MCPcopy Create free account
hub / github.com/davisking/dlib / timer_test

Function timer_test

dlib/test/timer.cpp:96–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94 typename timer_t
95 >
96 void timer_test (
97 )
98 /*!
99 requires
100 - timer_t is an implementation of dlib/timer/timer_abstract.h is instantiated
101 timer_test_helper
102 ensures
103 - runs tests on timer_t for compliance with the specs
104 !*/
105 {
106
107 print_spinner();
108 for (int j = 0; j < 3; ++j)
109 {
110 timer_test_helper h;
111
112 timer_t t1(h,&timer_test_helper::add);
113 timer_t t2(h,&timer_test_helper::add);
114 timer_t t3(h,&timer_test_helper::add);
115
116 DLIB_TEST(t1.delay_time() == 1000);
117 DLIB_TEST(t2.delay_time() == 1000);
118 DLIB_TEST(t3.delay_time() == 1000);
119 DLIB_TEST(t1.is_running() == false);
120 DLIB_TEST(t2.is_running() == false);
121 DLIB_TEST(t3.is_running() == false);
122 DLIB_TEST(t1.action_function() == &timer_test_helper::add);
123 DLIB_TEST(t2.action_function() == &timer_test_helper::add);
124 DLIB_TEST(t3.action_function() == &timer_test_helper::add);
125 DLIB_TEST(&t1.action_object() == &h);
126 DLIB_TEST(&t2.action_object() == &h);
127 DLIB_TEST(&t3.action_object() == &h);
128
129 t1.set_delay_time(1000);
130 t2.set_delay_time(500);
131 t3.set_delay_time(1500);
132
133 DLIB_TEST(t1.delay_time() == 1000);
134 DLIB_TEST(t2.delay_time() == 500);
135 DLIB_TEST(t3.delay_time() == 1500);
136 DLIB_TEST(t1.is_running() == false);
137 DLIB_TEST(t2.is_running() == false);
138 DLIB_TEST(t3.is_running() == false);
139 DLIB_TEST(t1.action_function() == &timer_test_helper::add);
140 DLIB_TEST(t2.action_function() == &timer_test_helper::add);
141 DLIB_TEST(t3.action_function() == &timer_test_helper::add);
142 DLIB_TEST(&t1.action_object() == &h);
143 DLIB_TEST(&t2.action_object() == &h);
144 DLIB_TEST(&t3.action_object() == &h);
145 dlib::sleep(1100);
146 print_spinner();
147 DLIB_TEST(h.count == 0);
148
149 t1.stop_and_wait();
150 t2.stop_and_wait();
151 t3.stop_and_wait();
152
153 dlib::sleep(1100);

Callers

nothing calls this directly

Calls 4

print_spinnerFunction · 0.85
action_functionMethod · 0.80
sleepFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected