|
- #include <gtest/gtest.h>
-
- #include "../../helper/now_mock.h"
-
- #include <asyncpp.h>
-
- using namespace ::testing;
- using namespace ::asyncpp;
- using namespace ::asyncpp::timing;
-
- TEST(delay_tests, poll)
- {
- StrictMock<now_mock> m;
-
- EXPECT_CALL(m, now)
- .WillOnce(Return(time_point(std::chrono::seconds( 0))))
- .WillOnce(Return(time_point(std::chrono::seconds( 999))))
- .WillOnce(Return(time_point(std::chrono::seconds(1000))));
-
- asyncpp::timing::timer t;
- timing::__impl::timer_base::lock l(t);
-
- {
- delay f(time_point(std::chrono::seconds(1000)));
-
- EXPECT_EQ(0, t.resource_count());
-
- auto r0 = f.poll();
- ASSERT_FALSE(r0);
-
- EXPECT_EQ(1, t.resource_count());
-
- auto r1 = f.poll();
- ASSERT_FALSE(r1);
-
- EXPECT_EQ(1, t.resource_count());
-
- auto r2 = f.poll();
- ASSERT_TRUE (r2);
- }
-
- EXPECT_EQ(0, t.resource_count());
- }
|