// MODULES: ../impl/chrono_io.cpp #include #include #include #include #include #include #include namespace beast { class abstract_clock_test : public unit_test::Suite { public: template void test(std::string name, AbstractClock& c) { testcase(name); auto const t1(c.now()); std::this_thread::sleep_for(std::chrono::milliseconds(1500)); auto const t2(c.now()); log << "t1= " << t1.time_since_epoch().count() << ", t2= " << t2.time_since_epoch().count() << ", elapsed= " << (t2 - t1).count() << std::endl; pass(); } void testManual() { testcase("manual"); using clock_type = ManualClock; clock_type c; auto c1 = c.now().time_since_epoch(); c.set(clock_type::time_point(std::chrono::seconds(1))); auto c2 = c.now().time_since_epoch(); c.set(clock_type::time_point(std::chrono::seconds(2))); auto c3 = c.now().time_since_epoch(); log << "[" << c1.count() << "," << c2.count() << "," << c3.count() << "]" << std::endl; pass(); } void run() override { test("steady_clock", getAbstractClock()); test("system_clock", getAbstractClock()); test("high_resolution_clock", getAbstractClock()); testManual(); } }; BEAST_DEFINE_TESTSUITE_MANUAL(abstract_clock, beast, beast); } // namespace beast