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

Function queue_sort_test

dlib/test/queue.cpp:31–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 typename queue
30 >
31 void queue_sort_test (
32 )
33 /*!
34 requires
35 - queue is an implementation of queue/queue_sort_abstract.h
36 is instantiated with int
37 ensures
38 - runs tests on queue for compliance with the specs
39 !*/
40 {
41
42 print_spinner();
43 srand(static_cast<unsigned int>(time(0)));
44
45 queue q,q2;
46
47 enumerable<int>& e = q;
48
49 // I will use these DLIB_TEST_MSG macros to assert that conditions are true. If they are
50 // false then it means we have detected an error in the queue object. CASSERT
51 // will then throw an exception which we will catch at the end of this function and
52 // report as an error/failed test.
53 DLIB_TEST(e.at_start() == true);
54
55 int a = 0;
56
57 DLIB_TEST(q.size() == 0);
58 DLIB_TEST(q.at_start() == true);
59 DLIB_TEST(q.current_element_valid() == false);
60
61 q.sort();
62
63 DLIB_TEST(q.size() == 0);
64 DLIB_TEST(q.at_start() == true);
65 DLIB_TEST(q.current_element_valid() == false);
66
67 DLIB_TEST (q.move_next() == false);
68 DLIB_TEST (q.move_next() == false);
69 DLIB_TEST (q.move_next() == false);
70 DLIB_TEST (q.move_next() == false);
71 DLIB_TEST (q.move_next() == false);
72 DLIB_TEST (q.move_next() == false);
73
74
75 DLIB_TEST(q.size() == 0);
76 DLIB_TEST(q.at_start() == false);
77 DLIB_TEST(q.current_element_valid() == false);
78
79
80 q.reset();
81
82 DLIB_TEST(q.size() == 0);
83 DLIB_TEST(q.at_start() == true);
84 DLIB_TEST(q.current_element_valid() == false);
85
86
87
88

Callers

nothing calls this directly

Calls 15

print_spinnerFunction · 0.85
sortMethod · 0.80
serializeFunction · 0.70
deserializeFunction · 0.70
swapFunction · 0.70
randClass · 0.50
at_startMethod · 0.45
sizeMethod · 0.45
current_element_validMethod · 0.45
move_nextMethod · 0.45
resetMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected