| 173 | typename timer_t |
| 174 | > |
| 175 | void timer_test ( |
| 176 | ) |
| 177 | /*! |
| 178 | requires |
| 179 | - timer_t is an implementation of dlib/timer/timer_abstract.h is instantiated |
| 180 | timer_test_helper |
| 181 | ensures |
| 182 | - runs tests on timer_t for compliance with the specs |
| 183 | !*/ |
| 184 | { |
| 185 | |
| 186 | print_spinner(); |
| 187 | for (int j = 0; j < 3; ++j) |
| 188 | { |
| 189 | timer_test_helper h; |
| 190 | timer_test_helper h2; |
| 191 | timer_test_helper h3; |
| 192 | |
| 193 | timer_t t1(h,&timer_test_helper::add); |
| 194 | timer_t t2(h2,&timer_test_helper::add); |
| 195 | timer_t t3(h3,&timer_test_helper::add); |
| 196 | |
| 197 | DLIB_TEST(t1.delay_time() == 1000); |
| 198 | DLIB_TEST(t2.delay_time() == 1000); |
| 199 | DLIB_TEST(t3.delay_time() == 1000); |
| 200 | DLIB_TEST(t1.is_running() == false); |
| 201 | DLIB_TEST(t2.is_running() == false); |
| 202 | DLIB_TEST(t3.is_running() == false); |
| 203 | DLIB_TEST(t1.action_function() == &timer_test_helper::add); |
| 204 | DLIB_TEST(t2.action_function() == &timer_test_helper::add); |
| 205 | DLIB_TEST(t3.action_function() == &timer_test_helper::add); |
| 206 | DLIB_TEST(&t1.action_object() == &h); |
| 207 | DLIB_TEST(&t2.action_object() == &h2); |
| 208 | DLIB_TEST(&t3.action_object() == &h3); |
| 209 | |
| 210 | t1.set_delay_time(1000); |
| 211 | t2.set_delay_time(500); |
| 212 | t3.set_delay_time(1500); |
| 213 | |
| 214 | DLIB_TEST(t1.delay_time() == 1000); |
| 215 | DLIB_TEST(t2.delay_time() == 500); |
| 216 | DLIB_TEST(t3.delay_time() == 1500); |
| 217 | DLIB_TEST(t1.is_running() == false); |
| 218 | DLIB_TEST(t2.is_running() == false); |
| 219 | DLIB_TEST(t3.is_running() == false); |
| 220 | DLIB_TEST(t1.action_function() == &timer_test_helper::add); |
| 221 | DLIB_TEST(t2.action_function() == &timer_test_helper::add); |
| 222 | DLIB_TEST(t3.action_function() == &timer_test_helper::add); |
| 223 | DLIB_TEST(&t1.action_object() == &h); |
| 224 | DLIB_TEST(&t2.action_object() == &h2); |
| 225 | DLIB_TEST(&t3.action_object() == &h3); |
| 226 | dlib::sleep(1100); |
| 227 | print_spinner(); |
| 228 | DLIB_TEST(h.get_count() == 0); |
| 229 | DLIB_TEST(h2.get_count() == 0); |
| 230 | DLIB_TEST(h3.get_count() == 0); |
| 231 | |
| 232 | t1.stop_and_wait(); |
nothing calls this directly
no test coverage detected