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

Function run_test

dlib/test/any_function.cpp:84–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82// ----------------------------------------------------------------------------------------
83
84 void run_test()
85 {
86 any_function<int()> a, b, c;
87
88 DLIB_TEST(a.is_empty());
89 DLIB_TEST(a.is_set()==false);
90 DLIB_TEST(a.contains<int(*)()>() == false);
91 DLIB_TEST(a.contains<test>() == false);
92 DLIB_TEST(a.is_empty());
93
94 a = b;
95
96 swap(a,b);
97 a.swap(b);
98
99 a = test();
100 test_contains_4(a);
101
102
103 bool error = false;
104 try
105 {
106 any_cast<int(*)()>(a);
107 }
108 catch (bad_any_cast&)
109 {
110 error = true;
111 }
112 DLIB_TEST(error);
113
114 swap(a,b);
115
116 test_contains_4(b);
117
118 DLIB_TEST(a.is_empty());
119
120 a = b;
121
122 test_contains_4(a);
123
124 c.get<test2>() = test2(10);
125 DLIB_TEST(c.get<test2>().v == 10);
126
127 a = c;
128 DLIB_TEST(a.cast_to<test2>().v == 10);
129
130
131 a.clear();
132 DLIB_TEST(a.is_empty());
133 error = false;
134 try
135 {
136 any_cast<test>(a);
137 }
138 catch (bad_any_cast&)
139 {
140 error = true;
141 }

Callers 1

perform_testMethod · 0.70

Calls 8

swapFunction · 0.70
testClass · 0.70
test_contains_4Function · 0.70
test2Class · 0.70
is_emptyMethod · 0.45
is_setMethod · 0.45
swapMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected