You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
891 B

  1. #include <gtest/gtest.h>
  2. #include "../../helper/now_mock.h"
  3. #include <asyncpp.h>
  4. using namespace ::testing;
  5. using namespace ::asyncpp;
  6. using namespace ::asyncpp::timing;
  7. TEST(delay_tests, poll)
  8. {
  9. StrictMock<now_mock> m;
  10. EXPECT_CALL(m, now)
  11. .WillOnce(Return(time_point(std::chrono::seconds( 0))))
  12. .WillOnce(Return(time_point(std::chrono::seconds( 999))))
  13. .WillOnce(Return(time_point(std::chrono::seconds(1000))));
  14. asyncpp::timing::timer t;
  15. timing::__impl::timer_base::lock l(t);
  16. {
  17. delay f(time_point(std::chrono::seconds(1000)));
  18. EXPECT_EQ(0, t.resource_count());
  19. auto r0 = f.poll();
  20. ASSERT_FALSE(r0);
  21. EXPECT_EQ(1, t.resource_count());
  22. auto r1 = f.poll();
  23. ASSERT_FALSE(r1);
  24. EXPECT_EQ(1, t.resource_count());
  25. auto r2 = f.poll();
  26. ASSERT_TRUE (r2);
  27. }
  28. EXPECT_EQ(0, t.resource_count());
  29. }