forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeoutBlockingWaitStrategyTests.cpp
More file actions
44 lines (29 loc) · 1.1 KB
/
Copy pathTimeoutBlockingWaitStrategyTests.cpp
File metadata and controls
44 lines (29 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "stdafx.h"
#include "Disruptor/Sequence.h"
#include "Disruptor/TimeoutBlockingWaitStrategy.h"
#include "Disruptor/TimeoutException.h"
#include "SequenceBarrierMock.h"
using namespace Disruptor;
BOOST_AUTO_TEST_SUITE(TimeoutBlockingWaitStrategyTest)
BOOST_AUTO_TEST_CASE(ShouldTimeoutWaitFor)
{
auto sequenceBarrierMock = std::make_shared< testing::NiceMock< Tests::SequenceBarrierMock > >();
auto theTimeout = std::chrono::milliseconds(500);
auto waitStrategy = std::make_shared< TimeoutBlockingWaitStrategy >(theTimeout);
auto cursor = std::make_shared< Sequence >(5);
const auto& dependent = cursor;
EXPECT_CALL(*sequenceBarrierMock, checkAlert()).Times(testing::AtLeast(1));
auto t0 = ClockConfig::Clock::now();
try
{
waitStrategy->waitFor(6, *cursor, *dependent, *sequenceBarrierMock);
throw std::runtime_error("TimeoutException should have been thrown");
}
catch (TimeoutException&)
{
}
auto t1 = ClockConfig::Clock::now();
auto timeWaiting = t1 - t0;
BOOST_CHECK(timeWaiting >= theTimeout);
}
BOOST_AUTO_TEST_SUITE_END()