mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-29 08:05:50 +00:00
@@ -43,6 +43,9 @@ struct AnyStrandTests : ::testing::Test {
|
||||
template <typename T>
|
||||
using StoppableOperationType = ::testing::NiceMock<MockStoppableOperation<T>>;
|
||||
|
||||
template <typename T>
|
||||
using RepeatingOperationType = NiceMock<MockRepeatingOperation<T>>;
|
||||
|
||||
::testing::NaggyMock<MockStrand> mockStrand;
|
||||
AnyStrand strand{static_cast<MockStrand&>(mockStrand)};
|
||||
};
|
||||
@@ -146,3 +149,15 @@ TEST_F(AnyStrandTests, ExecuteWithTimoutAndStopTokenAndReturnValueThrowsExceptio
|
||||
[[maybe_unused]] auto unused = strand.execute([](auto) { return 42; }, std::chrono::milliseconds{1})
|
||||
);
|
||||
}
|
||||
|
||||
TEST_F(AnyStrandTests, RepeatingOperation)
|
||||
{
|
||||
auto mockRepeatingOp = RepeatingOperationType<std::any>{};
|
||||
EXPECT_CALL(mockRepeatingOp, wait());
|
||||
EXPECT_CALL(mockStrand, executeRepeatedly(std::chrono::milliseconds{1}, A<std::function<std::any()>>()))
|
||||
.WillOnce([&mockRepeatingOp] -> RepeatingOperationType<std::any> const& { return mockRepeatingOp; });
|
||||
|
||||
auto res = strand.executeRepeatedly(std::chrono::milliseconds{1}, [] -> void { throw 0; });
|
||||
static_assert(std::is_same_v<decltype(res), AnyOperation<void>>);
|
||||
res.wait();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user