Commit 9a8ed037 authored by Davis King's avatar Davis King
Browse files

Switched all the test statements in the regression test suite from

DLIB_CASSERT to DLIB_TEST and DLIB_TEST_MSG.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402975
parent 574215ed
...@@ -60,7 +60,7 @@ namespace ...@@ -60,7 +60,7 @@ namespace
for (int i = 0; i < (int)a.size(); ++i) for (int i = 0; i < (int)a.size(); ++i)
{ {
DLIB_CASSERT(a[i] >= i,"1"); DLIB_TEST_MSG(a[i] >= i,"1");
// cout << a[i] << endl; // cout << a[i] << endl;
} }
...@@ -81,7 +81,7 @@ namespace ...@@ -81,7 +81,7 @@ namespace
for (int i = 0; i < (int)a.size(); ++i) for (int i = 0; i < (int)a.size(); ++i)
{ {
// cout << a[i] << endl; // cout << a[i] << endl;
DLIB_CASSERT(a[i] >= i,"2"); DLIB_TEST_MSG(a[i] >= i,"2");
} }
} }
...@@ -94,32 +94,32 @@ namespace ...@@ -94,32 +94,32 @@ namespace
seq test, test2; seq test, test2;
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
enumerable<int>& e = test; enumerable<int>& e = test;
DLIB_CASSERT(e.at_start() == true,""); DLIB_TEST(e.at_start() == true);
DLIB_CASSERT(e.current_element_valid() == false,""); DLIB_TEST(e.current_element_valid() == false);
for (int g = 0; g < 5; ++g) for (int g = 0; g < 5; ++g)
{ {
test.clear(); test.clear();
test2.clear(); test2.clear();
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(e.at_start() == true,""); DLIB_TEST(e.at_start() == true);
DLIB_CASSERT(e.current_element_valid() == false,""); DLIB_TEST(e.current_element_valid() == false);
DLIB_CASSERT(e.move_next() == false,""); DLIB_TEST(e.move_next() == false);
DLIB_CASSERT(e.current_element_valid() == false,""); DLIB_TEST(e.current_element_valid() == false);
DLIB_CASSERT(e.at_start() == false,""); DLIB_TEST(e.at_start() == false);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
test.clear(); test.clear();
test2.clear(); test2.clear();
...@@ -132,39 +132,39 @@ namespace ...@@ -132,39 +132,39 @@ namespace
test.add(i,a); test.add(i,a);
} }
DLIB_CASSERT(test.size() == 100,""); DLIB_TEST(test.size() == 100);
for (int i = 0; i < static_cast<int>(test.size()); ++i) for (int i = 0; i < static_cast<int>(test.size()); ++i)
{ {
DLIB_CASSERT(test[i] == i,""); DLIB_TEST(test[i] == i);
} }
swap(test,test2); swap(test,test2);
a = 0; a = 0;
DLIB_CASSERT(test2.at_start() == true,""); DLIB_TEST(test2.at_start() == true);
while(test2.move_next()) while(test2.move_next())
{ {
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.current_element_valid() == true,""); DLIB_TEST(test2.current_element_valid() == true);
DLIB_CASSERT(test2.element() == a,""); DLIB_TEST(test2.element() == a);
++a; ++a;
} }
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
test2.reset(); test2.reset();
DLIB_CASSERT(test2.at_start() == true,""); DLIB_TEST(test2.at_start() == true);
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
a = 0; a = 0;
while(test2.move_next()) while(test2.move_next())
{ {
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.current_element_valid() == true,""); DLIB_TEST(test2.current_element_valid() == true);
DLIB_CASSERT(test2.element() == a,""); DLIB_TEST(test2.element() == a);
++a; ++a;
} }
...@@ -177,20 +177,20 @@ namespace ...@@ -177,20 +177,20 @@ namespace
a = ::rand(); a = ::rand();
test.add(0,a); test.add(0,a);
} }
DLIB_CASSERT(test.size() == 1000,""); DLIB_TEST(test.size() == 1000);
test.sort(); test.sort();
for (unsigned long i = 0; i < test.size()-1; ++i) for (unsigned long i = 0; i < test.size()-1; ++i)
{ {
DLIB_CASSERT(test[i] <= test[i+1],""); DLIB_TEST(test[i] <= test[i+1]);
} }
a = 0; a = 0;
while(test.move_next()) while(test.move_next())
{ {
DLIB_CASSERT(a <= test.element(),""); DLIB_TEST(a <= test.element());
a = test.element(); a = test.element();
} }
...@@ -198,8 +198,8 @@ namespace ...@@ -198,8 +198,8 @@ namespace
test.clear(); test.clear();
test2.clear(); test2.clear();
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test2.size() == 0,""); DLIB_TEST(test2.size() == 0);
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)
{ {
...@@ -214,15 +214,15 @@ namespace ...@@ -214,15 +214,15 @@ namespace
} }
test.cat(test2); test.cat(test2);
DLIB_CASSERT(test.size() == 200,""); DLIB_TEST(test.size() == 200);
DLIB_CASSERT(test2.size() == 0,""); DLIB_TEST(test2.size() == 0);
// serialize the state of test, then clear test, then // serialize the state of test, then clear test, then
// load the state back into test. // load the state back into test.
ostringstream sout; ostringstream sout;
serialize(test,sout); serialize(test,sout);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
istringstream sin(sout.str()); istringstream sin(sout.str());
test.clear(); test.clear();
deserialize(test,sin); deserialize(test,sin);
...@@ -230,31 +230,31 @@ namespace ...@@ -230,31 +230,31 @@ namespace
for (int i = 0; i < 200; ++i) for (int i = 0; i < 200; ++i)
{ {
DLIB_CASSERT(test[i] == i,""); DLIB_TEST(test[i] == i);
} }
a = 0; a = 0;
while (test.move_next()) while (test.move_next())
{ {
DLIB_CASSERT(test.element() == a,""); DLIB_TEST(test.element() == a);
DLIB_CASSERT(test[0]==0,""); DLIB_TEST(test[0]==0);
++a; ++a;
} }
DLIB_CASSERT(a == 200,""); DLIB_TEST(a == 200);
DLIB_CASSERT(test[9] == 9,""); DLIB_TEST(test[9] == 9);
test.remove(9,a); test.remove(9,a);
DLIB_CASSERT(a == 9,""); DLIB_TEST(a == 9);
DLIB_CASSERT(test[9] == 10,""); DLIB_TEST(test[9] == 10);
DLIB_CASSERT(test.size() == 199,""); DLIB_TEST(test.size() == 199);
test.remove(0,a); test.remove(0,a);
DLIB_CASSERT(test[0] == 1,""); DLIB_TEST(test[0] == 1);
DLIB_CASSERT(test.size() == 198,""); DLIB_TEST(test.size() == 198);
DLIB_CASSERT(a == 0,""); DLIB_TEST(a == 0);
DLIB_CASSERT(test[9] == 11,""); DLIB_TEST(test[9] == 11);
DLIB_CASSERT(test[20] == 22,""); DLIB_TEST(test[20] == 22);
...@@ -268,15 +268,15 @@ namespace ...@@ -268,15 +268,15 @@ namespace
int a = 3; int a = 3;
test.add(0,a); test.add(0,a);
} }
DLIB_CASSERT(test.size() == 100,""); DLIB_TEST(test.size() == 100);
remover<int>& go = test; remover<int>& go = test;
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)
{ {
int a = 9; int a = 9;
go.remove_any(a); go.remove_any(a);
DLIB_CASSERT(a == 3,""); DLIB_TEST(a == 3);
} }
DLIB_CASSERT(go.size() == 0,""); DLIB_TEST(go.size() == 0);
} }
......
...@@ -174,105 +174,105 @@ namespace ...@@ -174,105 +174,105 @@ namespace
void assert_in_state_1 ( void assert_in_state_1 (
) )
{ {
DLIB_CASSERT (i1 == 1,""); DLIB_TEST (i1 == 1);
DLIB_CASSERT (i2 == 2,""); DLIB_TEST (i2 == 2);
DLIB_CASSERT (i3 == 3,""); DLIB_TEST (i3 == 3);
DLIB_CASSERT (i4 == 4,""); DLIB_TEST (i4 == 4);
DLIB_CASSERT (i5 == 5,""); DLIB_TEST (i5 == 5);
DLIB_CASSERT (i6 == 6,""); DLIB_TEST (i6 == 6);
DLIB_CASSERT (i7 == 7,""); DLIB_TEST (i7 == 7);
DLIB_CASSERT (i1_0 == 0,""); DLIB_TEST (i1_0 == 0);
DLIB_CASSERT (i2_0 == 0,""); DLIB_TEST (i2_0 == 0);
DLIB_CASSERT (i3_0 == 0,""); DLIB_TEST (i3_0 == 0);
DLIB_CASSERT (i4_0 == 0,""); DLIB_TEST (i4_0 == 0);
DLIB_CASSERT (i5_0 == 0,""); DLIB_TEST (i5_0 == 0);
DLIB_CASSERT (i6_0 == 0,""); DLIB_TEST (i6_0 == 0);
DLIB_CASSERT (i7_0 == 0,""); DLIB_TEST (i7_0 == 0);
DLIB_CASSERT (i1_n == -1,""); DLIB_TEST (i1_n == -1);
DLIB_CASSERT (i2_n == -2,""); DLIB_TEST (i2_n == -2);
DLIB_CASSERT (i3_n == -3,""); DLIB_TEST (i3_n == -3);
DLIB_CASSERT (abs(f1 -123.456) < 1e-5,""); DLIB_TEST (abs(f1 -123.456) < 1e-5);
DLIB_CASSERT (abs(f2 - 543.341) < 1e-10,""); DLIB_TEST (abs(f2 - 543.341) < 1e-10);
DLIB_CASSERT (abs(f3 - 5234234.23) < 1e-10,""); DLIB_TEST (abs(f3 - 5234234.23) < 1e-10);
DLIB_CASSERT (f1_inf == numeric_limits<float>::infinity(),""); DLIB_TEST (f1_inf == numeric_limits<float>::infinity());
DLIB_CASSERT (f2_inf == numeric_limits<double>::infinity(),""); DLIB_TEST (f2_inf == numeric_limits<double>::infinity());
DLIB_CASSERT (f3_inf == numeric_limits<long double>::infinity(),""); DLIB_TEST (f3_inf == numeric_limits<long double>::infinity());
DLIB_CASSERT (f1_ninf == -numeric_limits<float>::infinity(),""); DLIB_TEST (f1_ninf == -numeric_limits<float>::infinity());
DLIB_CASSERT (f2_ninf == -numeric_limits<double>::infinity(),""); DLIB_TEST (f2_ninf == -numeric_limits<double>::infinity());
DLIB_CASSERT (f3_ninf == -numeric_limits<long double>::infinity(),""); DLIB_TEST (f3_ninf == -numeric_limits<long double>::infinity());
DLIB_CASSERT (!(f1_qnan <= numeric_limits<float>::infinity() && f1_qnan >= -numeric_limits<float>::infinity() ),""); DLIB_TEST (!(f1_qnan <= numeric_limits<float>::infinity() && f1_qnan >= -numeric_limits<float>::infinity() ));
DLIB_CASSERT (!(f2_qnan <= numeric_limits<double>::infinity() && f1_qnan >= -numeric_limits<double>::infinity() ),""); DLIB_TEST (!(f2_qnan <= numeric_limits<double>::infinity() && f1_qnan >= -numeric_limits<double>::infinity() ));
DLIB_CASSERT (!(f3_qnan <= numeric_limits<long double>::infinity() && f1_qnan >= -numeric_limits<long double>::infinity() ),""); DLIB_TEST (!(f3_qnan <= numeric_limits<long double>::infinity() && f1_qnan >= -numeric_limits<long double>::infinity() ));
DLIB_CASSERT (!(f1_snan <= numeric_limits<float>::infinity() && f1_qnan >= -numeric_limits<float>::infinity() ),""); DLIB_TEST (!(f1_snan <= numeric_limits<float>::infinity() && f1_qnan >= -numeric_limits<float>::infinity() ));
DLIB_CASSERT (!(f2_snan <= numeric_limits<double>::infinity() && f1_qnan >= -numeric_limits<double>::infinity() ),""); DLIB_TEST (!(f2_snan <= numeric_limits<double>::infinity() && f1_qnan >= -numeric_limits<double>::infinity() ));
DLIB_CASSERT (!(f3_snan <= numeric_limits<long double>::infinity() && f1_qnan >= -numeric_limits<long double>::infinity() ),""); DLIB_TEST (!(f3_snan <= numeric_limits<long double>::infinity() && f1_qnan >= -numeric_limits<long double>::infinity() ));
DLIB_CASSERT (s1 == "davis",""); DLIB_TEST (s1 == "davis");
DLIB_CASSERT (s2 == L"yo yo yo",""); DLIB_TEST (s2 == L"yo yo yo");
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
DLIB_CASSERT (array[i] == i,""); DLIB_TEST (array[i] == i);
} }
DLIB_CASSERT (b_true == true,""); DLIB_TEST (b_true == true);
DLIB_CASSERT (b_false == false,""); DLIB_TEST (b_false == false);
} }
void assert_in_state_2 ( void assert_in_state_2 (
) )
{ {
DLIB_CASSERT (i1 == 10,""); DLIB_TEST (i1 == 10);
DLIB_CASSERT (i2 == 20,""); DLIB_TEST (i2 == 20);
DLIB_CASSERT (i3 == 30,""); DLIB_TEST (i3 == 30);
DLIB_CASSERT (i4 == 40,""); DLIB_TEST (i4 == 40);
DLIB_CASSERT (i5 == 50,""); DLIB_TEST (i5 == 50);
DLIB_CASSERT (i6 == 60,""); DLIB_TEST (i6 == 60);
DLIB_CASSERT (i7 == 70,""); DLIB_TEST (i7 == 70);
DLIB_CASSERT (i1_0 == 5,""); DLIB_TEST (i1_0 == 5);
DLIB_CASSERT (i2_0 == 6,""); DLIB_TEST (i2_0 == 6);
DLIB_CASSERT (i3_0 == 7,""); DLIB_TEST (i3_0 == 7);
DLIB_CASSERT (i4_0 == 8,""); DLIB_TEST (i4_0 == 8);
DLIB_CASSERT (i5_0 == 9,""); DLIB_TEST (i5_0 == 9);
DLIB_CASSERT (i6_0 == 10,""); DLIB_TEST (i6_0 == 10);
DLIB_CASSERT (i7_0 == 11,""); DLIB_TEST (i7_0 == 11);
DLIB_CASSERT (i1_n == -13,""); DLIB_TEST (i1_n == -13);
DLIB_CASSERT (i2_n == -25,""); DLIB_TEST (i2_n == -25);
DLIB_CASSERT (i3_n == -12,""); DLIB_TEST (i3_n == -12);
DLIB_CASSERT (abs(f1 - 45.3) < 1e-5,""); DLIB_TEST (abs(f1 - 45.3) < 1e-5);
DLIB_CASSERT (abs(f2 - 0.001) < 1e-10,""); DLIB_TEST (abs(f2 - 0.001) < 1e-10);
DLIB_CASSERT (abs(f3 - 2.332) < 1e-10,""); DLIB_TEST (abs(f3 - 2.332) < 1e-10);
DLIB_CASSERT (abs(f1_inf - 45.3) < 1e-5,""); DLIB_TEST (abs(f1_inf - 45.3) < 1e-5);
DLIB_CASSERT (abs(f2_inf - 0.001) < 1e-10,""); DLIB_TEST (abs(f2_inf - 0.001) < 1e-10);
DLIB_CASSERT (abs(f3_inf - 2.332) < 1e-10,""); DLIB_TEST (abs(f3_inf - 2.332) < 1e-10);
DLIB_CASSERT (abs(f1_ninf - 45.3) < 1e-5,""); DLIB_TEST (abs(f1_ninf - 45.3) < 1e-5);
DLIB_CASSERT (abs(f2_ninf - 0.001) < 1e-10,""); DLIB_TEST (abs(f2_ninf - 0.001) < 1e-10);
DLIB_CASSERT (abs(f3_ninf - 2.332) < 1e-10,""); DLIB_TEST (abs(f3_ninf - 2.332) < 1e-10);
DLIB_CASSERT (abs(f1_qnan - 45.3) < 1e-5,""); DLIB_TEST (abs(f1_qnan - 45.3) < 1e-5);
DLIB_CASSERT (abs(f2_qnan - 0.001) < 1e-10,""); DLIB_TEST (abs(f2_qnan - 0.001) < 1e-10);
DLIB_CASSERT (abs(f3_qnan - 2.332) < 1e-10,""); DLIB_TEST (abs(f3_qnan - 2.332) < 1e-10);
DLIB_CASSERT (abs(f1_snan - 45.3) < 1e-5,""); DLIB_TEST (abs(f1_snan - 45.3) < 1e-5);
DLIB_CASSERT (abs(f2_snan - 0.001) < 1e-10,""); DLIB_TEST (abs(f2_snan - 0.001) < 1e-10);
DLIB_CASSERT (abs(f3_snan - 2.332) < 1e-10,""); DLIB_TEST (abs(f3_snan - 2.332) < 1e-10);
DLIB_CASSERT (s1 == "",""); DLIB_TEST (s1 == "");
DLIB_CASSERT (s2 == L"",""); DLIB_TEST (s2 == L"");
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
DLIB_CASSERT (array[i] == 10-i,""); DLIB_TEST (array[i] == 10-i);
} }
DLIB_CASSERT (b_true == false,""); DLIB_TEST (b_true == false);
DLIB_CASSERT (b_false == true,""); DLIB_TEST (b_false == true);
} }
......
...@@ -40,92 +40,92 @@ namespace ...@@ -40,92 +40,92 @@ namespace
set test, test2; set test, test2;
enumerable<const int>& e = test; enumerable<const int>& e = test;
DLIB_CASSERT(e.at_start() == true,""); DLIB_TEST(e.at_start() == true);
for (int j = 0; j < 4; ++j) for (int j = 0; j < 4; ++j)
{ {
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.is_member(5) == false,""); DLIB_TEST(test.is_member(5) == false);
DLIB_CASSERT(test.is_member(0) == false,""); DLIB_TEST(test.is_member(0) == false);
DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_TEST(test.is_member(-999) == false);
DLIB_CASSERT(test.is_member(4999) == false,""); DLIB_TEST(test.is_member(4999) == false);
int a,b = 0; int a,b = 0;
a = 8; a = 8;
test.add(a); test.add(a);
DLIB_CASSERT(test.size() == 1,""); DLIB_TEST(test.size() == 1);
DLIB_CASSERT(test.is_member(8) == true,""); DLIB_TEST(test.is_member(8) == true);
DLIB_CASSERT(test.is_member(5) == false,""); DLIB_TEST(test.is_member(5) == false);
DLIB_CASSERT(test.is_member(0) == false,""); DLIB_TEST(test.is_member(0) == false);
DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_TEST(test.is_member(-999) == false);
DLIB_CASSERT(test.is_member(4999) == false,""); DLIB_TEST(test.is_member(4999) == false);
a = 53; a = 53;
test.add(a); test.add(a);
DLIB_CASSERT(test.size() == 2,""); DLIB_TEST(test.size() == 2);
DLIB_CASSERT(test.is_member(53) == true,""); DLIB_TEST(test.is_member(53) == true);
DLIB_CASSERT(test.is_member(5) == false,""); DLIB_TEST(test.is_member(5) == false);
DLIB_CASSERT(test.is_member(0) == false,""); DLIB_TEST(test.is_member(0) == false);
DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_TEST(test.is_member(-999) == false);
DLIB_CASSERT(test.is_member(4999) == false,""); DLIB_TEST(test.is_member(4999) == false);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test2.is_member(8) == true,""); DLIB_TEST(test2.is_member(8) == true);
DLIB_CASSERT(test2.is_member(5) == false,""); DLIB_TEST(test2.is_member(5) == false);
DLIB_CASSERT(test2.is_member(0) == false,""); DLIB_TEST(test2.is_member(0) == false);
DLIB_CASSERT(test2.is_member(-999) == false,""); DLIB_TEST(test2.is_member(-999) == false);
DLIB_CASSERT(test2.is_member(4999) == false,""); DLIB_TEST(test2.is_member(4999) == false);
DLIB_CASSERT(test2.size() == 2,""); DLIB_TEST(test2.size() == 2);
DLIB_CASSERT(test2.is_member(53) == true,""); DLIB_TEST(test2.is_member(53) == true);
DLIB_CASSERT(test2.is_member(5) == false,""); DLIB_TEST(test2.is_member(5) == false);
DLIB_CASSERT(test2.is_member(0) == false,""); DLIB_TEST(test2.is_member(0) == false);
DLIB_CASSERT(test2.is_member(-999) == false,""); DLIB_TEST(test2.is_member(-999) == false);
DLIB_CASSERT(test2.is_member(4999) == false,""); DLIB_TEST(test2.is_member(4999) == false);
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.is_member(8) == false,""); DLIB_TEST(test.is_member(8) == false);
DLIB_CASSERT(test.is_member(5) == false,""); DLIB_TEST(test.is_member(5) == false);
DLIB_CASSERT(test.is_member(0) == false,""); DLIB_TEST(test.is_member(0) == false);
DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_TEST(test.is_member(-999) == false);
DLIB_CASSERT(test.is_member(4999) == false,""); DLIB_TEST(test.is_member(4999) == false);
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.is_member(53) == false,""); DLIB_TEST(test.is_member(53) == false);
DLIB_CASSERT(test.is_member(5) == false,""); DLIB_TEST(test.is_member(5) == false);
DLIB_CASSERT(test.is_member(0) == false,""); DLIB_TEST(test.is_member(0) == false);
DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_TEST(test.is_member(-999) == false);
DLIB_CASSERT(test.is_member(4999) == false,""); DLIB_TEST(test.is_member(4999) == false);
test.clear(); test.clear();
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
while (test.size() < 10000) while (test.size() < 10000)
{ {
...@@ -134,9 +134,9 @@ namespace ...@@ -134,9 +134,9 @@ namespace
test.add(a); test.add(a);
} }
DLIB_CASSERT(test.size() == 10000,""); DLIB_TEST(test.size() == 10000);
test.clear(); test.clear();
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
while (test.size() < 10000) while (test.size() < 10000)
{ {
...@@ -145,7 +145,7 @@ namespace ...@@ -145,7 +145,7 @@ namespace
test.add(a); test.add(a);
} }
DLIB_CASSERT(test.size() == 10000,""); DLIB_TEST(test.size() == 10000);
int count = 0; int count = 0;
a = 0; a = 0;
...@@ -154,53 +154,53 @@ namespace ...@@ -154,53 +154,53 @@ namespace
enumerable<const int>& gogo = test; enumerable<const int>& gogo = test;
gogo.element(); gogo.element();
DLIB_CASSERT(test.element() == test.element(),""); DLIB_TEST(test.element() == test.element());
DLIB_CASSERT(test.element() == test.element(),""); DLIB_TEST(test.element() == test.element());
DLIB_CASSERT(test.element() == test.element(),""); DLIB_TEST(test.element() == test.element());
DLIB_CASSERT(a <= test.element(),""); DLIB_TEST(a <= test.element());
a = test.element(); a = test.element();
++count; ++count;
} }
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(count == 10000,""); DLIB_TEST(count == 10000);
test.swap(test2); test.swap(test2);
DLIB_CASSERT(test.size() == 2,""); DLIB_TEST(test.size() == 2);
DLIB_CASSERT(test2.size() == 10000,""); DLIB_TEST(test2.size() == 10000);
count = 0; count = 0;
a = -1; a = -1;
test2.reset(); test2.reset();
while (test2.move_next()) while (test2.move_next())
{ {
DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_TEST(test2.element() == test2.element());
DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_TEST(test2.element() == test2.element());
DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_TEST(test2.element() == test2.element());
DLIB_CASSERT(a < test2.element(),""); DLIB_TEST(a < test2.element());
a = test2.element(); a = test2.element();
++count; ++count;
} }
DLIB_CASSERT(test2.size() == 10000,""); DLIB_TEST(test2.size() == 10000);
DLIB_CASSERT(count == 10000,""); DLIB_TEST(count == 10000);
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.move_next() == false,""); DLIB_TEST(test2.move_next() == false);
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.move_next() == false,""); DLIB_TEST(test2.move_next() == false);
test2.clear(); test2.clear();
DLIB_CASSERT(test2.size() == 0,""); DLIB_TEST(test2.size() == 0);
DLIB_CASSERT(test2.at_start() == true,""); DLIB_TEST(test2.at_start() == true);
while (test.size() < 20000) while (test.size() < 20000)
{ {
...@@ -209,7 +209,7 @@ namespace ...@@ -209,7 +209,7 @@ namespace
test.add(a); test.add(a);
} }
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
{ {
int* array = new int[test.size()]; int* array = new int[test.size()];
...@@ -218,20 +218,20 @@ namespace ...@@ -218,20 +218,20 @@ namespace
count = 0; count = 0;
while (test.move_next()) while (test.move_next())
{ {
DLIB_CASSERT(test.element() == test.element(),""); DLIB_TEST(test.element() == test.element());
DLIB_CASSERT(test.element() == test.element(),""); DLIB_TEST(test.element() == test.element());
DLIB_CASSERT(test.element() == test.element(),""); DLIB_TEST(test.element() == test.element());
*tmp = test.element(); *tmp = test.element();
++tmp; ++tmp;
++count; ++count;
} }
DLIB_CASSERT(count == 20000,""); DLIB_TEST(count == 20000);
// serialize the state of test, then clear test, then // serialize the state of test, then clear test, then
// load the state back into test. // load the state back into test.
ostringstream sout; ostringstream sout;
serialize(test,sout); serialize(test,sout);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
istringstream sin(sout.str()); istringstream sin(sout.str());
test.clear(); test.clear();
deserialize(test,sin); deserialize(test,sin);
...@@ -241,34 +241,34 @@ namespace ...@@ -241,34 +241,34 @@ namespace
tmp = array; tmp = array;
for (int i = 0; i < 20000; ++i) for (int i = 0; i < 20000; ++i)
{ {
DLIB_CASSERT(test.is_member(*tmp) == true,""); DLIB_TEST(test.is_member(*tmp) == true);
++tmp; ++tmp;
} }
DLIB_CASSERT(test.size() == 20000,""); DLIB_TEST(test.size() == 20000);
tmp = array; tmp = array;
count = 0; count = 0;
while (test.size() > 10000) while (test.size() > 10000)
{ {
test.remove(*tmp,a); test.remove(*tmp,a);
DLIB_CASSERT(*tmp == a,""); DLIB_TEST(*tmp == a);
++tmp; ++tmp;
++count; ++count;
} }
DLIB_CASSERT(count == 10000,""); DLIB_TEST(count == 10000);
DLIB_CASSERT(test.size() == 10000,""); DLIB_TEST(test.size() == 10000);
while (test.move_next()) while (test.move_next())
{ {
DLIB_CASSERT(test.element() == *tmp,""); DLIB_TEST(test.element() == *tmp);
DLIB_CASSERT(test.element() == *tmp,""); DLIB_TEST(test.element() == *tmp);
DLIB_CASSERT(test.element() == *tmp,""); DLIB_TEST(test.element() == *tmp);
++tmp; ++tmp;
++count; ++count;
} }
DLIB_CASSERT(count == 20000,""); DLIB_TEST(count == 20000);
DLIB_CASSERT(test.size() == 10000,""); DLIB_TEST(test.size() == 10000);
while (test.size() < 20000) while (test.size() < 20000)
{ {
...@@ -283,26 +283,26 @@ namespace ...@@ -283,26 +283,26 @@ namespace
a = 0; a = 0;
while (test2.move_next()) while (test2.move_next())
{ {
DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_TEST(test2.element() == test2.element());
DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_TEST(test2.element() == test2.element());
DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_TEST(test2.element() == test2.element());
DLIB_CASSERT(a <= test2.element(),""); DLIB_TEST(a <= test2.element());
a = test2.element(); a = test2.element();
++count; ++count;
} }
DLIB_CASSERT(count == 20000,""); DLIB_TEST(count == 20000);
DLIB_CASSERT(test2.size() == 20000,""); DLIB_TEST(test2.size() == 20000);
a = -1; a = -1;
while (test2.size()>0) while (test2.size()>0)
{ {
test2.remove_any(b); test2.remove_any(b);
DLIB_CASSERT( a < b,""); DLIB_TEST( a < b);
a = b; a = b;
} }
DLIB_CASSERT(test2.size() == 0,""); DLIB_TEST(test2.size() == 0);
delete [] array; delete [] array;
} }
...@@ -319,12 +319,12 @@ namespace ...@@ -319,12 +319,12 @@ namespace
a = -1; a = -1;
while (test.move_next()) while (test.move_next())
{ {
DLIB_CASSERT(a < test.element(),""); DLIB_TEST(a < test.element());
a = test.element(); a = test.element();
++count; ++count;
if (count == 5000) if (count == 5000)
break; break;
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
} }
test.reset(); test.reset();
...@@ -333,13 +333,13 @@ namespace ...@@ -333,13 +333,13 @@ namespace
a = -1; a = -1;
while (test.move_next()) while (test.move_next())
{ {
DLIB_CASSERT(a < test.element(),""); DLIB_TEST(a < test.element());
a = test.element(); a = test.element();
++count; ++count;
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
} }
DLIB_CASSERT(count == 10000,""); DLIB_TEST(count == 10000);
test.clear(); test.clear();
...@@ -349,63 +349,63 @@ namespace ...@@ -349,63 +349,63 @@ namespace
{ {
DLIB_CASSERT(test == test2,""); DLIB_TEST(test == test2);
DLIB_CASSERT((test < test2) == false,""); DLIB_TEST((test < test2) == false);
DLIB_CASSERT((test2 < test) == false,""); DLIB_TEST((test2 < test) == false);
int a = 3, b = 3; int a = 3, b = 3;
test.add(a); test.add(a);
test2.add(b); test2.add(b);
test.move_next(); test.move_next();
DLIB_CASSERT(test == test2,""); DLIB_TEST(test == test2);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test.move_next(); test.move_next();
DLIB_CASSERT((test < test2) == false,""); DLIB_TEST((test < test2) == false);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test.move_next(); test.move_next();
DLIB_CASSERT((test2 < test) == false,""); DLIB_TEST((test2 < test) == false);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
a = 2; b = 5; a = 2; b = 5;
test.add(a); test.add(a);
test2.add(b); test2.add(b);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test == test2) == false,""); DLIB_TEST((test == test2) == false);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test < test2) == true,""); DLIB_TEST((test < test2) == true);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test2 < test) == false,""); DLIB_TEST((test2 < test) == false);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
a = 8; a = 8;
test.add(a); test.add(a);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test == test2) == false,""); DLIB_TEST((test == test2) == false);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test < test2) == false,""); DLIB_TEST((test < test2) == false);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test2 < test) == true,""); DLIB_TEST((test2 < test) == true);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test.clear(); test.clear();
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test == test2) == false,""); DLIB_TEST((test == test2) == false);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test < test2) == true,""); DLIB_TEST((test < test2) == true);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
test2.move_next(); test2.move_next();
DLIB_CASSERT((test2 < test) == false,""); DLIB_TEST((test2 < test) == false);
DLIB_CASSERT(test.at_start() && test2.at_start(),""); DLIB_TEST(test.at_start() && test2.at_start());
} }
...@@ -413,22 +413,22 @@ namespace ...@@ -413,22 +413,22 @@ namespace
{ {
test.clear(); test.clear();
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
int a = 5; int a = 5;
test.add(a); test.add(a);
a = 7; a = 7;
test.add(a); test.add(a);
DLIB_CASSERT(test.size() == 2,""); DLIB_TEST(test.size() == 2);
DLIB_CASSERT(test.is_member(7),""); DLIB_TEST(test.is_member(7));
DLIB_CASSERT(test.is_member(5),""); DLIB_TEST(test.is_member(5));
test.destroy(7); test.destroy(7);
DLIB_CASSERT(test.size() == 1,""); DLIB_TEST(test.size() == 1);
DLIB_CASSERT(!test.is_member(7),""); DLIB_TEST(!test.is_member(7));
DLIB_CASSERT(test.is_member(5),""); DLIB_TEST(test.is_member(5));
test.destroy(5); test.destroy(5);
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(!test.is_member(7),""); DLIB_TEST(!test.is_member(7));
DLIB_CASSERT(!test.is_member(5),""); DLIB_TEST(!test.is_member(5));
} }
......
...@@ -37,22 +37,22 @@ namespace ...@@ -37,22 +37,22 @@ namespace
buf test; buf test;
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
test.set_size(3); test.set_size(3);
buf test2; buf test2;
DLIB_CASSERT(test.size() == 8,""); DLIB_TEST(test.size() == 8);
for (int g = 0; g < 2; ++g) for (int g = 0; g < 2; ++g)
{ {
test.clear(); test.clear();
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
test.set_size(2); test.set_size(2);
DLIB_CASSERT(test.size() == 4,""); DLIB_TEST(test.size() == 4);
...@@ -62,186 +62,186 @@ namespace ...@@ -62,186 +62,186 @@ namespace
test[3] = 'f'; test[3] = 'f';
unsigned long id = test.get_element_id(2); unsigned long id = test.get_element_id(2);
DLIB_CASSERT(test[test.get_element_index(id)] == 'd',""); DLIB_TEST(test[test.get_element_index(id)] == 'd');
DLIB_CASSERT(test[0] == 'a',""); DLIB_TEST(test[0] == 'a');
DLIB_CASSERT(test[1] == 's',""); DLIB_TEST(test[1] == 's');
DLIB_CASSERT(test[2] == 'd',""); DLIB_TEST(test[2] == 'd');
DLIB_CASSERT(test[3] == 'f',""); DLIB_TEST(test[3] == 'f');
DLIB_CASSERT(test2.size() == 0,""); DLIB_TEST(test2.size() == 0);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test2.size() == 4,""); DLIB_TEST(test2.size() == 4);
DLIB_CASSERT(test2[0] == 'a',""); DLIB_TEST(test2[0] == 'a');
DLIB_CASSERT(test2[1] == 's',""); DLIB_TEST(test2[1] == 's');
DLIB_CASSERT(test2[2] == 'd',""); DLIB_TEST(test2[2] == 'd');
DLIB_CASSERT(test2[3] == 'f',""); DLIB_TEST(test2[3] == 'f');
swap(test,test2); swap(test,test2);
test.rotate_left(4); test.rotate_left(4);
DLIB_CASSERT(test[test.get_element_index(id)] == 'd',""); DLIB_TEST(test[test.get_element_index(id)] == 'd');
DLIB_CASSERT(test[0] == 'a',""); DLIB_TEST(test[0] == 'a');
DLIB_CASSERT(test[1] == 's',""); DLIB_TEST(test[1] == 's');
DLIB_CASSERT(test[2] == 'd',""); DLIB_TEST(test[2] == 'd');
DLIB_CASSERT(test[3] == 'f',""); DLIB_TEST(test[3] == 'f');
test.rotate_right(1); test.rotate_right(1);
DLIB_CASSERT(test[test.get_element_index(id)] == 'd',""); DLIB_TEST(test[test.get_element_index(id)] == 'd');
DLIB_CASSERT(test[0] == 's',""); DLIB_TEST(test[0] == 's');
DLIB_CASSERT(test[1] == 'd',""); DLIB_TEST(test[1] == 'd');
DLIB_CASSERT(test[2] == 'f',""); DLIB_TEST(test[2] == 'f');
DLIB_CASSERT(test[3] == 'a',""); DLIB_TEST(test[3] == 'a');
test.rotate_left(1); test.rotate_left(1);
DLIB_CASSERT(test[test.get_element_index(id)] == 'd',""); DLIB_TEST(test[test.get_element_index(id)] == 'd');
DLIB_CASSERT(test[0] == 'a',""); DLIB_TEST(test[0] == 'a');
DLIB_CASSERT(test[1] == 's',""); DLIB_TEST(test[1] == 's');
DLIB_CASSERT(test[2] == 'd',""); DLIB_TEST(test[2] == 'd');
DLIB_CASSERT(test[3] == 'f',""); DLIB_TEST(test[3] == 'f');
test.rotate_left(16); test.rotate_left(16);
DLIB_CASSERT(test[test.get_element_index(id)] == 'd',""); DLIB_TEST(test[test.get_element_index(id)] == 'd');
DLIB_CASSERT(test[0] == 'a',""); DLIB_TEST(test[0] == 'a');
DLIB_CASSERT(test[1] == 's',""); DLIB_TEST(test[1] == 's');
DLIB_CASSERT(test[2] == 'd',""); DLIB_TEST(test[2] == 'd');
DLIB_CASSERT(test[3] == 'f',""); DLIB_TEST(test[3] == 'f');
test.rotate_left(2); test.rotate_left(2);
DLIB_CASSERT(test[test.get_element_index(id)] == 'd',""); DLIB_TEST(test[test.get_element_index(id)] == 'd');
DLIB_CASSERT(test[0] == 'd',""); DLIB_TEST(test[0] == 'd');
DLIB_CASSERT(test[1] == 'f',""); DLIB_TEST(test[1] == 'f');
DLIB_CASSERT(test[2] == 'a',""); DLIB_TEST(test[2] == 'a');
DLIB_CASSERT(test[3] == 's',""); DLIB_TEST(test[3] == 's');
test.rotate_left(1); test.rotate_left(1);
DLIB_CASSERT(test[test.get_element_index(id)] == 'd',""); DLIB_TEST(test[test.get_element_index(id)] == 'd');
DLIB_CASSERT(test[0] == 's',""); DLIB_TEST(test[0] == 's');
DLIB_CASSERT(test[1] == 'd',""); DLIB_TEST(test[1] == 'd');
DLIB_CASSERT(test[2] == 'f',""); DLIB_TEST(test[2] == 'f');
DLIB_CASSERT(test[3] == 'a',""); DLIB_TEST(test[3] == 'a');
test.rotate_left(1); test.rotate_left(1);
DLIB_CASSERT(test[test.get_element_index(id)] == 'd',""); DLIB_TEST(test[test.get_element_index(id)] == 'd');
DLIB_CASSERT(test[0] == 'a',""); DLIB_TEST(test[0] == 'a');
DLIB_CASSERT(test[1] == 's',""); DLIB_TEST(test[1] == 's');
DLIB_CASSERT(test[2] == 'd',""); DLIB_TEST(test[2] == 'd');
DLIB_CASSERT(test[3] == 'f',""); DLIB_TEST(test[3] == 'f');
DLIB_CASSERT(test.size() == 4,""); DLIB_TEST(test.size() == 4);
test[0] = 'x'; test[0] = 'x';
DLIB_CASSERT(test[0] == 'x',""); DLIB_TEST(test[0] == 'x');
DLIB_CASSERT(test[1] == 's',""); DLIB_TEST(test[1] == 's');
DLIB_CASSERT(test[2] == 'd',""); DLIB_TEST(test[2] == 'd');
DLIB_CASSERT(test[3] == 'f',""); DLIB_TEST(test[3] == 'f');
test.rotate_left(1); test.rotate_left(1);
DLIB_CASSERT(test[0] == 'f',test[0]); DLIB_TEST_MSG(test[0] == 'f',test[0]);
DLIB_CASSERT(test[1] == 'x',""); DLIB_TEST(test[1] == 'x');
DLIB_CASSERT(test[2] == 's',""); DLIB_TEST(test[2] == 's');
DLIB_CASSERT(test[3] == 'd',""); DLIB_TEST(test[3] == 'd');
test[0] = 'x'; test[0] = 'x';
DLIB_CASSERT(test[0] == 'x',""); DLIB_TEST(test[0] == 'x');
DLIB_CASSERT(test[1] == 'x',""); DLIB_TEST(test[1] == 'x');
DLIB_CASSERT(test[2] == 's',""); DLIB_TEST(test[2] == 's');
DLIB_CASSERT(test[3] == 'd',""); DLIB_TEST(test[3] == 'd');
test.rotate_left(1); test.rotate_left(1);
DLIB_CASSERT(test[0] == 'd',""); DLIB_TEST(test[0] == 'd');
DLIB_CASSERT(test[1] == 'x',""); DLIB_TEST(test[1] == 'x');
DLIB_CASSERT(test[2] == 'x',""); DLIB_TEST(test[2] == 'x');
DLIB_CASSERT(test[3] == 's',""); DLIB_TEST(test[3] == 's');
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == true,""); DLIB_TEST(test.move_next() == true);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
test.clear(); test.clear();
test2.clear(); test2.clear();
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test2.move_next() == false,""); DLIB_TEST(test2.move_next() == false);
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
test.set_size(3); test.set_size(3);
DLIB_CASSERT(test.size() == 8,""); DLIB_TEST(test.size() == 8);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == true,""); DLIB_TEST(test.move_next() == true);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
test.reset(); test.reset();
DLIB_CASSERT(test.size() == 8,""); DLIB_TEST(test.size() == 8);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == true,""); DLIB_TEST(test.move_next() == true);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
test.rotate_right(1); test.rotate_right(1);
DLIB_CASSERT(test.size() == 8,""); DLIB_TEST(test.size() == 8);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == true,""); DLIB_TEST(test.move_next() == true);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
test.rotate_left(1); test.rotate_left(1);
DLIB_CASSERT(test.size() == 8,""); DLIB_TEST(test.size() == 8);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == true,""); DLIB_TEST(test.move_next() == true);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
test.reset(); test.reset();
...@@ -253,11 +253,11 @@ namespace ...@@ -253,11 +253,11 @@ namespace
unsigned long count = 0; unsigned long count = 0;
while (test.move_next()) while (test.move_next())
{ {
DLIB_CASSERT(test.element() == count,""); DLIB_TEST(test.element() == count);
++count; ++count;
} }
DLIB_CASSERT(count == test.size(),""); DLIB_TEST(count == test.size());
test2.clear(); test2.clear();
...@@ -270,14 +270,14 @@ namespace ...@@ -270,14 +270,14 @@ namespace
char ch; char ch;
sin >> ch; sin >> ch;
DLIB_CASSERT( !sin, ""); DLIB_TEST( !sin);
DLIB_CASSERT(test2.size() == test.size(),""); DLIB_TEST(test2.size() == test.size());
for (unsigned long i = 0; i < test.size(); ++i) for (unsigned long i = 0; i < test.size(); ++i)
{ {
DLIB_CASSERT(test[i] == test2[i], DLIB_TEST_MSG(test[i] == test2[i],
"\ni: " << i << "\ni: " << i <<
"\ntest[i]: " << test[i] << "\ntest[i]: " << test[i] <<
"\ntest2[i]: " << test2[i]); "\ntest2[i]: " << test2[i]);
...@@ -286,13 +286,13 @@ namespace ...@@ -286,13 +286,13 @@ namespace
count = 0; count = 0;
while (test.move_next() && test2.move_next()) while (test.move_next() && test2.move_next())
{ {
DLIB_CASSERT(test.element() == count,""); DLIB_TEST(test.element() == count);
DLIB_CASSERT(test2.element() == count,""); DLIB_TEST(test2.element() == count);
++count; ++count;
} }
DLIB_CASSERT(test2.size() == count,""); DLIB_TEST(test2.size() == count);
DLIB_CASSERT(test.size() == count,""); DLIB_TEST(test.size() == count);
test2.clear(); test2.clear();
......
...@@ -49,63 +49,63 @@ namespace ...@@ -49,63 +49,63 @@ namespace
deleter_called = 0; deleter_called = 0;
{ {
DLIB_CASSERT(counter == 0,counter); DLIB_TEST_MSG(counter == 0,counter);
scoped_ptr<base> p1(new derived); scoped_ptr<base> p1(new derived);
scoped_ptr<derived> p2(new derived); scoped_ptr<derived> p2(new derived);
scoped_ptr<derived> p3; scoped_ptr<derived> p3;
DLIB_CASSERT(counter == 2,counter); DLIB_TEST_MSG(counter == 2,counter);
DLIB_CASSERT(!p3,""); DLIB_TEST(!p3);
p1->num = 1; p1->num = 1;
p2->num = 2; p2->num = 2;
DLIB_CASSERT(p1->num == 1,""); DLIB_TEST(p1->num == 1);
DLIB_CASSERT(p2->num == 2,""); DLIB_TEST(p2->num == 2);
(*p1).num = 3; (*p1).num = 3;
(*p2).num = 4; (*p2).num = 4;
DLIB_CASSERT(p1->num == 3,""); DLIB_TEST(p1->num == 3);
DLIB_CASSERT(p2->num == 4,""); DLIB_TEST(p2->num == 4);
DLIB_CASSERT(counter == 2,counter); DLIB_TEST_MSG(counter == 2,counter);
DLIB_CASSERT(p1,""); DLIB_TEST(p1);
DLIB_CASSERT(p2,""); DLIB_TEST(p2);
DLIB_CASSERT(counter == 2,counter); DLIB_TEST_MSG(counter == 2,counter);
p1.reset(); p1.reset();
DLIB_CASSERT(counter == 1,counter); DLIB_TEST_MSG(counter == 1,counter);
DLIB_CASSERT(!p1,""); DLIB_TEST(!p1);
DLIB_CASSERT(p2,""); DLIB_TEST(p2);
p1.reset(new derived); p1.reset(new derived);
DLIB_CASSERT(counter == 2,counter); DLIB_TEST_MSG(counter == 2,counter);
DLIB_CASSERT(p1,""); DLIB_TEST(p1);
DLIB_CASSERT(counter == 2,counter); DLIB_TEST_MSG(counter == 2,counter);
p2.reset(); p2.reset();
DLIB_CASSERT(counter == 1,counter); DLIB_TEST_MSG(counter == 1,counter);
DLIB_CASSERT(!p2,""); DLIB_TEST(!p2);
derived* d = new derived; derived* d = new derived;
p2.reset(d); p2.reset(d);
DLIB_CASSERT(p2.get() == d,""); DLIB_TEST(p2.get() == d);
DLIB_CASSERT(counter == 2,counter); DLIB_TEST_MSG(counter == 2,counter);
DLIB_CASSERT(p2,""); DLIB_TEST(p2);
DLIB_CASSERT(!p3,""); DLIB_TEST(!p3);
p2->num = 9; p2->num = 9;
swap(p2,p3); swap(p2,p3);
DLIB_CASSERT(!p2,""); DLIB_TEST(!p2);
DLIB_CASSERT(p3,""); DLIB_TEST(p3);
DLIB_CASSERT(p3->num == 9,""); DLIB_TEST(p3->num == 9);
p2.swap(p3); p2.swap(p3);
DLIB_CASSERT(p2,""); DLIB_TEST(p2);
DLIB_CASSERT(!p3,""); DLIB_TEST(!p3);
DLIB_CASSERT(p2->num == 9,""); DLIB_TEST(p2->num == 9);
DLIB_CASSERT(counter == 2,counter); DLIB_TEST_MSG(counter == 2,counter);
} }
DLIB_CASSERT(counter == 0,counter); DLIB_TEST_MSG(counter == 0,counter);
{ {
base* realp1 = new derived; base* realp1 = new derived;
...@@ -114,119 +114,119 @@ namespace ...@@ -114,119 +114,119 @@ namespace
shared_ptr<derived> p2(realp2,&deleter); shared_ptr<derived> p2(realp2,&deleter);
shared_ptr<base> p3; shared_ptr<base> p3;
shared_ptr<derived> p4; shared_ptr<derived> p4;
DLIB_CASSERT(p4.get() == 0,""); DLIB_TEST(p4.get() == 0);
DLIB_CASSERT(p1,""); DLIB_TEST(p1);
DLIB_CASSERT(p2,""); DLIB_TEST(p2);
DLIB_CASSERT(!p3,""); DLIB_TEST(!p3);
DLIB_CASSERT(!p4,""); DLIB_TEST(!p4);
DLIB_CASSERT(p1.get() == realp1,""); DLIB_TEST(p1.get() == realp1);
DLIB_CASSERT(p2.get() == realp2,""); DLIB_TEST(p2.get() == realp2);
p1->num = 1; p1->num = 1;
p2->num = 2; p2->num = 2;
DLIB_CASSERT((*p1).num == 1,""); DLIB_TEST((*p1).num == 1);
DLIB_CASSERT((*p2).num == 2,""); DLIB_TEST((*p2).num == 2);
p1.swap(p3); p1.swap(p3);
DLIB_CASSERT(!p1,""); DLIB_TEST(!p1);
DLIB_CASSERT(p3,""); DLIB_TEST(p3);
DLIB_CASSERT((*p3).num == 1,""); DLIB_TEST((*p3).num == 1);
DLIB_CASSERT(p3->num == 1,""); DLIB_TEST(p3->num == 1);
swap(p1,p3); swap(p1,p3);
DLIB_CASSERT(p1,""); DLIB_TEST(p1);
DLIB_CASSERT(!p3,""); DLIB_TEST(!p3);
DLIB_CASSERT((*p1).num == 1,""); DLIB_TEST((*p1).num == 1);
DLIB_CASSERT(p1->num == 1,""); DLIB_TEST(p1->num == 1);
DLIB_CASSERT(counter == 2,counter); DLIB_TEST_MSG(counter == 2,counter);
DLIB_CASSERT(p1.unique(),""); DLIB_TEST(p1.unique());
DLIB_CASSERT(p2.unique(),""); DLIB_TEST(p2.unique());
DLIB_CASSERT(!p3.unique(),""); DLIB_TEST(!p3.unique());
DLIB_CASSERT(!p4.unique(),""); DLIB_TEST(!p4.unique());
DLIB_CASSERT(p1.use_count() == 1,""); DLIB_TEST(p1.use_count() == 1);
DLIB_CASSERT(p2.use_count() == 1,""); DLIB_TEST(p2.use_count() == 1);
DLIB_CASSERT(p3.use_count() == 0,""); DLIB_TEST(p3.use_count() == 0);
DLIB_CASSERT(p4.use_count() == 0,""); DLIB_TEST(p4.use_count() == 0);
shared_ptr<base> p11(p1); shared_ptr<base> p11(p1);
DLIB_CASSERT(!p1.unique(),""); DLIB_TEST(!p1.unique());
DLIB_CASSERT(p2.unique(),""); DLIB_TEST(p2.unique());
DLIB_CASSERT(!p3.unique(),""); DLIB_TEST(!p3.unique());
DLIB_CASSERT(!p4.unique(),""); DLIB_TEST(!p4.unique());
DLIB_CASSERT(p1.use_count() == 2,""); DLIB_TEST(p1.use_count() == 2);
DLIB_CASSERT(p2.use_count() == 1,""); DLIB_TEST(p2.use_count() == 1);
DLIB_CASSERT(p3.use_count() == 0,""); DLIB_TEST(p3.use_count() == 0);
DLIB_CASSERT(p4.use_count() == 0,""); DLIB_TEST(p4.use_count() == 0);
shared_ptr<base> p22(p2); shared_ptr<base> p22(p2);
DLIB_CASSERT(!p1.unique(),""); DLIB_TEST(!p1.unique());
DLIB_CASSERT(!p2.unique(),""); DLIB_TEST(!p2.unique());
DLIB_CASSERT(!p3.unique(),""); DLIB_TEST(!p3.unique());
DLIB_CASSERT(!p4.unique(),""); DLIB_TEST(!p4.unique());
DLIB_CASSERT(p1.use_count() == 2,""); DLIB_TEST(p1.use_count() == 2);
DLIB_CASSERT(p2.use_count() == 2,""); DLIB_TEST(p2.use_count() == 2);
DLIB_CASSERT(p3.use_count() == 0,""); DLIB_TEST(p3.use_count() == 0);
DLIB_CASSERT(p4.use_count() == 0,""); DLIB_TEST(p4.use_count() == 0);
DLIB_CASSERT(p11.get() == realp1,""); DLIB_TEST(p11.get() == realp1);
DLIB_CASSERT(p11 == p1,""); DLIB_TEST(p11 == p1);
DLIB_CASSERT(p22 == p2,""); DLIB_TEST(p22 == p2);
DLIB_CASSERT(p3 == p4,""); DLIB_TEST(p3 == p4);
DLIB_CASSERT(p11 != p22,""); DLIB_TEST(p11 != p22);
DLIB_CASSERT(p1 != p2,""); DLIB_TEST(p1 != p2);
DLIB_CASSERT(p3 != p1,""); DLIB_TEST(p3 != p1);
DLIB_CASSERT(p3 != p11,""); DLIB_TEST(p3 != p11);
DLIB_CASSERT(p3 != p2,""); DLIB_TEST(p3 != p2);
p1 = p1 = p1; p1 = p1 = p1;
DLIB_CASSERT(p1.use_count() == 2,""); DLIB_TEST(p1.use_count() == 2);
DLIB_CASSERT(p1->num == 1,""); DLIB_TEST(p1->num == 1);
DLIB_CASSERT(p11.use_count() == 2,""); DLIB_TEST(p11.use_count() == 2);
p1.reset(); p1.reset();
DLIB_CASSERT(p1.get() == 0,""); DLIB_TEST(p1.get() == 0);
DLIB_CASSERT(p1.use_count() == 0,""); DLIB_TEST(p1.use_count() == 0);
DLIB_CASSERT(p1.unique() == false,""); DLIB_TEST(p1.unique() == false);
DLIB_CASSERT(p11.use_count() == 1,""); DLIB_TEST(p11.use_count() == 1);
p11 = p2; p11 = p2;
DLIB_CASSERT(p1.use_count() == 0,""); DLIB_TEST(p1.use_count() == 0);
DLIB_CASSERT(p1.unique() == false,""); DLIB_TEST(p1.unique() == false);
DLIB_CASSERT(p11.use_count() == 3,""); DLIB_TEST(p11.use_count() == 3);
DLIB_CASSERT(p11.unique() == false,""); DLIB_TEST(p11.unique() == false);
// now p11, p2, and p22 all reference the same thing and the rest are null // now p11, p2, and p22 all reference the same thing and the rest are null
DLIB_CASSERT((p11 < p2) == false,"") DLIB_TEST_MSG((p11 < p2) == false,"")
DLIB_CASSERT((p2 < p11) == false,"") DLIB_TEST_MSG((p2 < p11) == false,"")
DLIB_CASSERT(get_deleter<D>(p4) == 0,""); DLIB_TEST(get_deleter<D>(p4) == 0);
p4 = p2; p4 = p2;
DLIB_CASSERT(get_deleter<D>(p4) != 0,""); DLIB_TEST(get_deleter<D>(p4) != 0);
DLIB_CASSERT(get_deleter<D>(p4) == get_deleter<D>(p2),""); DLIB_TEST(get_deleter<D>(p4) == get_deleter<D>(p2));
DLIB_CASSERT(get_deleter<D>(p4) == get_deleter<D>(p11),""); DLIB_TEST(get_deleter<D>(p4) == get_deleter<D>(p11));
DLIB_CASSERT(get_deleter<int>(p4) == 0,""); DLIB_TEST(get_deleter<int>(p4) == 0);
realp1 = new derived; realp1 = new derived;
p1.reset(realp1, &deleter_base); p1.reset(realp1, &deleter_base);
DLIB_CASSERT(p1.get() == realp1,""); DLIB_TEST(p1.get() == realp1);
DLIB_CASSERT(p1.unique(),""); DLIB_TEST(p1.unique());
DLIB_CASSERT(p1.use_count() == 1,""); DLIB_TEST(p1.use_count() == 1);
DLIB_CASSERT(*get_deleter<Db>(p1) == &deleter_base,""); DLIB_TEST(*get_deleter<Db>(p1) == &deleter_base);
DLIB_CASSERT(p1 != p4,""); DLIB_TEST(p1 != p4);
p4 = dynamic_pointer_cast<derived>(p1); p4 = dynamic_pointer_cast<derived>(p1);
DLIB_CASSERT(!p1.unique(),""); DLIB_TEST(!p1.unique());
DLIB_CASSERT(p1.use_count() == 2,""); DLIB_TEST(p1.use_count() == 2);
DLIB_CASSERT(p1 == p4,""); DLIB_TEST(p1 == p4);
realp1 = new derived; realp1 = new derived;
p1.reset(realp1); p1.reset(realp1);
DLIB_CASSERT(p1.get() == realp1,""); DLIB_TEST(p1.get() == realp1);
DLIB_CASSERT(p1.unique(),""); DLIB_TEST(p1.unique());
DLIB_CASSERT(p1.use_count() == 1,""); DLIB_TEST(p1.use_count() == 1);
DLIB_CASSERT(get_deleter<D>(p1) == 0,""); DLIB_TEST(get_deleter<D>(p1) == 0);
auto_ptr<derived> ap1(new derived); auto_ptr<derived> ap1(new derived);
...@@ -234,24 +234,24 @@ namespace ...@@ -234,24 +234,24 @@ namespace
ap1->num = 35; ap1->num = 35;
ap2->num = 36; ap2->num = 36;
DLIB_CASSERT(ap1.get() != 0,""); DLIB_TEST(ap1.get() != 0);
DLIB_CASSERT(ap2.get() != 0,""); DLIB_TEST(ap2.get() != 0);
p1 = ap2; p1 = ap2;
p2 = ap1; p2 = ap1;
DLIB_CASSERT(ap1.get() == 0,""); DLIB_TEST(ap1.get() == 0);
DLIB_CASSERT(p1.unique(),""); DLIB_TEST(p1.unique());
DLIB_CASSERT(p1.use_count() == 1,""); DLIB_TEST(p1.use_count() == 1);
DLIB_CASSERT(ap2.get() == 0,""); DLIB_TEST(ap2.get() == 0);
DLIB_CASSERT(p2.unique(),""); DLIB_TEST(p2.unique());
DLIB_CASSERT(p2.use_count() == 1,""); DLIB_TEST(p2.use_count() == 1);
DLIB_CASSERT(p1->num == 36,""); DLIB_TEST(p1->num == 36);
DLIB_CASSERT(p2->num == 35,""); DLIB_TEST(p2->num == 35);
} }
DLIB_CASSERT(counter == 0,counter); DLIB_TEST_MSG(counter == 0,counter);
DLIB_CASSERT(deleter_called == 2,counter); DLIB_TEST_MSG(deleter_called == 2,counter);
weak_ptr<base> wp4; weak_ptr<base> wp4;
{ {
...@@ -267,88 +267,88 @@ namespace ...@@ -267,88 +267,88 @@ namespace
weak_ptr<base> wp2c(p1); weak_ptr<base> wp2c(p1);
weak_ptr<base> wp3c(p2); weak_ptr<base> wp3c(p2);
DLIB_CASSERT(wp1c.use_count() == 1,""); DLIB_TEST(wp1c.use_count() == 1);
DLIB_CASSERT(wp1c.lock() == p1,""); DLIB_TEST(wp1c.lock() == p1);
DLIB_CASSERT(wp1c.expired() == false,""); DLIB_TEST(wp1c.expired() == false);
DLIB_CASSERT(wp2c.use_count() == 1,""); DLIB_TEST(wp2c.use_count() == 1);
DLIB_CASSERT(wp2c.lock() == p1,""); DLIB_TEST(wp2c.lock() == p1);
DLIB_CASSERT(wp2c.expired() == false,""); DLIB_TEST(wp2c.expired() == false);
DLIB_CASSERT(wp3c.use_count() == 0,""); DLIB_TEST(wp3c.use_count() == 0);
DLIB_CASSERT(wp3c.lock() == shared_ptr<base>(),""); DLIB_TEST(wp3c.lock() == shared_ptr<base>());
DLIB_CASSERT(wp3c.expired() == true,""); DLIB_TEST(wp3c.expired() == true);
DLIB_CASSERT(wp2.use_count() == 0,""); DLIB_TEST(wp2.use_count() == 0);
DLIB_CASSERT(wp2.expired() == true,""); DLIB_TEST(wp2.expired() == true);
DLIB_CASSERT(wp2.lock().use_count() == 0,""); DLIB_TEST(wp2.lock().use_count() == 0);
DLIB_CASSERT(wp2.lock().unique() == false,""); DLIB_TEST(wp2.lock().unique() == false);
wp1 = p1; wp1 = p1;
wp2 = wp1; wp2 = wp1;
wp3 = p1; wp3 = p1;
DLIB_CASSERT(p1.use_count() == 1,""); DLIB_TEST(p1.use_count() == 1);
DLIB_CASSERT(p1.unique(),""); DLIB_TEST(p1.unique());
DLIB_CASSERT(wp1.use_count() == 1,""); DLIB_TEST(wp1.use_count() == 1);
DLIB_CASSERT(wp2.use_count() == 1,""); DLIB_TEST(wp2.use_count() == 1);
DLIB_CASSERT(wp3.use_count() == 1,""); DLIB_TEST(wp3.use_count() == 1);
DLIB_CASSERT(wp1.expired() == false,""); DLIB_TEST(wp1.expired() == false);
DLIB_CASSERT(wp2.expired() == false,""); DLIB_TEST(wp2.expired() == false);
DLIB_CASSERT(wp3.expired() == false,""); DLIB_TEST(wp3.expired() == false);
DLIB_CASSERT(wp1.lock() == p1,""); DLIB_TEST(wp1.lock() == p1);
DLIB_CASSERT(wp2.lock() == p1,""); DLIB_TEST(wp2.lock() == p1);
DLIB_CASSERT(wp3.lock() == p1,""); DLIB_TEST(wp3.lock() == p1);
wp3.reset(); wp3.reset();
DLIB_CASSERT(p1.use_count() == 1,""); DLIB_TEST(p1.use_count() == 1);
DLIB_CASSERT(p1.unique(),""); DLIB_TEST(p1.unique());
DLIB_CASSERT(wp1.use_count() == 1,""); DLIB_TEST(wp1.use_count() == 1);
DLIB_CASSERT(wp2.use_count() == 1,""); DLIB_TEST(wp2.use_count() == 1);
DLIB_CASSERT(wp3.use_count() == 0,""); DLIB_TEST(wp3.use_count() == 0);
DLIB_CASSERT(wp1.expired() == false,""); DLIB_TEST(wp1.expired() == false);
DLIB_CASSERT(wp2.expired() == false,""); DLIB_TEST(wp2.expired() == false);
DLIB_CASSERT(wp3.expired() == true,""); DLIB_TEST(wp3.expired() == true);
DLIB_CASSERT(wp1.lock() == p1,""); DLIB_TEST(wp1.lock() == p1);
DLIB_CASSERT(wp2.lock() == p1,""); DLIB_TEST(wp2.lock() == p1);
DLIB_CASSERT(wp3.lock() == shared_ptr<base>(),""); DLIB_TEST(wp3.lock() == shared_ptr<base>());
p1.reset(); p1.reset();
DLIB_CASSERT(p1.use_count() == 0,""); DLIB_TEST(p1.use_count() == 0);
DLIB_CASSERT(p1.unique() == false,""); DLIB_TEST(p1.unique() == false);
DLIB_CASSERT(wp1.use_count() == 0,""); DLIB_TEST(wp1.use_count() == 0);
DLIB_CASSERT(wp2.use_count() == 0,""); DLIB_TEST(wp2.use_count() == 0);
DLIB_CASSERT(wp3.use_count() == 0,""); DLIB_TEST(wp3.use_count() == 0);
DLIB_CASSERT(wp1.expired() == true,""); DLIB_TEST(wp1.expired() == true);
DLIB_CASSERT(wp2.expired() == true,""); DLIB_TEST(wp2.expired() == true);
DLIB_CASSERT(wp3.expired() == true,""); DLIB_TEST(wp3.expired() == true);
DLIB_CASSERT(wp1.lock() == shared_ptr<base>(),""); DLIB_TEST(wp1.lock() == shared_ptr<base>());
DLIB_CASSERT(wp2.lock() == shared_ptr<base>(),""); DLIB_TEST(wp2.lock() == shared_ptr<base>());
DLIB_CASSERT(wp3.lock() == shared_ptr<base>(),""); DLIB_TEST(wp3.lock() == shared_ptr<base>());
p1.reset(new derived); p1.reset(new derived);
DLIB_CASSERT(p1.use_count() == 1,""); DLIB_TEST(p1.use_count() == 1);
DLIB_CASSERT(p1.unique() == true,""); DLIB_TEST(p1.unique() == true);
DLIB_CASSERT(wp1.use_count() == 0,""); DLIB_TEST(wp1.use_count() == 0);
DLIB_CASSERT(wp2.use_count() == 0,""); DLIB_TEST(wp2.use_count() == 0);
DLIB_CASSERT(wp3.use_count() == 0,""); DLIB_TEST(wp3.use_count() == 0);
DLIB_CASSERT(wp1.expired() == true,""); DLIB_TEST(wp1.expired() == true);
DLIB_CASSERT(wp2.expired() == true,""); DLIB_TEST(wp2.expired() == true);
DLIB_CASSERT(wp3.expired() == true,""); DLIB_TEST(wp3.expired() == true);
DLIB_CASSERT(wp1.lock() == shared_ptr<base>(),""); DLIB_TEST(wp1.lock() == shared_ptr<base>());
DLIB_CASSERT(wp2.lock() == shared_ptr<base>(),""); DLIB_TEST(wp2.lock() == shared_ptr<base>());
DLIB_CASSERT(wp3.lock() == shared_ptr<base>(),""); DLIB_TEST(wp3.lock() == shared_ptr<base>());
DLIB_CASSERT(wp4.expired() == true,""); DLIB_TEST(wp4.expired() == true);
DLIB_CASSERT(wp4.lock() == shared_ptr<base>(),""); DLIB_TEST(wp4.lock() == shared_ptr<base>());
wp4 = p1; wp4 = p1;
p3 = p1; p3 = p1;
DLIB_CASSERT(wp4.expired() == false,""); DLIB_TEST(wp4.expired() == false);
DLIB_CASSERT(wp4.lock() == p3,""); DLIB_TEST(wp4.lock() == p3);
bool ok = false; bool ok = false;
...@@ -358,14 +358,14 @@ namespace ...@@ -358,14 +358,14 @@ namespace
{ {
ok = true; ok = true;
} }
DLIB_CASSERT(ok,""); DLIB_TEST(ok);
} }
DLIB_CASSERT(wp4.expired() == true,""); DLIB_TEST(wp4.expired() == true);
DLIB_CASSERT(wp4.lock() == shared_ptr<base>(),""); DLIB_TEST(wp4.lock() == shared_ptr<base>());
DLIB_CASSERT(counter == 0,counter); DLIB_TEST_MSG(counter == 0,counter);
DLIB_CASSERT(deleter_called == 3,counter); DLIB_TEST_MSG(deleter_called == 3,counter);
} }
......
...@@ -218,8 +218,8 @@ namespace { ...@@ -218,8 +218,8 @@ namespace {
srv.clear(); srv.clear();
dlog << LTRACE << "ending successful test"; dlog << LTRACE << "ending successful test";
DLIB_CASSERT( !srv.error_occurred,""); DLIB_TEST( !srv.error_occurred);
DLIB_CASSERT( srv.got_connections,""); DLIB_TEST( srv.got_connections);
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -132,14 +132,14 @@ namespace ...@@ -132,14 +132,14 @@ namespace
listener* list; listener* list;
if (create_listener(list,0)) if (create_listener(list,0))
{ {
DLIB_CASSERT(false, "Unable to create a listener"); DLIB_TEST_MSG(false, "Unable to create a listener");
} }
create_new_thread(&thread_proc_struct<ssb>::thread_proc,list); create_new_thread(&thread_proc_struct<ssb>::thread_proc,list);
if (create_connection(con,list->get_listening_port(),"127.0.0.1")) if (create_connection(con,list->get_listening_port(),"127.0.0.1"))
{ {
DLIB_CASSERT(false, "Unable to create a connection"); DLIB_TEST_MSG(false, "Unable to create a connection");
} }
// make sure con gets deleted // make sure con gets deleted
...@@ -154,57 +154,57 @@ namespace ...@@ -154,57 +154,57 @@ namespace
{ {
in >> ch; in >> ch;
char c = i; char c = i;
DLIB_CASSERT(ch == c,"ch: " << (int)ch << " c: " << (int)c); DLIB_TEST_MSG(ch == c,"ch: " << (int)ch << " c: " << (int)c);
} }
in.get(); in.get();
DLIB_CASSERT(in.peek() == 'A', "*" << in.peek() << "*"); DLIB_TEST_MSG(in.peek() == 'A', "*" << in.peek() << "*");
in.get(); in.get();
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {
in.read(&ch,1); in.read(&ch,1);
char c = i; char c = i;
DLIB_CASSERT(ch == c,"ch: " << (int)ch << " c: " << (int)c ); DLIB_TEST_MSG(ch == c,"ch: " << (int)ch << " c: " << (int)c );
} }
for (int i = -100; i < 25600; ++i) for (int i = -100; i < 25600; ++i)
{ {
int n = 0; int n = 0;
in >> n; in >> n;
DLIB_CASSERT(n == i,"n: " << n << " i:" << i); DLIB_TEST_MSG(n == i,"n: " << n << " i:" << i);
} }
in.get(); in.get();
DLIB_CASSERT(in.peek() == 'A', "*" << in.peek() << "*"); DLIB_TEST_MSG(in.peek() == 'A', "*" << in.peek() << "*");
in.get(); in.get();
for (int i = -100; i < 25600; ++i) for (int i = -100; i < 25600; ++i)
{ {
int n; int n;
in.read((char*)&n,sizeof(n)); in.read((char*)&n,sizeof(n));
DLIB_CASSERT(n == i,"n: " << n << " i:" << i); DLIB_TEST_MSG(n == i,"n: " << n << " i:" << i);
} }
in.read(bigbuf,1000000); in.read(bigbuf,1000000);
for (int i = 0; i < 1000000; ++i) for (int i = 0; i < 1000000; ++i)
{ {
DLIB_CASSERT(bigbuf[i] == (char)(i&0xFF),""); DLIB_TEST(bigbuf[i] == (char)(i&0xFF));
} }
DLIB_CASSERT(in.get() == 'd',""); DLIB_TEST(in.get() == 'd');
DLIB_CASSERT(in.get() == 'a',""); DLIB_TEST(in.get() == 'a');
DLIB_CASSERT(in.get() == 'v',""); DLIB_TEST(in.get() == 'v');
DLIB_CASSERT(in.get() == 'i',""); DLIB_TEST(in.get() == 'i');
DLIB_CASSERT(in.peek() == 's',""); DLIB_TEST(in.peek() == 's');
DLIB_CASSERT(in.get() == 's',""); DLIB_TEST(in.get() == 's');
in.putback('s'); in.putback('s');
DLIB_CASSERT(in.peek() == 's',""); DLIB_TEST(in.peek() == 's');
DLIB_CASSERT(in.get() == 's',""); DLIB_TEST(in.get() == 's');
string tstring; string tstring;
...@@ -214,9 +214,9 @@ namespace ...@@ -214,9 +214,9 @@ namespace
deserialize(tint,in); deserialize(tint,in);
deserialize(tuint,in); deserialize(tuint,in);
DLIB_CASSERT(tstring == "this is a test",""); DLIB_TEST(tstring == "this is a test");
DLIB_CASSERT(tint == -853,""); DLIB_TEST(tint == -853);
DLIB_CASSERT(tuint == 89,""); DLIB_TEST(tuint == 89);
......
...@@ -42,43 +42,43 @@ namespace ...@@ -42,43 +42,43 @@ namespace
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start(),""); DLIB_TEST(a1.at_start());
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
swap(a1,a2); swap(a1,a2);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.at_start() == false,""); DLIB_TEST(a2.at_start() == false);
DLIB_CASSERT(a2.move_next() == false,""); DLIB_TEST(a2.move_next() == false);
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a2.at_start() == false,""); DLIB_TEST(a2.at_start() == false);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start(),""); DLIB_TEST(a1.at_start());
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
a1.reset(); a1.reset();
a2.reset(); a2.reset();
...@@ -86,85 +86,85 @@ namespace ...@@ -86,85 +86,85 @@ namespace
for (unsigned long k = 0; k < 4; ++k) for (unsigned long k = 0; k < 4; ++k)
{ {
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start(),""); DLIB_TEST(a1.at_start());
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
swap(a1,a2); swap(a1,a2);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.at_start() == false,""); DLIB_TEST(a2.at_start() == false);
DLIB_CASSERT(a2.move_next() == false,""); DLIB_TEST(a2.move_next() == false);
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a2.at_start() == false,""); DLIB_TEST(a2.at_start() == false);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start(),""); DLIB_TEST(a1.at_start());
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
a1.clear(); a1.clear();
a2.clear(); a2.clear();
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start(),""); DLIB_TEST(a1.at_start());
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
swap(a1,a2); swap(a1,a2);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.at_start() == false,""); DLIB_TEST(a2.at_start() == false);
DLIB_CASSERT(a2.move_next() == false,""); DLIB_TEST(a2.move_next() == false);
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a2.at_start() == false,""); DLIB_TEST(a2.at_start() == false);
DLIB_CASSERT(a2.size() == 0,""); DLIB_TEST(a2.size() == 0);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start(),""); DLIB_TEST(a1.at_start());
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.move_next() == false,""); DLIB_TEST(a1.move_next() == false);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
a1.clear(); a1.clear();
a2.clear(); a2.clear();
...@@ -176,53 +176,53 @@ namespace ...@@ -176,53 +176,53 @@ namespace
a1.push(a); a1.push(a);
} }
DLIB_CASSERT(a1.size() == 100,""); DLIB_TEST(a1.size() == 100);
int count = 99; int count = 99;
while (a1.move_next()) while (a1.move_next())
{ {
DLIB_CASSERT(a1.element() == count,a1.element() << " : " << count); DLIB_TEST_MSG(a1.element() == count,a1.element() << " : " << count);
--count; --count;
} }
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.at_start() == false,""); DLIB_TEST(a1.at_start() == false);
a1.swap(a2); a1.swap(a2);
count = 99; count = 99;
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.at_start() == false,""); DLIB_TEST(a2.at_start() == false);
DLIB_CASSERT(a1.current_element_valid() == false,""); DLIB_TEST(a1.current_element_valid() == false);
DLIB_CASSERT(a1.at_start() == true,""); DLIB_TEST(a1.at_start() == true);
DLIB_CASSERT(a1.size() == 0,""); DLIB_TEST(a1.size() == 0);
DLIB_CASSERT(a2.size() == 100,""); DLIB_TEST(a2.size() == 100);
DLIB_CASSERT(a2.current() == 99,""); DLIB_TEST(a2.current() == 99);
a2.reset(); a2.reset();
while (a2.move_next()) while (a2.move_next())
{ {
DLIB_CASSERT(a2.element() == count--,""); DLIB_TEST(a2.element() == count--);
} }
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.at_start() == false,""); DLIB_TEST(a2.at_start() == false);
int b = 4; int b = 4;
a2.push(b); a2.push(b);
DLIB_CASSERT(a2.current_element_valid() == false,""); DLIB_TEST(a2.current_element_valid() == false);
DLIB_CASSERT(a2.at_start() == true,""); DLIB_TEST(a2.at_start() == true);
DLIB_CASSERT(a2.current() == 4,""); DLIB_TEST(a2.current() == 4);
int c = 0; int c = 0;
a2.pop(c); a2.pop(c);
DLIB_CASSERT(c == 4,""); DLIB_TEST(c == 4);
// serialize the state of a2, then clear a2, then // serialize the state of a2, then clear a2, then
// load the state back into a2. // load the state back into a2.
ostringstream sout; ostringstream sout;
serialize(a2,sout); serialize(a2,sout);
DLIB_CASSERT(a2.at_start() == true,""); DLIB_TEST(a2.at_start() == true);
istringstream sin(sout.str()); istringstream sin(sout.str());
a2.clear(); a2.clear();
deserialize(a2,sin); deserialize(a2,sin);
...@@ -232,10 +232,10 @@ namespace ...@@ -232,10 +232,10 @@ namespace
while (a2.size()) while (a2.size())
{ {
int a = 0; int a = 0;
DLIB_CASSERT(a2.current() == count,""); DLIB_TEST(a2.current() == count);
DLIB_CASSERT(const_cast<const stack&>(a2).current() == count,""); DLIB_TEST(const_cast<const stack&>(a2).current() == count);
a2.pop(a); a2.pop(a);
DLIB_CASSERT(a == count--,""); DLIB_TEST(a == count--);
} }
...@@ -256,14 +256,14 @@ namespace ...@@ -256,14 +256,14 @@ namespace
int a = 3; int a = 3;
a1.push(a); a1.push(a);
} }
DLIB_CASSERT(go.size() == 100,""); DLIB_TEST(go.size() == 100);
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)
{ {
int a = 9; int a = 9;
go.remove_any(a); go.remove_any(a);
DLIB_CASSERT(a == 3,""); DLIB_TEST(a == 3);
} }
DLIB_CASSERT(go.size() == 0,""); DLIB_TEST(go.size() == 0);
} }
} }
......
...@@ -61,47 +61,47 @@ namespace ...@@ -61,47 +61,47 @@ namespace
map test; map test;
map test2; map test2;
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.at_start(),""); DLIB_TEST(test.at_start());
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == false,""); DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test[1] == 0,""); DLIB_TEST(test[1] == 0);
DLIB_CASSERT(test[2] == 0,""); DLIB_TEST(test[2] == 0);
DLIB_CASSERT(test[3] == 0,""); DLIB_TEST(test[3] == 0);
DLIB_CASSERT(test[0] == 0,""); DLIB_TEST(test[0] == 0);
test.load(treeb); test.load(treeb);
DLIB_CASSERT(test.at_start(),""); DLIB_TEST(test.at_start());
DLIB_CASSERT(test[1] != 0,""); DLIB_TEST(test[1] != 0);
DLIB_CASSERT(test[2] == 0,""); DLIB_TEST(test[2] == 0);
DLIB_CASSERT(test[3] == 0,""); DLIB_TEST(test[3] == 0);
DLIB_CASSERT(test[0] == 0,""); DLIB_TEST(test[0] == 0);
test2.clear(); test2.clear();
swap(test2,test); swap(test2,test);
DLIB_CASSERT(test2[1] != 0,""); DLIB_TEST(test2[1] != 0);
DLIB_CASSERT(test2[2] == 0,""); DLIB_TEST(test2[2] == 0);
DLIB_CASSERT(test2[3] == 0,""); DLIB_TEST(test2[3] == 0);
DLIB_CASSERT(test2[0] == 0,""); DLIB_TEST(test2[0] == 0);
DLIB_CASSERT(test[1] == 0,""); DLIB_TEST(test[1] == 0);
DLIB_CASSERT(test[2] == 0,""); DLIB_TEST(test[2] == 0);
DLIB_CASSERT(test[3] == 0,""); DLIB_TEST(test[3] == 0);
DLIB_CASSERT(test[0] == 0,""); DLIB_TEST(test[0] == 0);
DLIB_CASSERT(treeb.size() == 0,""); DLIB_TEST(treeb.size() == 0);
treeb.clear(); treeb.clear();
} }
...@@ -145,34 +145,34 @@ namespace ...@@ -145,34 +145,34 @@ namespace
map e; map e;
e.load(table_4); e.load(table_4);
DLIB_CASSERT(e.size() == 0,""); DLIB_TEST(e.size() == 0);
DLIB_CASSERT(e.at_start() == true,""); DLIB_TEST(e.at_start() == true);
DLIB_CASSERT(e.current_element_valid() == false,""); DLIB_TEST(e.current_element_valid() == false);
DLIB_CASSERT(e.move_next() == false,""); DLIB_TEST(e.move_next() == false);
DLIB_CASSERT(e.at_start() == false,""); DLIB_TEST(e.at_start() == false);
DLIB_CASSERT(e.current_element_valid() == false,""); DLIB_TEST(e.current_element_valid() == false);
DLIB_CASSERT(m_4.size() == table_4b.size(),""); DLIB_TEST(m_4.size() == table_4b.size());
DLIB_CASSERT(m_8.size() == table_8b.size(),""); DLIB_TEST(m_8.size() == table_8b.size());
DLIB_CASSERT(m_t.size() == treeb.size(),""); DLIB_TEST(m_t.size() == treeb.size());
DLIB_CASSERT(m_4.at_start() == true,""); DLIB_TEST(m_4.at_start() == true);
DLIB_CASSERT(m_8.at_start() == true,""); DLIB_TEST(m_8.at_start() == true);
DLIB_CASSERT(m_t.at_start() == true,""); DLIB_TEST(m_t.at_start() == true);
DLIB_CASSERT(m_4.current_element_valid() == false,""); DLIB_TEST(m_4.current_element_valid() == false);
DLIB_CASSERT(m_8.current_element_valid() == false,""); DLIB_TEST(m_8.current_element_valid() == false);
DLIB_CASSERT(m_t.current_element_valid() == false,""); DLIB_TEST(m_t.current_element_valid() == false);
DLIB_CASSERT(m_4.move_next() == true,""); DLIB_TEST(m_4.move_next() == true);
DLIB_CASSERT(m_4.at_start() == false,""); DLIB_TEST(m_4.at_start() == false);
DLIB_CASSERT(m_4.current_element_valid() == true,""); DLIB_TEST(m_4.current_element_valid() == true);
DLIB_CASSERT(m_8.move_next() == true,""); DLIB_TEST(m_8.move_next() == true);
DLIB_CASSERT(m_8.at_start() == false,""); DLIB_TEST(m_8.at_start() == false);
DLIB_CASSERT(m_8.current_element_valid() == true,""); DLIB_TEST(m_8.current_element_valid() == true);
DLIB_CASSERT(m_t.move_next() == true,""); DLIB_TEST(m_t.move_next() == true);
DLIB_CASSERT(m_t.at_start() == false,""); DLIB_TEST(m_t.at_start() == false);
DLIB_CASSERT(m_t.current_element_valid() == true,""); DLIB_TEST(m_t.current_element_valid() == true);
m_4.reset(); m_4.reset();
m_8.reset(); m_8.reset();
...@@ -180,67 +180,67 @@ namespace ...@@ -180,67 +180,67 @@ namespace
while (m_4.move_next()) while (m_4.move_next())
{ {
DLIB_CASSERT( table_4b[m_4.element().key()] != 0,""); DLIB_TEST( table_4b[m_4.element().key()] != 0);
DLIB_CASSERT( *table_4b[m_4.element().key()] == m_4.element().value(),""); DLIB_TEST( *table_4b[m_4.element().key()] == m_4.element().value());
} }
// serialize the state of m_4, then clear m_4, then // serialize the state of m_4, then clear m_4, then
// load the state back into m_4. // load the state back into m_4.
ostringstream sout; ostringstream sout;
serialize(m_4,sout); serialize(m_4,sout);
DLIB_CASSERT(m_4.at_start() == true,""); DLIB_TEST(m_4.at_start() == true);
istringstream sin(sout.str()); istringstream sin(sout.str());
m_4.clear(); m_4.clear();
deserialize(m_4,sin); deserialize(m_4,sin);
DLIB_CASSERT(m_4.at_start() == true,""); DLIB_TEST(m_4.at_start() == true);
while (table_4b.move_next()) while (table_4b.move_next())
{ {
DLIB_CASSERT( m_4[table_4b.element().key()] != 0,""); DLIB_TEST( m_4[table_4b.element().key()] != 0);
DLIB_CASSERT( *m_4[table_4b.element().key()] == table_4b.element().value(),""); DLIB_TEST( *m_4[table_4b.element().key()] == table_4b.element().value());
} }
// serialize the state of m_8, then clear m_8, then // serialize the state of m_8, then clear m_8, then
// load the state back into m_8. // load the state back into m_8.
sout.str(""); sout.str("");
serialize(m_8,sout); serialize(m_8,sout);
DLIB_CASSERT(m_8.at_start() == true,""); DLIB_TEST(m_8.at_start() == true);
sin.str(sout.str()); sin.str(sout.str());
m_8.clear(); m_8.clear();
deserialize(m_8,sin); deserialize(m_8,sin);
DLIB_CASSERT(m_8.at_start() == true,""); DLIB_TEST(m_8.at_start() == true);
while (m_8.move_next()) while (m_8.move_next())
{ {
DLIB_CASSERT( table_8b[m_8.element().key()] != 0,""); DLIB_TEST( table_8b[m_8.element().key()] != 0);
DLIB_CASSERT( *table_8b[m_8.element().key()] == m_8.element().value(),""); DLIB_TEST( *table_8b[m_8.element().key()] == m_8.element().value());
} }
while (table_8b.move_next()) while (table_8b.move_next())
{ {
DLIB_CASSERT( m_8[table_8b.element().key()] != 0,""); DLIB_TEST( m_8[table_8b.element().key()] != 0);
DLIB_CASSERT( *m_8[table_8b.element().key()] == table_8b.element().value(),""); DLIB_TEST( *m_8[table_8b.element().key()] == table_8b.element().value());
} }
while (m_t.move_next()) while (m_t.move_next())
{ {
DLIB_CASSERT( treeb[m_t.element().key()] != 0,""); DLIB_TEST( treeb[m_t.element().key()] != 0);
DLIB_CASSERT( *treeb[m_t.element().key()] == m_t.element().value(),""); DLIB_TEST( *treeb[m_t.element().key()] == m_t.element().value());
} }
// make sure operator[] doesn't hang // make sure operator[] doesn't hang
for (int l = 1; l < 10000; ++l) for (int l = 1; l < 10000; ++l)
{ {
DLIB_CASSERT(m_t[l+0xFFF] == 0,""); DLIB_TEST(m_t[l+0xFFF] == 0);
} }
while (treeb.move_next()) while (treeb.move_next())
{ {
DLIB_CASSERT( m_t[treeb.element().key()] != 0,""); DLIB_TEST( m_t[treeb.element().key()] != 0);
DLIB_CASSERT( *m_t[treeb.element().key()] == treeb.element().value(),""); DLIB_TEST( *m_t[treeb.element().key()] == treeb.element().value());
} }
...@@ -252,24 +252,24 @@ namespace ...@@ -252,24 +252,24 @@ namespace
int last = 0; int last = 0;
while (m_4.move_next()) while (m_4.move_next())
{ {
DLIB_CASSERT(last <= m_4.element().key(),""); DLIB_TEST(last <= m_4.element().key());
DLIB_CASSERT(m_4.element().key() + 1 == m_4.element().value(),""); DLIB_TEST(m_4.element().key() + 1 == m_4.element().value());
last = m_4.element().key(); last = m_4.element().key();
} }
last = 0; last = 0;
while (m_8.move_next()) while (m_8.move_next())
{ {
DLIB_CASSERT(last <= m_8.element().key(),""); DLIB_TEST(last <= m_8.element().key());
DLIB_CASSERT(m_8.element().key() + 1 == m_8.element().value(),""); DLIB_TEST(m_8.element().key() + 1 == m_8.element().value());
last = m_8.element().key(); last = m_8.element().key();
} }
last = 0; last = 0;
while (m_t.move_next()) while (m_t.move_next())
{ {
DLIB_CASSERT(last <= m_t.element().key(),""); DLIB_TEST(last <= m_t.element().key());
DLIB_CASSERT(m_t.element().key() + 1 == m_t.element().value(),""); DLIB_TEST(m_t.element().key() + 1 == m_t.element().value());
last = m_t.element().key(); last = m_t.element().key();
} }
...@@ -284,14 +284,14 @@ namespace ...@@ -284,14 +284,14 @@ namespace
table_4b.reset(); table_4b.reset();
while (m_8.move_next()) while (m_8.move_next())
{ {
DLIB_CASSERT( table_4b[m_8.element().key()] != 0,""); DLIB_TEST( table_4b[m_8.element().key()] != 0);
DLIB_CASSERT( *table_4b[m_8.element().key()] == m_8.element().value(),""); DLIB_TEST( *table_4b[m_8.element().key()] == m_8.element().value());
} }
while (table_4b.move_next()) while (table_4b.move_next())
{ {
DLIB_CASSERT( m_8[table_4b.element().key()] != 0,""); DLIB_TEST( m_8[table_4b.element().key()] != 0);
DLIB_CASSERT( *m_8[table_4b.element().key()] == table_4b.element().value(),""); DLIB_TEST( *m_8[table_4b.element().key()] == table_4b.element().value());
} }
} }
......
...@@ -68,50 +68,50 @@ namespace ...@@ -68,50 +68,50 @@ namespace
set s; set s;
DLIB_CASSERT(s.size() == 0,""); DLIB_TEST(s.size() == 0);
DLIB_CASSERT(s.at_start(),""); DLIB_TEST(s.at_start());
DLIB_CASSERT(s.current_element_valid() == false,""); DLIB_TEST(s.current_element_valid() == false);
DLIB_CASSERT(s.move_next() == false,""); DLIB_TEST(s.move_next() == false);
DLIB_CASSERT(s.current_element_valid() == false,""); DLIB_TEST(s.current_element_valid() == false);
DLIB_CASSERT(s.at_start() == false,""); DLIB_TEST(s.at_start() == false);
s.load(q); s.load(q);
DLIB_CASSERT(s.at_start(),""); DLIB_TEST(s.at_start());
set se; set se;
se.load(q); se.load(q);
DLIB_CASSERT(se.size() == 0,""); DLIB_TEST(se.size() == 0);
DLIB_CASSERT(se.at_start() == true,""); DLIB_TEST(se.at_start() == true);
DLIB_CASSERT(se.current_element_valid() == false,""); DLIB_TEST(se.current_element_valid() == false);
DLIB_CASSERT(se.move_next() == false,""); DLIB_TEST(se.move_next() == false);
DLIB_CASSERT(se.at_start() == false,""); DLIB_TEST(se.at_start() == false);
DLIB_CASSERT(se.current_element_valid() == false,""); DLIB_TEST(se.current_element_valid() == false);
DLIB_CASSERT(s.size() == qb.size(),""); DLIB_TEST(s.size() == qb.size());
DLIB_CASSERT(s.at_start() == true,""); DLIB_TEST(s.at_start() == true);
DLIB_CASSERT(s.current_element_valid() == false,""); DLIB_TEST(s.current_element_valid() == false);
DLIB_CASSERT(s.move_next() == true,""); DLIB_TEST(s.move_next() == true);
DLIB_CASSERT(s.at_start() == false,""); DLIB_TEST(s.at_start() == false);
DLIB_CASSERT(s.current_element_valid() == true,""); DLIB_TEST(s.current_element_valid() == true);
s.reset(); s.reset();
se.reset(); se.reset();
swap(se,s); swap(se,s);
DLIB_CASSERT(s.size() == 0,""); DLIB_TEST(s.size() == 0);
DLIB_CASSERT(s.at_start() == true,""); DLIB_TEST(s.at_start() == true);
DLIB_CASSERT(s.current_element_valid() == false,""); DLIB_TEST(s.current_element_valid() == false);
DLIB_CASSERT(s.move_next() == false,""); DLIB_TEST(s.move_next() == false);
DLIB_CASSERT(s.at_start() == false,""); DLIB_TEST(s.at_start() == false);
DLIB_CASSERT(s.current_element_valid() == false,""); DLIB_TEST(s.current_element_valid() == false);
DLIB_CASSERT(se.size() == qb.size(),""); DLIB_TEST(se.size() == qb.size());
DLIB_CASSERT(se.at_start() == true,""); DLIB_TEST(se.at_start() == true);
DLIB_CASSERT(se.current_element_valid() == false,""); DLIB_TEST(se.current_element_valid() == false);
DLIB_CASSERT(se.move_next() == true,""); DLIB_TEST(se.move_next() == true);
DLIB_CASSERT(se.at_start() == false,""); DLIB_TEST(se.at_start() == false);
DLIB_CASSERT(se.current_element_valid() == true,""); DLIB_TEST(se.current_element_valid() == true);
s.reset(); s.reset();
se.reset(); se.reset();
...@@ -122,7 +122,7 @@ namespace ...@@ -122,7 +122,7 @@ namespace
int last = 0; int last = 0;
while (s.move_next()) while (s.move_next())
{ {
DLIB_CASSERT(last <= s.element(),""); DLIB_TEST(last <= s.element());
last = s.element(); last = s.element();
} }
...@@ -132,8 +132,8 @@ namespace ...@@ -132,8 +132,8 @@ namespace
{ {
int a; int a;
qb.dequeue(a); qb.dequeue(a);
DLIB_CASSERT(s.is_member(a),""); DLIB_TEST(s.is_member(a));
DLIB_CASSERT(!se.is_member(a),""); DLIB_TEST(!se.is_member(a));
// make sure is_member() doesn't hang // make sure is_member() doesn't hang
for (int l = 0; l < 100; ++l) for (int l = 0; l < 100; ++l)
...@@ -149,30 +149,30 @@ namespace ...@@ -149,30 +149,30 @@ namespace
// load the state back into se. // load the state back into se.
ostringstream sout; ostringstream sout;
serialize(se,sout); serialize(se,sout);
DLIB_CASSERT(se.at_start() == true,""); DLIB_TEST(se.at_start() == true);
istringstream sin(sout.str()); istringstream sin(sout.str());
se.clear(); se.clear();
deserialize(se,sin); deserialize(se,sin);
DLIB_CASSERT(se.at_start() == true,""); DLIB_TEST(se.at_start() == true);
last = 0; last = 0;
while (se.move_next()) while (se.move_next())
{ {
DLIB_CASSERT(last <= se.element(),""); DLIB_TEST(last <= se.element());
last = se.element(); last = se.element();
} }
DLIB_CASSERT(s.size() == 0,""); DLIB_TEST(s.size() == 0);
DLIB_CASSERT(se.size() == qc.size(),""); DLIB_TEST(se.size() == qc.size());
while (qc.move_next()) while (qc.move_next())
{ {
int a; int a;
qc.dequeue(a); qc.dequeue(a);
DLIB_CASSERT(se.is_member(a),""); DLIB_TEST(se.is_member(a));
DLIB_CASSERT(!s.is_member(a),""); DLIB_TEST(!s.is_member(a));
} }
......
...@@ -35,110 +35,110 @@ namespace ...@@ -35,110 +35,110 @@ namespace
dlog << LTRACE << 1; dlog << LTRACE << 1;
DLIB_CASSERT(string_cast<int>("5") == 5,string_cast<int>("5")); DLIB_TEST_MSG(string_cast<int>("5") == 5,string_cast<int>("5"));
DLIB_CASSERT(string_cast<int>("0x5") == 5,string_cast<int>("0x5")); DLIB_TEST_MSG(string_cast<int>("0x5") == 5,string_cast<int>("0x5"));
DLIB_CASSERT(string_cast<int>("0xA") == 10,string_cast<int>("0xA")); DLIB_TEST_MSG(string_cast<int>("0xA") == 10,string_cast<int>("0xA"));
DLIB_CASSERT(string_cast<float>("0.5") == 0.5,""); DLIB_TEST(string_cast<float>("0.5") == 0.5);
DLIB_CASSERT(string_cast<std::string>("0.5 !") == "0.5 !",""); DLIB_TEST(string_cast<std::string>("0.5 !") == "0.5 !");
DLIB_CASSERT(string_cast<bool>("true") == true,""); DLIB_TEST(string_cast<bool>("true") == true);
DLIB_CASSERT(string_cast<bool>("false") == false,""); DLIB_TEST(string_cast<bool>("false") == false);
DLIB_CASSERT(string_cast<bool>("TRUE") == true,""); DLIB_TEST(string_cast<bool>("TRUE") == true);
DLIB_CASSERT(string_cast<bool>("FALSE") == false,""); DLIB_TEST(string_cast<bool>("FALSE") == false);
dlog << LTRACE << 2; dlog << LTRACE << 2;
DLIB_CASSERT(string_cast<int>(L"5") == 5,string_cast<int>("5")); DLIB_TEST_MSG(string_cast<int>(L"5") == 5,string_cast<int>("5"));
dlog << LTRACE << 2.1; dlog << LTRACE << 2.1;
DLIB_CASSERT(string_cast<int>(L"0x5") == 5,string_cast<int>("0x5")); DLIB_TEST_MSG(string_cast<int>(L"0x5") == 5,string_cast<int>("0x5"));
DLIB_CASSERT(string_cast<int>(L"0xA") == 10,string_cast<int>("0xA")); DLIB_TEST_MSG(string_cast<int>(L"0xA") == 10,string_cast<int>("0xA"));
DLIB_CASSERT(string_cast<float>(L"0.5") == 0.5,""); DLIB_TEST(string_cast<float>(L"0.5") == 0.5);
DLIB_CASSERT(string_cast<std::string>(L"0.5 !") == "0.5 !",""); DLIB_TEST(string_cast<std::string>(L"0.5 !") == "0.5 !");
DLIB_CASSERT(string_cast<bool>(L"true") == true,""); DLIB_TEST(string_cast<bool>(L"true") == true);
DLIB_CASSERT(string_cast<bool>(L"false") == false,""); DLIB_TEST(string_cast<bool>(L"false") == false);
DLIB_CASSERT(string_cast<bool>(L"TRUE") == true,""); DLIB_TEST(string_cast<bool>(L"TRUE") == true);
DLIB_CASSERT(string_cast<bool>(L"FALSE") == false,""); DLIB_TEST(string_cast<bool>(L"FALSE") == false);
dlog << LTRACE << 3; dlog << LTRACE << 3;
DLIB_CASSERT(cast_to_string(5) == "5",""); DLIB_TEST(cast_to_string(5) == "5");
DLIB_CASSERT(cast_to_string(5.5) == "5.5",""); DLIB_TEST(cast_to_string(5.5) == "5.5");
dlog << LTRACE << 4; dlog << LTRACE << 4;
DLIB_CASSERT(cast_to_wstring(5) == L"5",""); DLIB_TEST(cast_to_wstring(5) == L"5");
DLIB_CASSERT(cast_to_wstring(5.5) == L"5.5",""); DLIB_TEST(cast_to_wstring(5.5) == L"5.5");
dlog << LTRACE << 5; dlog << LTRACE << 5;
DLIB_CASSERT(toupper(a) == A,""); DLIB_TEST(toupper(a) == A);
DLIB_CASSERT(toupper(A) == A,""); DLIB_TEST(toupper(A) == A);
DLIB_CASSERT(tolower(a) == a,""); DLIB_TEST(tolower(a) == a);
DLIB_CASSERT(tolower(A) == a,""); DLIB_TEST(tolower(A) == a);
DLIB_CASSERT(trim(a) == "davis",""); DLIB_TEST(trim(a) == "davis");
DLIB_CASSERT(ltrim(a) == "davis ",""); DLIB_TEST(ltrim(a) == "davis ");
DLIB_CASSERT(rtrim(a) == " davis",""); DLIB_TEST(rtrim(a) == " davis");
DLIB_CASSERT(trim(string_cast<wstring>(a)) == L"davis",""); DLIB_TEST(trim(string_cast<wstring>(a)) == L"davis");
DLIB_CASSERT(ltrim(string_cast<wstring>(a)) == L"davis ",""); DLIB_TEST(ltrim(string_cast<wstring>(a)) == L"davis ");
DLIB_CASSERT(rtrim(string_cast<wstring>(a)) == L" davis",""); DLIB_TEST(rtrim(string_cast<wstring>(a)) == L" davis");
DLIB_CASSERT(trim(a, " ") == "davis",""); DLIB_TEST(trim(a, " ") == "davis");
DLIB_CASSERT(ltrim(a, " ") == "davis ",""); DLIB_TEST(ltrim(a, " ") == "davis ");
DLIB_CASSERT(rtrim(a, " ") == " davis",""); DLIB_TEST(rtrim(a, " ") == " davis");
DLIB_CASSERT(trim(empty) == "",""); DLIB_TEST(trim(empty) == "");
DLIB_CASSERT(ltrim(empty) == "",""); DLIB_TEST(ltrim(empty) == "");
DLIB_CASSERT(rtrim(empty) == "",""); DLIB_TEST(rtrim(empty) == "");
DLIB_CASSERT(trim(string_cast<wstring>(empty)) == L"",""); DLIB_TEST(trim(string_cast<wstring>(empty)) == L"");
DLIB_CASSERT(ltrim(string_cast<wstring>(empty)) == L"",""); DLIB_TEST(ltrim(string_cast<wstring>(empty)) == L"");
DLIB_CASSERT(rtrim(string_cast<wstring>(empty)) == L"",""); DLIB_TEST(rtrim(string_cast<wstring>(empty)) == L"");
DLIB_CASSERT(trim(empty, " ") == "",""); DLIB_TEST(trim(empty, " ") == "");
DLIB_CASSERT(ltrim(empty, " ") == "",""); DLIB_TEST(ltrim(empty, " ") == "");
DLIB_CASSERT(rtrim(empty, " ") == "",""); DLIB_TEST(rtrim(empty, " ") == "");
dlog << LTRACE << 6; dlog << LTRACE << 6;
DLIB_CASSERT( (lpad(wstring(L"davis"), 10) == L" davis"), ""); DLIB_TEST( (lpad(wstring(L"davis"), 10) == L" davis"));
DLIB_CASSERT( (rpad(wstring(L"davis"), 10) == L"davis "), ""); DLIB_TEST( (rpad(wstring(L"davis"), 10) == L"davis "));
DLIB_CASSERT( (pad(wstring(L"davis"), 10) == L" davis "), ""); DLIB_TEST( (pad(wstring(L"davis"), 10) == L" davis "));
DLIB_CASSERT( (lpad(string("davis"), -10) == "davis"), ""); DLIB_TEST( (lpad(string("davis"), -10) == "davis"));
DLIB_CASSERT( (rpad(string("davis"), -10) == "davis"), ""); DLIB_TEST( (rpad(string("davis"), -10) == "davis"));
DLIB_CASSERT( (pad(string("davis"), -10) == "davis"), ""); DLIB_TEST( (pad(string("davis"), -10) == "davis"));
DLIB_CASSERT( (lpad(string("davis"), 10) == " davis"), ""); DLIB_TEST( (lpad(string("davis"), 10) == " davis"));
DLIB_CASSERT( (rpad(string("davis"), 10) == "davis "), ""); DLIB_TEST( (rpad(string("davis"), 10) == "davis "));
DLIB_CASSERT( (pad(string("davis"), 10) == " davis "), ""); DLIB_TEST( (pad(string("davis"), 10) == " davis "));
DLIB_CASSERT( (lpad(string("davis"), 10, string("*")) == "*****davis"), ""); DLIB_TEST( (lpad(string("davis"), 10, string("*")) == "*****davis"));
DLIB_CASSERT( (rpad(string("davis"), 10, string("*")) == "davis*****"), ""); DLIB_TEST( (rpad(string("davis"), 10, string("*")) == "davis*****"));
DLIB_CASSERT( (pad(string("davis"), 10, string("*")) == "**davis***"), ""); DLIB_TEST( (pad(string("davis"), 10, string("*")) == "**davis***"));
DLIB_CASSERT( (lpad(string("davis"), 10, string("_-")) == "_-_-_davis"), ""); DLIB_TEST( (lpad(string("davis"), 10, string("_-")) == "_-_-_davis"));
DLIB_CASSERT( (rpad(string("davis"), 10, string("_-")) == "davis_-_-_"), ""); DLIB_TEST( (rpad(string("davis"), 10, string("_-")) == "davis_-_-_"));
DLIB_CASSERT( (pad(string("davis"), 10, string("_-")) == "_-davis_-_"), ""); DLIB_TEST( (pad(string("davis"), 10, string("_-")) == "_-davis_-_"));
DLIB_CASSERT( (lpad(string("davis"), 10, string("willy wanka")) == "willydavis"), ""); DLIB_TEST( (lpad(string("davis"), 10, string("willy wanka")) == "willydavis"));
DLIB_CASSERT( (rpad(string("davis"), 10, string("willy wanka")) == "daviswilly"), ""); DLIB_TEST( (rpad(string("davis"), 10, string("willy wanka")) == "daviswilly"));
DLIB_CASSERT( (pad(string("davis"), 10, string("willy wanka")) == "widaviswil"), ""); DLIB_TEST( (pad(string("davis"), 10, string("willy wanka")) == "widaviswil"));
DLIB_CASSERT( (lpad(string("davis"), 10, "*")) == "*****davis", ""); DLIB_TEST( (lpad(string("davis"), 10, "*")) == "*****davis");
DLIB_CASSERT( (rpad(string("davis"), 10, "*") == "davis*****"), ""); DLIB_TEST( (rpad(string("davis"), 10, "*") == "davis*****"));
DLIB_CASSERT( (pad(string("davis"), 10, "*") == "**davis***"), ""); DLIB_TEST( (pad(string("davis"), 10, "*") == "**davis***"));
DLIB_CASSERT( (lpad(string("davis"), 10, "_-") == "_-_-_davis"), ""); DLIB_TEST( (lpad(string("davis"), 10, "_-") == "_-_-_davis"));
DLIB_CASSERT( (rpad(string("davis"), 10, "_-") == "davis_-_-_"), ""); DLIB_TEST( (rpad(string("davis"), 10, "_-") == "davis_-_-_"));
DLIB_CASSERT( (pad(string("davis"), 10, "_-") == "_-davis_-_"), ""); DLIB_TEST( (pad(string("davis"), 10, "_-") == "_-davis_-_"));
DLIB_CASSERT( (lpad(string("davis"), 10, "willy wanka") == "willydavis"), ""); DLIB_TEST( (lpad(string("davis"), 10, "willy wanka") == "willydavis"));
DLIB_CASSERT( (rpad(string("davis"), 10, "willy wanka") == "daviswilly"), ""); DLIB_TEST( (rpad(string("davis"), 10, "willy wanka") == "daviswilly"));
DLIB_CASSERT( (pad(string("davis"), 10, "willy wanka") == "widaviswil"), ""); DLIB_TEST( (pad(string("davis"), 10, "willy wanka") == "widaviswil"));
dlog << LTRACE << 7; dlog << LTRACE << 7;
a = "file.txt"; a = "file.txt";
DLIB_CASSERT( (left_substr(a,string(".")) == "file"), ""); DLIB_TEST( (left_substr(a,string(".")) == "file"));
DLIB_CASSERT( (left_substr(a,".") == "file"), ""); DLIB_TEST( (left_substr(a,".") == "file"));
DLIB_CASSERT( (right_substr(a,string(".")) == "txt"), ""); DLIB_TEST( (right_substr(a,string(".")) == "txt"));
DLIB_CASSERT( (right_substr(a,".") == "txt"), ""); DLIB_TEST( (right_substr(a,".") == "txt"));
DLIB_CASSERT( (left_substr(a," ") == "file.txt"), ""); DLIB_TEST( (left_substr(a," ") == "file.txt"));
DLIB_CASSERT( (right_substr(a," ") == ""), ""); DLIB_TEST( (right_substr(a," ") == ""));
DLIB_CASSERT( (left_substr(a,"") == "file.txt"), ""); DLIB_TEST( (left_substr(a,"") == "file.txt"));
DLIB_CASSERT( (right_substr(a,"") == ""), ""); DLIB_TEST( (right_substr(a,"") == ""));
wstring ws = L"file.txt"; wstring ws = L"file.txt";
DLIB_CASSERT( (left_substr(ws,wstring(L".")) == L"file"), ""); DLIB_TEST( (left_substr(ws,wstring(L".")) == L"file"));
DLIB_CASSERT( (left_substr(ws,L".") == L"file"), L""); DLIB_TEST_MSG( (left_substr(ws,L".") == L"file"), L"");
DLIB_CASSERT( (right_substr(ws,wstring(L".")) == L"txt"), ""); DLIB_TEST( (right_substr(ws,wstring(L".")) == L"txt"));
DLIB_CASSERT( (right_substr(ws,L".") == L"txt"), L""); DLIB_TEST_MSG( (right_substr(ws,L".") == L"txt"), L"");
dlog << LTRACE << 8; dlog << LTRACE << 8;
...@@ -158,12 +158,12 @@ namespace ...@@ -158,12 +158,12 @@ namespace
c = 0; c = 0;
deserialize(w,sin); deserialize(w,sin);
deserialize(c,sin); deserialize(c,sin);
DLIB_CASSERT(w == 85,""); DLIB_TEST(w == 85);
DLIB_CASSERT(c == 4,""); DLIB_TEST(c == 4);
deserialize(w,sin); deserialize(w,sin);
deserialize(c,sin); deserialize(c,sin);
DLIB_CASSERT(w == static_cast<wchar_t>(-1),""); DLIB_TEST(w == static_cast<wchar_t>(-1));
DLIB_CASSERT(c == static_cast<char>(-1),""); DLIB_TEST(c == static_cast<char>(-1));
wstring str = L"test string"; wstring str = L"test string";
...@@ -173,7 +173,7 @@ namespace ...@@ -173,7 +173,7 @@ namespace
sin.str(sout.str()); sin.str(sout.str());
str = L"something else"; str = L"something else";
deserialize(str,sin); deserialize(str,sin);
DLIB_CASSERT(str == L"test string",""); DLIB_TEST(str == L"test string");
} }
} }
......
...@@ -132,9 +132,9 @@ namespace ...@@ -132,9 +132,9 @@ namespace
// all points are correctly identified. // all points are correctly identified.
for (unsigned long i = 0; i < samples.size()/3; ++i) for (unsigned long i = 0; i < samples.size()/3; ++i)
{ {
DLIB_CASSERT(test(samples[i]) == class1, " "); DLIB_TEST(test(samples[i]) == class1);
DLIB_CASSERT(test(samples[i+num]) == class2, ""); DLIB_TEST(test(samples[i+num]) == class2);
DLIB_CASSERT(test(samples[i+2*num]) == class3, ""); DLIB_TEST(test(samples[i+2*num]) == class3);
} }
dlog << LINFO << " end test_clutering()"; dlog << LINFO << " end test_clutering()";
...@@ -201,20 +201,20 @@ namespace ...@@ -201,20 +201,20 @@ namespace
// now we output the value of the sinc function for a few test points as well as the // now we output the value of the sinc function for a few test points as well as the
// value predicted by krls object. // value predicted by krls object.
m(0) = 2.5; dlog << LDEBUG << "krls: " << sinc(m(0)) << " " << test(m); DLIB_CASSERT(abs(sinc(m(0)) - test(m)) < 0.01,""); m(0) = 2.5; dlog << LDEBUG << "krls: " << sinc(m(0)) << " " << test(m); DLIB_TEST(abs(sinc(m(0)) - test(m)) < 0.01);
m(0) = 0.1; dlog << LDEBUG << "krls: " << sinc(m(0)) << " " << test(m); DLIB_CASSERT(abs(sinc(m(0)) - test(m)) < 0.01,""); m(0) = 0.1; dlog << LDEBUG << "krls: " << sinc(m(0)) << " " << test(m); DLIB_TEST(abs(sinc(m(0)) - test(m)) < 0.01);
m(0) = -4; dlog << LDEBUG << "krls: " << sinc(m(0)) << " " << test(m); DLIB_CASSERT(abs(sinc(m(0)) - test(m)) < 0.01,""); m(0) = -4; dlog << LDEBUG << "krls: " << sinc(m(0)) << " " << test(m); DLIB_TEST(abs(sinc(m(0)) - test(m)) < 0.01);
m(0) = 5.0; dlog << LDEBUG << "krls: " << sinc(m(0)) << " " << test(m); DLIB_CASSERT(abs(sinc(m(0)) - test(m)) < 0.01,""); m(0) = 5.0; dlog << LDEBUG << "krls: " << sinc(m(0)) << " " << test(m); DLIB_TEST(abs(sinc(m(0)) - test(m)) < 0.01);
m(0) = 2.5; dlog << LDEBUG << "rvm: " << sinc(m(0)) << " " << test2(m); DLIB_CASSERT(abs(sinc(m(0)) - test2(m)) < 0.01,""); m(0) = 2.5; dlog << LDEBUG << "rvm: " << sinc(m(0)) << " " << test2(m); DLIB_TEST(abs(sinc(m(0)) - test2(m)) < 0.01);
m(0) = 0.1; dlog << LDEBUG << "rvm: " << sinc(m(0)) << " " << test2(m); DLIB_CASSERT(abs(sinc(m(0)) - test2(m)) < 0.01,""); m(0) = 0.1; dlog << LDEBUG << "rvm: " << sinc(m(0)) << " " << test2(m); DLIB_TEST(abs(sinc(m(0)) - test2(m)) < 0.01);
m(0) = -4; dlog << LDEBUG << "rvm: " << sinc(m(0)) << " " << test2(m); DLIB_CASSERT(abs(sinc(m(0)) - test2(m)) < 0.01,""); m(0) = -4; dlog << LDEBUG << "rvm: " << sinc(m(0)) << " " << test2(m); DLIB_TEST(abs(sinc(m(0)) - test2(m)) < 0.01);
m(0) = 5.0; dlog << LDEBUG << "rvm: " << sinc(m(0)) << " " << test2(m); DLIB_CASSERT(abs(sinc(m(0)) - test2(m)) < 0.01,""); m(0) = 5.0; dlog << LDEBUG << "rvm: " << sinc(m(0)) << " " << test2(m); DLIB_TEST(abs(sinc(m(0)) - test2(m)) < 0.01);
m(0) = 2.5; dlog << LDEBUG << "rbf: " << sinc(m(0)) << " " << test3(m); DLIB_CASSERT(abs(sinc(m(0)) - test3(m)) < 0.01,""); m(0) = 2.5; dlog << LDEBUG << "rbf: " << sinc(m(0)) << " " << test3(m); DLIB_TEST(abs(sinc(m(0)) - test3(m)) < 0.01);
m(0) = 0.1; dlog << LDEBUG << "rbf: " << sinc(m(0)) << " " << test3(m); DLIB_CASSERT(abs(sinc(m(0)) - test3(m)) < 0.01,""); m(0) = 0.1; dlog << LDEBUG << "rbf: " << sinc(m(0)) << " " << test3(m); DLIB_TEST(abs(sinc(m(0)) - test3(m)) < 0.01);
m(0) = -4; dlog << LDEBUG << "rbf: " << sinc(m(0)) << " " << test3(m); DLIB_CASSERT(abs(sinc(m(0)) - test3(m)) < 0.01,""); m(0) = -4; dlog << LDEBUG << "rbf: " << sinc(m(0)) << " " << test3(m); DLIB_TEST(abs(sinc(m(0)) - test3(m)) < 0.01);
m(0) = 5.0; dlog << LDEBUG << "rbf: " << sinc(m(0)) << " " << test3(m); DLIB_CASSERT(abs(sinc(m(0)) - test3(m)) < 0.01,""); m(0) = 5.0; dlog << LDEBUG << "rbf: " << sinc(m(0)) << " " << test3(m); DLIB_TEST(abs(sinc(m(0)) - test3(m)) < 0.01);
dlog << LINFO << " end test_regression()"; dlog << LINFO << " end test_regression()";
} }
...@@ -264,13 +264,13 @@ namespace ...@@ -264,13 +264,13 @@ namespace
m(0) = -1.5; m(1) = sinc(m(0)); dlog << LDEBUG << " " << test(m); rs.add(test(m)); m(0) = -1.5; m(1) = sinc(m(0)); dlog << LDEBUG << " " << test(m); rs.add(test(m));
m(0) = -0.5; m(1) = sinc(m(0)); dlog << LDEBUG << " " << test(m); rs.add(test(m)); m(0) = -0.5; m(1) = sinc(m(0)); dlog << LDEBUG << " " << test(m); rs.add(test(m));
m(0) = -1.5; m(1) = sinc(m(0)); DLIB_CASSERT(rs.scale(test(m)) < 2, rs.scale(test(m))); m(0) = -1.5; m(1) = sinc(m(0)); DLIB_TEST_MSG(rs.scale(test(m)) < 2, rs.scale(test(m)));
m(0) = -1.5; m(1) = sinc(m(0)); DLIB_CASSERT(rs.scale(test(m)) < 2, rs.scale(test(m))); m(0) = -1.5; m(1) = sinc(m(0)); DLIB_TEST_MSG(rs.scale(test(m)) < 2, rs.scale(test(m)));
m(0) = -0; m(1) = sinc(m(0)); DLIB_CASSERT(rs.scale(test(m)) < 2, rs.scale(test(m))); m(0) = -0; m(1) = sinc(m(0)); DLIB_TEST_MSG(rs.scale(test(m)) < 2, rs.scale(test(m)));
m(0) = -0.5; m(1) = sinc(m(0)); DLIB_CASSERT(rs.scale(test(m)) < 2, rs.scale(test(m))); m(0) = -0.5; m(1) = sinc(m(0)); DLIB_TEST_MSG(rs.scale(test(m)) < 2, rs.scale(test(m)));
m(0) = -4.1; m(1) = sinc(m(0)); DLIB_CASSERT(rs.scale(test(m)) < 2, rs.scale(test(m))); m(0) = -4.1; m(1) = sinc(m(0)); DLIB_TEST_MSG(rs.scale(test(m)) < 2, rs.scale(test(m)));
m(0) = -1.5; m(1) = sinc(m(0)); DLIB_CASSERT(rs.scale(test(m)) < 2, rs.scale(test(m))); m(0) = -1.5; m(1) = sinc(m(0)); DLIB_TEST_MSG(rs.scale(test(m)) < 2, rs.scale(test(m)));
m(0) = -0.5; m(1) = sinc(m(0)); DLIB_CASSERT(rs.scale(test(m)) < 2, rs.scale(test(m))); m(0) = -0.5; m(1) = sinc(m(0)); DLIB_TEST_MSG(rs.scale(test(m)) < 2, rs.scale(test(m)));
dlog << LDEBUG; dlog << LDEBUG;
// Lets output the distance from the centroid to some points that are NOT from the sinc function. // Lets output the distance from the centroid to some points that are NOT from the sinc function.
...@@ -281,31 +281,31 @@ namespace ...@@ -281,31 +281,31 @@ namespace
dlog << LDEBUG << "Points that are NOT on the sinc function:\n"; dlog << LDEBUG << "Points that are NOT on the sinc function:\n";
m(0) = -1.5; m(1) = sinc(m(0))+4; m(0) = -1.5; m(1) = sinc(m(0))+4;
dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc."; dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc.";
DLIB_CASSERT(rs.scale(test(m)) > 6, rs.scale(test(m))); DLIB_TEST_MSG(rs.scale(test(m)) > 6, rs.scale(test(m)));
m(0) = -1.5; m(1) = sinc(m(0))+3; m(0) = -1.5; m(1) = sinc(m(0))+3;
dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc."; dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc.";
DLIB_CASSERT(rs.scale(test(m)) > 6, rs.scale(test(m))); DLIB_TEST_MSG(rs.scale(test(m)) > 6, rs.scale(test(m)));
m(0) = -0; m(1) = -sinc(m(0)); m(0) = -0; m(1) = -sinc(m(0));
dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc."; dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc.";
DLIB_CASSERT(rs.scale(test(m)) > 6, rs.scale(test(m))); DLIB_TEST_MSG(rs.scale(test(m)) > 6, rs.scale(test(m)));
m(0) = -0.5; m(1) = -sinc(m(0)); m(0) = -0.5; m(1) = -sinc(m(0));
dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc."; dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc.";
DLIB_CASSERT(rs.scale(test(m)) > 6, rs.scale(test(m))); DLIB_TEST_MSG(rs.scale(test(m)) > 6, rs.scale(test(m)));
m(0) = -4.1; m(1) = sinc(m(0))+2; m(0) = -4.1; m(1) = sinc(m(0))+2;
dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc."; dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc.";
DLIB_CASSERT(rs.scale(test(m)) > 6, rs.scale(test(m))); DLIB_TEST_MSG(rs.scale(test(m)) > 6, rs.scale(test(m)));
m(0) = -1.5; m(1) = sinc(m(0))+0.9; m(0) = -1.5; m(1) = sinc(m(0))+0.9;
dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc."; dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc.";
DLIB_CASSERT(rs.scale(test(m)) > 6, rs.scale(test(m))); DLIB_TEST_MSG(rs.scale(test(m)) > 6, rs.scale(test(m)));
m(0) = -0.5; m(1) = sinc(m(0))+1; m(0) = -0.5; m(1) = sinc(m(0))+1;
dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc."; dlog << LDEBUG << " " << test(m) << " is " << rs.scale(test(m)) << " standard deviations from sinc.";
DLIB_CASSERT(rs.scale(test(m)) > 6, rs.scale(test(m))); DLIB_TEST_MSG(rs.scale(test(m)) > 6, rs.scale(test(m)));
dlog << LINFO << " end test_anomaly_detection()"; dlog << LINFO << " end test_anomaly_detection()";
} }
...@@ -365,10 +365,10 @@ namespace ...@@ -365,10 +365,10 @@ namespace
dlog << LDEBUG << "rbf cv: " << rbf_cv; dlog << LDEBUG << "rbf cv: " << rbf_cv;
dlog << LDEBUG << "peg cv: " << peg_cv; dlog << LDEBUG << "peg cv: " << peg_cv;
DLIB_CASSERT(mean(rvm_cv) > 0.9, rvm_cv); DLIB_TEST_MSG(mean(rvm_cv) > 0.9, rvm_cv);
DLIB_CASSERT(mean(svm_cv) > 0.9, svm_cv); DLIB_TEST_MSG(mean(svm_cv) > 0.9, svm_cv);
DLIB_CASSERT(mean(rbf_cv) > 0.9, rbf_cv); DLIB_TEST_MSG(mean(rbf_cv) > 0.9, rbf_cv);
DLIB_CASSERT(mean(peg_cv) > 0.9, rbf_cv); DLIB_TEST_MSG(mean(peg_cv) > 0.9, rbf_cv);
const long num_sv = trainer.train(x,y).support_vectors.size(); const long num_sv = trainer.train(x,y).support_vectors.size();
print_spinner(); print_spinner();
...@@ -377,8 +377,8 @@ namespace ...@@ -377,8 +377,8 @@ namespace
dlog << LDEBUG << "num sv: " << num_sv; dlog << LDEBUG << "num sv: " << num_sv;
dlog << LDEBUG << "num rv: " << num_rv; dlog << LDEBUG << "num rv: " << num_rv;
DLIB_CASSERT(num_rv <= 17, ""); DLIB_TEST(num_rv <= 17);
DLIB_CASSERT(num_sv <= 45, num_sv); DLIB_TEST_MSG(num_sv <= 45, num_sv);
decision_function<kernel_type> df = reduced2(trainer, 19).train(x,y); decision_function<kernel_type> df = reduced2(trainer, 19).train(x,y);
print_spinner(); print_spinner();
...@@ -387,13 +387,13 @@ namespace ...@@ -387,13 +387,13 @@ namespace
print_spinner(); print_spinner();
dlog << LDEBUG << "svm reduced test error: " << svm_reduced_error; dlog << LDEBUG << "svm reduced test error: " << svm_reduced_error;
dlog << LDEBUG << "svm reduced num sv: " << df.support_vectors.size(); dlog << LDEBUG << "svm reduced num sv: " << df.support_vectors.size();
DLIB_CASSERT(mean(svm_reduced_error) > 0.9, ""); DLIB_TEST(mean(svm_reduced_error) > 0.9);
svm_cv = cross_validate_trainer(reduced(trainer,30), x,y, 4); svm_cv = cross_validate_trainer(reduced(trainer,30), x,y, 4);
dlog << LDEBUG << "svm reduced cv: " << svm_cv; dlog << LDEBUG << "svm reduced cv: " << svm_cv;
DLIB_CASSERT(mean(svm_cv) > 0.9, svm_cv); DLIB_TEST_MSG(mean(svm_cv) > 0.9, svm_cv);
DLIB_CASSERT(df.support_vectors.size() == 19,""); DLIB_TEST(df.support_vectors.size() == 19);
dlog << LINFO << " end test_binary_classification()"; dlog << LINFO << " end test_binary_classification()";
} }
......
...@@ -84,18 +84,18 @@ namespace ...@@ -84,18 +84,18 @@ namespace
res = 4; res = 4;
DLIB_CASSERT(a==a,""); DLIB_TEST(a==a);
DLIB_CASSERT(a!=b,""); DLIB_TEST(a!=b);
DLIB_CASSERT(a==1,""); DLIB_TEST(a==1);
tp.add_task(gset_to_zero, a); tp.add_task(gset_to_zero, a);
tp.add_task(gset_to_zero, b); tp.add_task(gset_to_zero, b);
tp.add_task(*this, &thread_pool_tester::set_to_zero, c); tp.add_task(*this, &thread_pool_tester::set_to_zero, c);
tp.add_task(gset_to_zero, res); tp.add_task(gset_to_zero, res);
DLIB_CASSERT(a == 0,""); DLIB_TEST(a == 0);
DLIB_CASSERT(b == 0,""); DLIB_TEST(b == 0);
DLIB_CASSERT(c == 0,""); DLIB_TEST(c == 0);
DLIB_CASSERT(res == 0,""); DLIB_TEST(res == 0);
tp.add_task(gincrement, a); tp.add_task(gincrement, a);
...@@ -103,10 +103,10 @@ namespace ...@@ -103,10 +103,10 @@ namespace
tp.add_task(*this, &thread_pool_tester::increment, c); tp.add_task(*this, &thread_pool_tester::increment, c);
tp.add_task(gincrement, res); tp.add_task(gincrement, res);
DLIB_CASSERT(a == 1,""); DLIB_TEST(a == 1);
DLIB_CASSERT(b == 1,""); DLIB_TEST(b == 1);
DLIB_CASSERT(c == 1,""); DLIB_TEST(c == 1);
DLIB_CASSERT(res == 1,""); DLIB_TEST(res == 1);
tp.add_task(&gincrement, a); tp.add_task(&gincrement, a);
tp.add_task(*this, &thread_pool_tester::increment, b); tp.add_task(*this, &thread_pool_tester::increment, b);
...@@ -117,124 +117,124 @@ namespace ...@@ -117,124 +117,124 @@ namespace
tp.add_task(*this, &thread_pool_tester::increment, c); tp.add_task(*this, &thread_pool_tester::increment, c);
tp.add_task(gincrement, res); tp.add_task(gincrement, res);
DLIB_CASSERT(a == 3,""); DLIB_TEST(a == 3);
DLIB_CASSERT(b == 3,""); DLIB_TEST(b == 3);
DLIB_CASSERT(c == 3,""); DLIB_TEST(c == 3);
DLIB_CASSERT(res == 3,""); DLIB_TEST(res == 3);
tp.add_task(*this, &thread_pool_tester::increment, c); tp.add_task(*this, &thread_pool_tester::increment, c);
tp.add_task(gincrement, res); tp.add_task(gincrement, res);
DLIB_CASSERT(c == 4,""); DLIB_TEST(c == 4);
DLIB_CASSERT(res == 4,""); DLIB_TEST(res == 4);
tp.add_task(gadd, a, b, res); tp.add_task(gadd, a, b, res);
DLIB_CASSERT(res == a+b,""); DLIB_TEST(res == a+b);
DLIB_CASSERT(res == 6,""); DLIB_TEST(res == 6);
a = 3; a = 3;
b = 4; b = 4;
res = 99; res = 99;
DLIB_CASSERT(res == 99,""); DLIB_TEST(res == 99);
tp.add_task(*this, &thread_pool_tester::add, a, b, res); tp.add_task(*this, &thread_pool_tester::add, a, b, res);
DLIB_CASSERT(res == a+b,""); DLIB_TEST(res == a+b);
DLIB_CASSERT(res == 7,""); DLIB_TEST(res == 7);
a = 1; a = 1;
b = 2; b = 2;
c = 3; c = 3;
res = 88; res = 88;
DLIB_CASSERT(res == 88,""); DLIB_TEST(res == 88);
DLIB_CASSERT(a == 1,""); DLIB_TEST(a == 1);
DLIB_CASSERT(b == 2,""); DLIB_TEST(b == 2);
DLIB_CASSERT(c == 3,""); DLIB_TEST(c == 3);
tp.add_task(gadd2, a, b, c, res); tp.add_task(gadd2, a, b, c, res);
DLIB_CASSERT(res == 6,""); DLIB_TEST(res == 6);
DLIB_CASSERT(a == 1,""); DLIB_TEST(a == 1);
DLIB_CASSERT(b == 2,""); DLIB_TEST(b == 2);
DLIB_CASSERT(c == 3,""); DLIB_TEST(c == 3);
a = 1; a = 1;
b = 2; b = 2;
c = 3; c = 3;
res = 88; res = 88;
DLIB_CASSERT(res == 88,""); DLIB_TEST(res == 88);
DLIB_CASSERT(a == 1,""); DLIB_TEST(a == 1);
DLIB_CASSERT(b == 2,""); DLIB_TEST(b == 2);
DLIB_CASSERT(c == 3,""); DLIB_TEST(c == 3);
tp.add_task(*this, &thread_pool_tester::add2, a, b, c, res); tp.add_task(*this, &thread_pool_tester::add2, a, b, c, res);
DLIB_CASSERT(res == 6,""); DLIB_TEST(res == 6);
DLIB_CASSERT(a == 1,""); DLIB_TEST(a == 1);
DLIB_CASSERT(b == 2,""); DLIB_TEST(b == 2);
DLIB_CASSERT(c == 3,""); DLIB_TEST(c == 3);
a = 1; a = 1;
b = 2; b = 2;
c = 3; c = 3;
res = 88; res = 88;
tp.add_task(gadd1, a, b); tp.add_task(gadd1, a, b);
DLIB_CASSERT(a == 1,""); DLIB_TEST(a == 1);
DLIB_CASSERT(b == 3,""); DLIB_TEST(b == 3);
a = 2; a = 2;
tp.add_task(*this, &thread_pool_tester::add1, a, b); tp.add_task(*this, &thread_pool_tester::add1, a, b);
DLIB_CASSERT(a == 2,""); DLIB_TEST(a == 2);
DLIB_CASSERT(b == 5,""); DLIB_TEST(b == 5);
val = 4; val = 4;
uint64 id = tp.add_task(*this, &thread_pool_tester::zero_val); uint64 id = tp.add_task(*this, &thread_pool_tester::zero_val);
tp.wait_for_task(id); tp.wait_for_task(id);
DLIB_CASSERT(val == 0,""); DLIB_TEST(val == 0);
id = tp.add_task(*this, &thread_pool_tester::accum2, 1,2); id = tp.add_task(*this, &thread_pool_tester::accum2, 1,2);
tp.wait_for_all_tasks(); tp.wait_for_all_tasks();
DLIB_CASSERT(val == 3,""); DLIB_TEST(val == 3);
id = tp.add_task(*this, &thread_pool_tester::accum1, 3); id = tp.add_task(*this, &thread_pool_tester::accum1, 3);
tp.wait_for_task(id); tp.wait_for_task(id);
DLIB_CASSERT(val == 6,""); DLIB_TEST(val == 6);
obj.get().val = 8; obj.get().val = 8;
DLIB_CASSERT(obj.get().val == 8,""); DLIB_TEST(obj.get().val == 8);
tp.add_task(gset_struct_to_zero, obj); tp.add_task(gset_struct_to_zero, obj);
DLIB_CASSERT(obj.get().val == 0,""); DLIB_TEST(obj.get().val == 0);
obj.get().val = 8; obj.get().val = 8;
DLIB_CASSERT(obj.get().val == 8,""); DLIB_TEST(obj.get().val == 8);
tp.add_task(*this,&thread_pool_tester::set_struct_to_zero, obj); tp.add_task(*this,&thread_pool_tester::set_struct_to_zero, obj);
DLIB_CASSERT(obj.get().val == 0,""); DLIB_TEST(obj.get().val == 0);
a = 1; a = 1;
b = 2; b = 2;
res = 0; res = 0;
add_functor f; add_functor f;
tp.add_task(f, a, b, res); tp.add_task(f, a, b, res);
DLIB_CASSERT(a == 1,""); DLIB_TEST(a == 1);
DLIB_CASSERT(b == 2,""); DLIB_TEST(b == 2);
DLIB_CASSERT(res == 3,""); DLIB_TEST(res == 3);
global_var = 0; global_var = 0;
DLIB_CASSERT(global_var == 0,""); DLIB_TEST(global_var == 0);
id = tp.add_task(&set_global_var); id = tp.add_task(&set_global_var);
tp.wait_for_task(id); tp.wait_for_task(id);
DLIB_CASSERT(global_var == 9,""); DLIB_TEST(global_var == 9);
global_var = 0; global_var = 0;
DLIB_CASSERT(global_var == 0,""); DLIB_TEST(global_var == 0);
id = tp.add_task(f); id = tp.add_task(f);
tp.wait_for_task(id); tp.wait_for_task(id);
DLIB_CASSERT(global_var == 9,""); DLIB_TEST(global_var == 9);
global_var = 0; global_var = 0;
DLIB_CASSERT(global_var == 0,""); DLIB_TEST(global_var == 0);
id = tp.add_task(f, &add_functor::set_global_var); id = tp.add_task(f, &add_functor::set_global_var);
tp.wait_for_task(id); tp.wait_for_task(id);
DLIB_CASSERT(global_var == 9,""); DLIB_TEST(global_var == 9);
global_var = 0; global_var = 0;
DLIB_CASSERT(global_var == 0,""); DLIB_TEST(global_var == 0);
id = tp.add_task(f, &add_functor::set_global_var_const); id = tp.add_task(f, &add_functor::set_global_var_const);
tp.wait_for_task(id); tp.wait_for_task(id);
DLIB_CASSERT(global_var == 9,""); DLIB_TEST(global_var == 9);
......
...@@ -65,7 +65,7 @@ namespace ...@@ -65,7 +65,7 @@ namespace
sm.wait(); sm.wait();
DLIB_CASSERT(!failure,""); DLIB_TEST(!failure);
} }
void thread_end_handler ( void thread_end_handler (
......
...@@ -65,38 +65,38 @@ namespace ...@@ -65,38 +65,38 @@ namespace
timer_t t2(h,&timer_test_helper::add); timer_t t2(h,&timer_test_helper::add);
timer_t t3(h,&timer_test_helper::add); timer_t t3(h,&timer_test_helper::add);
DLIB_CASSERT(t1.delay_time() == 1000,""); DLIB_TEST(t1.delay_time() == 1000);
DLIB_CASSERT(t2.delay_time() == 1000,""); DLIB_TEST(t2.delay_time() == 1000);
DLIB_CASSERT(t3.delay_time() == 1000,""); DLIB_TEST(t3.delay_time() == 1000);
DLIB_CASSERT(t1.is_running() == false,""); DLIB_TEST(t1.is_running() == false);
DLIB_CASSERT(t2.is_running() == false,""); DLIB_TEST(t2.is_running() == false);
DLIB_CASSERT(t3.is_running() == false,""); DLIB_TEST(t3.is_running() == false);
DLIB_CASSERT(t1.action_function() == &timer_test_helper::add,""); DLIB_TEST(t1.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t2.action_function() == &timer_test_helper::add,""); DLIB_TEST(t2.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t3.action_function() == &timer_test_helper::add,""); DLIB_TEST(t3.action_function() == &timer_test_helper::add);
DLIB_CASSERT(&t1.action_object() == &h,""); DLIB_TEST(&t1.action_object() == &h);
DLIB_CASSERT(&t2.action_object() == &h,""); DLIB_TEST(&t2.action_object() == &h);
DLIB_CASSERT(&t3.action_object() == &h,""); DLIB_TEST(&t3.action_object() == &h);
t1.set_delay_time(1000); t1.set_delay_time(1000);
t2.set_delay_time(500); t2.set_delay_time(500);
t3.set_delay_time(200); t3.set_delay_time(200);
DLIB_CASSERT(t1.delay_time() == 1000,""); DLIB_TEST(t1.delay_time() == 1000);
DLIB_CASSERT(t2.delay_time() == 500,""); DLIB_TEST(t2.delay_time() == 500);
DLIB_CASSERT(t3.delay_time() == 200,""); DLIB_TEST(t3.delay_time() == 200);
DLIB_CASSERT(t1.is_running() == false,""); DLIB_TEST(t1.is_running() == false);
DLIB_CASSERT(t2.is_running() == false,""); DLIB_TEST(t2.is_running() == false);
DLIB_CASSERT(t3.is_running() == false,""); DLIB_TEST(t3.is_running() == false);
DLIB_CASSERT(t1.action_function() == &timer_test_helper::add,""); DLIB_TEST(t1.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t2.action_function() == &timer_test_helper::add,""); DLIB_TEST(t2.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t3.action_function() == &timer_test_helper::add,""); DLIB_TEST(t3.action_function() == &timer_test_helper::add);
DLIB_CASSERT(&t1.action_object() == &h,""); DLIB_TEST(&t1.action_object() == &h);
DLIB_CASSERT(&t2.action_object() == &h,""); DLIB_TEST(&t2.action_object() == &h);
DLIB_CASSERT(&t3.action_object() == &h,""); DLIB_TEST(&t3.action_object() == &h);
dlib::sleep(1100); dlib::sleep(1100);
print_spinner(); print_spinner();
DLIB_CASSERT(h.count == 0,""); DLIB_TEST(h.count == 0);
t1.stop_and_wait(); t1.stop_and_wait();
t2.stop_and_wait(); t2.stop_and_wait();
...@@ -104,58 +104,58 @@ namespace ...@@ -104,58 +104,58 @@ namespace
dlib::sleep(1100); dlib::sleep(1100);
print_spinner(); print_spinner();
DLIB_CASSERT(h.count == 0,""); DLIB_TEST(h.count == 0);
DLIB_CASSERT(t1.delay_time() == 1000,""); DLIB_TEST(t1.delay_time() == 1000);
DLIB_CASSERT(t2.delay_time() == 500,""); DLIB_TEST(t2.delay_time() == 500);
DLIB_CASSERT(t3.delay_time() == 200,""); DLIB_TEST(t3.delay_time() == 200);
DLIB_CASSERT(t1.is_running() == false,""); DLIB_TEST(t1.is_running() == false);
DLIB_CASSERT(t2.is_running() == false,""); DLIB_TEST(t2.is_running() == false);
DLIB_CASSERT(t3.is_running() == false,""); DLIB_TEST(t3.is_running() == false);
DLIB_CASSERT(t1.action_function() == &timer_test_helper::add,""); DLIB_TEST(t1.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t2.action_function() == &timer_test_helper::add,""); DLIB_TEST(t2.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t3.action_function() == &timer_test_helper::add,""); DLIB_TEST(t3.action_function() == &timer_test_helper::add);
DLIB_CASSERT(&t1.action_object() == &h,""); DLIB_TEST(&t1.action_object() == &h);
DLIB_CASSERT(&t2.action_object() == &h,""); DLIB_TEST(&t2.action_object() == &h);
DLIB_CASSERT(&t3.action_object() == &h,""); DLIB_TEST(&t3.action_object() == &h);
t1.start(); t1.start();
t2.start(); t2.start();
t3.start(); t3.start();
DLIB_CASSERT(t1.delay_time() == 1000,""); DLIB_TEST(t1.delay_time() == 1000);
DLIB_CASSERT(t2.delay_time() == 500,""); DLIB_TEST(t2.delay_time() == 500);
DLIB_CASSERT(t3.delay_time() == 200,""); DLIB_TEST(t3.delay_time() == 200);
DLIB_CASSERT(t1.is_running() == true,""); DLIB_TEST(t1.is_running() == true);
DLIB_CASSERT(t2.is_running() == true,""); DLIB_TEST(t2.is_running() == true);
DLIB_CASSERT(t3.is_running() == true,""); DLIB_TEST(t3.is_running() == true);
DLIB_CASSERT(t1.action_function() == &timer_test_helper::add,""); DLIB_TEST(t1.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t2.action_function() == &timer_test_helper::add,""); DLIB_TEST(t2.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t3.action_function() == &timer_test_helper::add,""); DLIB_TEST(t3.action_function() == &timer_test_helper::add);
DLIB_CASSERT(&t1.action_object() == &h,""); DLIB_TEST(&t1.action_object() == &h);
DLIB_CASSERT(&t2.action_object() == &h,""); DLIB_TEST(&t2.action_object() == &h);
DLIB_CASSERT(&t3.action_object() == &h,""); DLIB_TEST(&t3.action_object() == &h);
t1.stop(); t1.stop();
t2.stop(); t2.stop();
t3.stop(); t3.stop();
DLIB_CASSERT(t1.delay_time() == 1000,""); DLIB_TEST(t1.delay_time() == 1000);
DLIB_CASSERT(t2.delay_time() == 500,""); DLIB_TEST(t2.delay_time() == 500);
DLIB_CASSERT(t3.delay_time() == 200,""); DLIB_TEST(t3.delay_time() == 200);
DLIB_CASSERT(t1.is_running() == false,""); DLIB_TEST(t1.is_running() == false);
DLIB_CASSERT(t2.is_running() == false,""); DLIB_TEST(t2.is_running() == false);
DLIB_CASSERT(t3.is_running() == false,""); DLIB_TEST(t3.is_running() == false);
DLIB_CASSERT(t1.action_function() == &timer_test_helper::add,""); DLIB_TEST(t1.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t2.action_function() == &timer_test_helper::add,""); DLIB_TEST(t2.action_function() == &timer_test_helper::add);
DLIB_CASSERT(t3.action_function() == &timer_test_helper::add,""); DLIB_TEST(t3.action_function() == &timer_test_helper::add);
DLIB_CASSERT(&t1.action_object() == &h,""); DLIB_TEST(&t1.action_object() == &h);
DLIB_CASSERT(&t2.action_object() == &h,""); DLIB_TEST(&t2.action_object() == &h);
DLIB_CASSERT(&t3.action_object() == &h,""); DLIB_TEST(&t3.action_object() == &h);
DLIB_CASSERT(h.count == 0,""); DLIB_TEST(h.count == 0);
dlib::sleep(1100); dlib::sleep(1100);
print_spinner(); print_spinner();
DLIB_CASSERT(h.count == 0,""); DLIB_TEST(h.count == 0);
for (int i = 1; i <= 3; ++i) for (int i = 1; i <= 3; ++i)
{ {
...@@ -163,9 +163,9 @@ namespace ...@@ -163,9 +163,9 @@ namespace
t2.start(); t2.start();
t3.start(); t3.start();
DLIB_CASSERT(t1.is_running() == true,""); DLIB_TEST(t1.is_running() == true);
DLIB_CASSERT(t2.is_running() == true,""); DLIB_TEST(t2.is_running() == true);
DLIB_CASSERT(t3.is_running() == true,""); DLIB_TEST(t3.is_running() == true);
dlib::sleep(1100); dlib::sleep(1100);
// this should allow the timers to trigger 8 times // this should allow the timers to trigger 8 times
...@@ -173,42 +173,42 @@ namespace ...@@ -173,42 +173,42 @@ namespace
t2.stop(); t2.stop();
t3.stop(); t3.stop();
DLIB_CASSERT(h.count == 8*i,"h.count: " << h.count << " i: " << i); DLIB_TEST_MSG(h.count == 8*i,"h.count: " << h.count << " i: " << i);
dlib::sleep(1100); dlib::sleep(1100);
DLIB_CASSERT(h.count == 8*i,"h.count: " << h.count << " i: " << i); DLIB_TEST_MSG(h.count == 8*i,"h.count: " << h.count << " i: " << i);
} }
h.count = 0; h.count = 0;
t1.start(); t1.start();
dlib::sleep(300); dlib::sleep(300);
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
t1.set_delay_time(400); t1.set_delay_time(400);
dlib::sleep(200); dlib::sleep(200);
DLIB_CASSERT(h.count == 1,h.count); DLIB_TEST_MSG(h.count == 1,h.count);
dlib::sleep(250); dlib::sleep(250);
DLIB_CASSERT(h.count == 1,h.count); DLIB_TEST_MSG(h.count == 1,h.count);
dlib::sleep(100); dlib::sleep(100);
DLIB_CASSERT(h.count == 2,h.count); DLIB_TEST_MSG(h.count == 2,h.count);
t1.set_delay_time(2000); t1.set_delay_time(2000);
DLIB_CASSERT(h.count == 2,h.count); DLIB_TEST_MSG(h.count == 2,h.count);
dlib::sleep(1000); dlib::sleep(1000);
DLIB_CASSERT(h.count == 2,h.count); DLIB_TEST_MSG(h.count == 2,h.count);
t1.clear(); t1.clear();
h.count = 0; h.count = 0;
t3.start(); t3.start();
DLIB_CASSERT(t3.is_running() == true,""); DLIB_TEST(t3.is_running() == true);
DLIB_CASSERT(t3.delay_time() == 200,""); DLIB_TEST(t3.delay_time() == 200);
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
t3.clear(); t3.clear();
DLIB_CASSERT(t3.is_running() == false,""); DLIB_TEST(t3.is_running() == false);
DLIB_CASSERT(t3.delay_time() == 1000,""); DLIB_TEST(t3.delay_time() == 1000);
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
dlib::sleep(200); dlib::sleep(200);
DLIB_CASSERT(t3.is_running() == false,""); DLIB_TEST(t3.is_running() == false);
DLIB_CASSERT(t3.delay_time() == 1000,""); DLIB_TEST(t3.delay_time() == 1000);
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
{ {
...@@ -216,12 +216,12 @@ namespace ...@@ -216,12 +216,12 @@ namespace
timer_t t4(h,&timer_test_helper::delayed_add); timer_t t4(h,&timer_test_helper::delayed_add);
t4.set_delay_time(100); t4.set_delay_time(100);
t4.start(); t4.start();
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
dlib::sleep(400); dlib::sleep(400);
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
t4.stop_and_wait(); t4.stop_and_wait();
DLIB_CASSERT(h.count == 1,h.count); DLIB_TEST_MSG(h.count == 1,h.count);
DLIB_CASSERT(t4.is_running() == false,""); DLIB_TEST(t4.is_running() == false);
} }
{ {
...@@ -229,15 +229,15 @@ namespace ...@@ -229,15 +229,15 @@ namespace
timer_t t4(h,&timer_test_helper::delayed_add); timer_t t4(h,&timer_test_helper::delayed_add);
t4.set_delay_time(100); t4.set_delay_time(100);
t4.start(); t4.start();
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
dlib::sleep(400); dlib::sleep(400);
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
t4.clear(); t4.clear();
DLIB_CASSERT(t4.is_running() == false,""); DLIB_TEST(t4.is_running() == false);
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
t4.stop_and_wait(); t4.stop_and_wait();
DLIB_CASSERT(h.count == 1,h.count); DLIB_TEST_MSG(h.count == 1,h.count);
DLIB_CASSERT(t4.is_running() == false,""); DLIB_TEST(t4.is_running() == false);
} }
{ {
...@@ -245,11 +245,11 @@ namespace ...@@ -245,11 +245,11 @@ namespace
timer_t t5(h,&timer_test_helper::delayed_add); timer_t t5(h,&timer_test_helper::delayed_add);
t5.set_delay_time(100); t5.set_delay_time(100);
t5.start(); t5.start();
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
dlib::sleep(400); dlib::sleep(400);
DLIB_CASSERT(h.count == 0,h.count); DLIB_TEST_MSG(h.count == 0,h.count);
} }
DLIB_CASSERT(h.count == 1,h.count); DLIB_TEST_MSG(h.count == 1,h.count);
} }
......
...@@ -33,22 +33,22 @@ namespace ...@@ -33,22 +33,22 @@ namespace
tok test; tok test;
DLIB_CASSERT(test.numbers() == "0123456789",""); DLIB_TEST(test.numbers() == "0123456789");
DLIB_CASSERT(test.uppercase_letters() == "ABCDEFGHIJKLMNOPQRSTUVWXYZ",""); DLIB_TEST(test.uppercase_letters() == "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
DLIB_CASSERT(test.lowercase_letters() == "abcdefghijklmnopqrstuvwxyz",""); DLIB_TEST(test.lowercase_letters() == "abcdefghijklmnopqrstuvwxyz");
DLIB_CASSERT(test.get_identifier_body() == "_" + test.lowercase_letters() + DLIB_TEST_MSG(test.get_identifier_body() == "_" + test.lowercase_letters() +
test.uppercase_letters() + test.numbers(),""); test.uppercase_letters() + test.numbers(),"");
DLIB_CASSERT(test.get_identifier_head() == "_" + test.lowercase_letters() + DLIB_TEST_MSG(test.get_identifier_head() == "_" + test.lowercase_letters() +
test.uppercase_letters(),""); test.uppercase_letters(),"");
DLIB_CASSERT(test.stream_is_set() == false,""); DLIB_TEST(test.stream_is_set() == false);
test.clear(); test.clear();
DLIB_CASSERT(test.stream_is_set() == false,""); DLIB_TEST(test.stream_is_set() == false);
DLIB_CASSERT(test.get_identifier_body() == "_" + test.lowercase_letters() + DLIB_TEST_MSG(test.get_identifier_body() == "_" + test.lowercase_letters() +
test.uppercase_letters() + test.numbers(),""); test.uppercase_letters() + test.numbers(),"");
DLIB_CASSERT(test.get_identifier_head() == "_" + test.lowercase_letters() + DLIB_TEST_MSG(test.get_identifier_head() == "_" + test.lowercase_letters() +
test.uppercase_letters(),""); test.uppercase_letters(),"");
tok test2; tok test2;
...@@ -57,108 +57,108 @@ namespace ...@@ -57,108 +57,108 @@ namespace
istringstream sin; istringstream sin;
test2.set_stream(sin); test2.set_stream(sin);
DLIB_CASSERT(test2.stream_is_set(),""); DLIB_TEST(test2.stream_is_set());
DLIB_CASSERT(&test2.get_stream() == &sin,""); DLIB_TEST(&test2.get_stream() == &sin);
int type; int type;
string token; string token;
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_FILE,""); DLIB_TEST(type == tok::END_OF_FILE);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_FILE,""); DLIB_TEST(type == tok::END_OF_FILE);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_FILE,""); DLIB_TEST(type == tok::END_OF_FILE);
sin.clear(); sin.clear();
sin.str(" The cat 123asdf1234 ._ \n test."); sin.str(" The cat 123asdf1234 ._ \n test.");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
DLIB_CASSERT(test2.peek_type() == tok::IDENTIFIER,""); DLIB_TEST(test2.peek_type() == tok::IDENTIFIER);
DLIB_CASSERT(test2.peek_token() == "The",""); DLIB_TEST(test2.peek_token() == "The");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "The",""); DLIB_TEST(token == "The");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "cat",""); DLIB_TEST(token == "cat");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::NUMBER,""); DLIB_TEST(type == tok::NUMBER);
DLIB_CASSERT(token == "123","token: " << token); DLIB_TEST_MSG(token == "123","token: " << token);
DLIB_CASSERT(test2.peek_type() == tok::IDENTIFIER,""); DLIB_TEST(test2.peek_type() == tok::IDENTIFIER);
DLIB_CASSERT(test2.peek_token() == "asdf1234",""); DLIB_TEST(test2.peek_token() == "asdf1234");
DLIB_CASSERT(test2.peek_type() == tok::IDENTIFIER,""); DLIB_TEST(test2.peek_type() == tok::IDENTIFIER);
DLIB_CASSERT(test2.peek_token() == "asdf1234",""); DLIB_TEST(test2.peek_token() == "asdf1234");
DLIB_CASSERT(test2.peek_type() == tok::IDENTIFIER,""); DLIB_TEST(test2.peek_type() == tok::IDENTIFIER);
DLIB_CASSERT(test2.peek_token() == "asdf1234",""); DLIB_TEST(test2.peek_token() == "asdf1234");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "asdf1234",""); DLIB_TEST(token == "asdf1234");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ","token: " << token); DLIB_TEST_MSG(token == " ","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::CHAR,""); DLIB_TEST(type == tok::CHAR);
DLIB_CASSERT(token == ".","token: " << token); DLIB_TEST_MSG(token == ".","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "_",""); DLIB_TEST(token == "_");
DLIB_CASSERT(test2.peek_type() == tok::WHITE_SPACE,""); DLIB_TEST(test2.peek_type() == tok::WHITE_SPACE);
DLIB_CASSERT(test2.peek_token() == " ","token: \"" << token << "\"" << DLIB_TEST_MSG(test2.peek_token() == " ","token: \"" << token << "\"" <<
"\ntoken size: " << (unsigned int)token.size()); "\ntoken size: " << (unsigned int)token.size());
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test2.stream_is_set() == false,""); DLIB_TEST(test2.stream_is_set() == false);
DLIB_CASSERT(test.peek_type() == tok::WHITE_SPACE,""); DLIB_TEST(test.peek_type() == tok::WHITE_SPACE);
DLIB_CASSERT(test.peek_token() == " ","token: \"" << token << "\"" << DLIB_TEST_MSG(test.peek_token() == " ","token: \"" << token << "\"" <<
"\ntoken size: " << (unsigned int)token.size()); "\ntoken size: " << (unsigned int)token.size());
test.get_token(type,token); test.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ","token: \"" << token << "\"" << DLIB_TEST_MSG(token == " ","token: \"" << token << "\"" <<
"\ntoken size: " << (unsigned int)token.size()); "\ntoken size: " << (unsigned int)token.size());
test.get_token(type,token); test.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_LINE,"token: " << token); DLIB_TEST_MSG(type == tok::END_OF_LINE,"token: " << token);
DLIB_CASSERT(token == "\n","token: " << token); DLIB_TEST_MSG(token == "\n","token: " << token);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test.stream_is_set() == false,""); DLIB_TEST(test.stream_is_set() == false);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ","token: " << token); DLIB_TEST_MSG(token == " ","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "test","token: " << token); DLIB_TEST_MSG(token == "test","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::CHAR,""); DLIB_TEST(type == tok::CHAR);
DLIB_CASSERT(token == ".","token: " << token); DLIB_TEST_MSG(token == ".","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_FILE,""); DLIB_TEST(type == tok::END_OF_FILE);
...@@ -178,75 +178,75 @@ namespace ...@@ -178,75 +178,75 @@ namespace
sin.str(" The cat 123asdf1234 ._ \n\r test."); sin.str(" The cat 123asdf1234 ._ \n\r test.");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "The",""); DLIB_TEST(token == "The");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "cat",""); DLIB_TEST(token == "cat");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::NUMBER,""); DLIB_TEST(type == tok::NUMBER);
DLIB_CASSERT(token == "123","token: " << token); DLIB_TEST_MSG(token == "123","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "asdf1234",""); DLIB_TEST(token == "asdf1234");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ","token: " << token); DLIB_TEST_MSG(token == " ","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::CHAR,""); DLIB_TEST(type == tok::CHAR);
DLIB_CASSERT(token == ".","token: " << token); DLIB_TEST_MSG(token == ".","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "_",""); DLIB_TEST(token == "_");
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test2.stream_is_set() == false,""); DLIB_TEST(test2.stream_is_set() == false);
test.get_token(type,token); test.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ","token: \"" << token << "\"" << DLIB_TEST_MSG(token == " ","token: \"" << token << "\"" <<
"\ntoken size: " << (unsigned int)token.size()); "\ntoken size: " << (unsigned int)token.size());
test.get_token(type,token); test.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_LINE,"token: " << token); DLIB_TEST_MSG(type == tok::END_OF_LINE,"token: " << token);
DLIB_CASSERT(token == "\n","token: " << token); DLIB_TEST_MSG(token == "\n","token: " << token);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test.stream_is_set() == false,""); DLIB_TEST(test.stream_is_set() == false);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == "\r ","token: " << token); DLIB_TEST_MSG(token == "\r ","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "test","token: " << token); DLIB_TEST_MSG(token == "test","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::CHAR,""); DLIB_TEST(type == tok::CHAR);
DLIB_CASSERT(token == ".","token: " << token); DLIB_TEST_MSG(token == ".","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_FILE,""); DLIB_TEST(type == tok::END_OF_FILE);
...@@ -269,83 +269,83 @@ namespace ...@@ -269,83 +269,83 @@ namespace
sin.str(" The cat 123as_df1234 ._ \n test."); sin.str(" The cat 123as_df1234 ._ \n test.");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "The",""); DLIB_TEST(token == "The");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "cat",""); DLIB_TEST(token == "cat");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ",""); DLIB_TEST(token == " ");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::NUMBER,""); DLIB_TEST(type == tok::NUMBER);
DLIB_CASSERT(token == "123","token: " << token); DLIB_TEST_MSG(token == "123","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "as",""); DLIB_TEST(token == "as");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::CHAR,""); DLIB_TEST(type == tok::CHAR);
DLIB_CASSERT(token == "_","token: " << token); DLIB_TEST_MSG(token == "_","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "df1234",""); DLIB_TEST(token == "df1234");
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ","token: " << token); DLIB_TEST_MSG(token == " ","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::CHAR,""); DLIB_TEST(type == tok::CHAR);
DLIB_CASSERT(token == ".","token: " << token); DLIB_TEST_MSG(token == ".","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::CHAR,""); DLIB_TEST(type == tok::CHAR);
DLIB_CASSERT(token == "_",""); DLIB_TEST(token == "_");
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test2.stream_is_set() == false,""); DLIB_TEST(test2.stream_is_set() == false);
test.get_token(type,token); test.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ","token: \"" << token << "\"" << DLIB_TEST_MSG(token == " ","token: \"" << token << "\"" <<
"\ntoken size: " << (unsigned int)token.size()); "\ntoken size: " << (unsigned int)token.size());
test.get_token(type,token); test.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_LINE,"token: " << token); DLIB_TEST_MSG(type == tok::END_OF_LINE,"token: " << token);
DLIB_CASSERT(token == "\n","token: " << token); DLIB_TEST_MSG(token == "\n","token: " << token);
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test.stream_is_set() == false,""); DLIB_TEST(test.stream_is_set() == false);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::WHITE_SPACE,""); DLIB_TEST(type == tok::WHITE_SPACE);
DLIB_CASSERT(token == " ","token: " << token); DLIB_TEST_MSG(token == " ","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::IDENTIFIER,""); DLIB_TEST(type == tok::IDENTIFIER);
DLIB_CASSERT(token == "test","token: " << token); DLIB_TEST_MSG(token == "test","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::CHAR,""); DLIB_TEST(type == tok::CHAR);
DLIB_CASSERT(token == ".","token: " << token); DLIB_TEST_MSG(token == ".","token: " << token);
test2.get_token(type,token); test2.get_token(type,token);
DLIB_CASSERT(type == tok::END_OF_FILE,""); DLIB_TEST(type == tok::END_OF_FILE);
} }
......
...@@ -98,15 +98,15 @@ namespace ...@@ -98,15 +98,15 @@ namespace
COMPILE_TIME_ASSERT((is_same_type<tuple<int,float>::get_type<2>::type, null_type>::value)); COMPILE_TIME_ASSERT((is_same_type<tuple<int,float>::get_type<2>::type, null_type>::value));
b.get<0>() = 8; b.get<0>() = 8;
DLIB_CASSERT(b.get<int>() == 8,""); DLIB_TEST(b.get<int>() == 8);
DLIB_CASSERT(b.index<int>() == 0,""); DLIB_TEST(b.index<int>() == 0);
c.get<0>() = 9; c.get<0>() = 9;
DLIB_CASSERT(c.get<int>() == 9,""); DLIB_TEST(c.get<int>() == 9);
DLIB_CASSERT(c.index<int>() == 0,""); DLIB_TEST(c.index<int>() == 0);
c.get<1>() = 3.0; c.get<1>() = 3.0;
DLIB_CASSERT(c.get<float>() == 3.0,""); DLIB_TEST(c.get<float>() == 3.0);
DLIB_CASSERT(c.index<float>() == 1,""); DLIB_TEST(c.index<float>() == 1);
...@@ -126,9 +126,9 @@ namespace ...@@ -126,9 +126,9 @@ namespace
const_cast<const T&>(a).for_each(nil()); const_cast<const T&>(a).for_each(nil());
const_cast<const T&>(a).for_each(n); const_cast<const T&>(a).for_each(n);
DLIB_CASSERT(a.get<0>() == b.get<0>()+2,""); DLIB_TEST(a.get<0>() == b.get<0>()+2);
DLIB_CASSERT(a.get<1>() == b.get<1>()+2,""); DLIB_TEST(a.get<1>() == b.get<1>()+2);
DLIB_CASSERT(a.get<2>() == b.get<2>()+2,""); DLIB_TEST(a.get<2>() == b.get<2>()+2);
ostringstream sout; ostringstream sout;
...@@ -136,24 +136,24 @@ namespace ...@@ -136,24 +136,24 @@ namespace
istringstream sin(sout.str()); istringstream sin(sout.str());
deserialize(b,sin); deserialize(b,sin);
DLIB_CASSERT(a.get<0>() == b.get<0>(),""); DLIB_TEST(a.get<0>() == b.get<0>());
DLIB_CASSERT(a.get<1>() == b.get<1>(),""); DLIB_TEST(a.get<1>() == b.get<1>());
DLIB_CASSERT(a.get<2>() == b.get<2>(),""); DLIB_TEST(a.get<2>() == b.get<2>());
a.for_index(i,0); a.for_index(i,0);
a.for_index(inc(),1); a.for_index(inc(),1);
const_cast<const T&>(a).for_index(n,2); const_cast<const T&>(a).for_index(n,2);
const_cast<const T&>(a).for_index(nil(),0); const_cast<const T&>(a).for_index(nil(),0);
DLIB_CASSERT(a.get<0>() == b.get<0>()+1,""); DLIB_TEST(a.get<0>() == b.get<0>()+1);
DLIB_CASSERT(a.get<1>() == b.get<1>()+1,""); DLIB_TEST(a.get<1>() == b.get<1>()+1);
DLIB_CASSERT(a.get<2>() == b.get<2>()+0,""); DLIB_TEST(a.get<2>() == b.get<2>()+0);
swap(a,b); swap(a,b);
DLIB_CASSERT(b.get<0>() == a.get<0>()+1,""); DLIB_TEST(b.get<0>() == a.get<0>()+1);
DLIB_CASSERT(b.get<1>() == a.get<1>()+1,""); DLIB_TEST(b.get<1>() == a.get<1>()+1);
DLIB_CASSERT(b.get<2>() == a.get<2>()+0,""); DLIB_TEST(b.get<2>() == a.get<2>()+0);
} }
......
...@@ -30,25 +30,25 @@ namespace ...@@ -30,25 +30,25 @@ namespace
void operator() (float val) void operator() (float val)
{ {
DLIB_CASSERT(val == f_val,""); DLIB_TEST(val == f_val);
last_kind = FLOAT; last_kind = FLOAT;
} }
void operator() (double val) void operator() (double val)
{ {
DLIB_CASSERT(val == d_val,""); DLIB_TEST(val == d_val);
last_kind = DOUBLE; last_kind = DOUBLE;
} }
void operator() (char val) void operator() (char val)
{ {
DLIB_CASSERT(val == c_val,""); DLIB_TEST(val == c_val);
last_kind = CHAR; last_kind = CHAR;
} }
void operator()(std::string& val) void operator()(std::string& val)
{ {
DLIB_CASSERT(val == s_val,""); DLIB_TEST(val == s_val);
last_kind = STRING; last_kind = STRING;
} }
...@@ -68,29 +68,29 @@ namespace ...@@ -68,29 +68,29 @@ namespace
public: public:
void test_stuff() void test_stuff()
{ {
DLIB_CASSERT(a.is_empty() == true,""); DLIB_TEST(a.is_empty() == true);
DLIB_CASSERT(a.contains<char>() == false,""); DLIB_TEST(a.contains<char>() == false);
DLIB_CASSERT(a.contains<float>() == false,""); DLIB_TEST(a.contains<float>() == false);
DLIB_CASSERT(a.contains<double>() == false,""); DLIB_TEST(a.contains<double>() == false);
DLIB_CASSERT(a.contains<std::string>() == false,""); DLIB_TEST(a.contains<std::string>() == false);
DLIB_CASSERT(a.contains<long>() == false,""); DLIB_TEST(a.contains<long>() == false);
f_val = 4.345f; f_val = 4.345f;
a.get<float>() = f_val; a.get<float>() = f_val;
DLIB_CASSERT(a.is_empty() == false,""); DLIB_TEST(a.is_empty() == false);
DLIB_CASSERT(a.contains<char>() == false,""); DLIB_TEST(a.contains<char>() == false);
DLIB_CASSERT(a.contains<float>() == true,""); DLIB_TEST(a.contains<float>() == true);
DLIB_CASSERT(a.contains<double>() == false,""); DLIB_TEST(a.contains<double>() == false);
DLIB_CASSERT(a.contains<std::string>() == false,""); DLIB_TEST(a.contains<std::string>() == false);
DLIB_CASSERT(a.contains<long>() == false,""); DLIB_TEST(a.contains<long>() == false);
last_kind = NONE; last_kind = NONE;
a.apply_to_contents(*this); a.apply_to_contents(*this);
DLIB_CASSERT(last_kind == FLOAT,""); DLIB_TEST(last_kind == FLOAT);
// ----------- // -----------
...@@ -98,7 +98,7 @@ namespace ...@@ -98,7 +98,7 @@ namespace
a.get<double>() = d_val; a.get<double>() = d_val;
last_kind = NONE; last_kind = NONE;
a.apply_to_contents(*this); a.apply_to_contents(*this);
DLIB_CASSERT(last_kind == DOUBLE,""); DLIB_TEST(last_kind == DOUBLE);
// ----------- // -----------
...@@ -106,7 +106,7 @@ namespace ...@@ -106,7 +106,7 @@ namespace
a.get<char>() = c_val; a.get<char>() = c_val;
last_kind = NONE; last_kind = NONE;
a.apply_to_contents(*this); a.apply_to_contents(*this);
DLIB_CASSERT(last_kind == CHAR,""); DLIB_TEST(last_kind == CHAR);
// ----------- // -----------
...@@ -114,120 +114,120 @@ namespace ...@@ -114,120 +114,120 @@ namespace
a.get<std::string>() = s_val; a.get<std::string>() = s_val;
last_kind = NONE; last_kind = NONE;
a.apply_to_contents(*this); a.apply_to_contents(*this);
DLIB_CASSERT(last_kind == STRING,""); DLIB_TEST(last_kind == STRING);
// ----------- // -----------
DLIB_CASSERT(a.is_empty() == false,""); DLIB_TEST(a.is_empty() == false);
DLIB_CASSERT(a.contains<char>() == false,""); DLIB_TEST(a.contains<char>() == false);
DLIB_CASSERT(a.contains<float>() == false,""); DLIB_TEST(a.contains<float>() == false);
DLIB_CASSERT(a.contains<double>() == false,""); DLIB_TEST(a.contains<double>() == false);
DLIB_CASSERT(a.contains<std::string>() == true,""); DLIB_TEST(a.contains<std::string>() == true);
DLIB_CASSERT(a.contains<long>() == false,""); DLIB_TEST(a.contains<long>() == false);
// ----------- // -----------
a.swap(b); a.swap(b);
DLIB_CASSERT(a.is_empty() == true,""); DLIB_TEST(a.is_empty() == true);
DLIB_CASSERT(a.contains<char>() == false,""); DLIB_TEST(a.contains<char>() == false);
DLIB_CASSERT(a.contains<float>() == false,""); DLIB_TEST(a.contains<float>() == false);
DLIB_CASSERT(a.contains<double>() == false,""); DLIB_TEST(a.contains<double>() == false);
DLIB_CASSERT(a.contains<std::string>() == false,""); DLIB_TEST(a.contains<std::string>() == false);
DLIB_CASSERT(a.contains<long>() == false,""); DLIB_TEST(a.contains<long>() == false);
DLIB_CASSERT(b.is_empty() == false,""); DLIB_TEST(b.is_empty() == false);
DLIB_CASSERT(b.contains<char>() == false,""); DLIB_TEST(b.contains<char>() == false);
DLIB_CASSERT(b.contains<float>() == false,""); DLIB_TEST(b.contains<float>() == false);
DLIB_CASSERT(b.contains<double>() == false,""); DLIB_TEST(b.contains<double>() == false);
DLIB_CASSERT(b.contains<std::string>() == true,""); DLIB_TEST(b.contains<std::string>() == true);
DLIB_CASSERT(b.contains<long>() == false,""); DLIB_TEST(b.contains<long>() == false);
last_kind = NONE; last_kind = NONE;
b.apply_to_contents(*this); b.apply_to_contents(*this);
DLIB_CASSERT(last_kind == STRING,""); DLIB_TEST(last_kind == STRING);
// ----------- // -----------
b.swap(a); b.swap(a);
DLIB_CASSERT(b.is_empty() == true,""); DLIB_TEST(b.is_empty() == true);
DLIB_CASSERT(b.contains<char>() == false,""); DLIB_TEST(b.contains<char>() == false);
DLIB_CASSERT(b.contains<float>() == false,""); DLIB_TEST(b.contains<float>() == false);
DLIB_CASSERT(b.contains<double>() == false,""); DLIB_TEST(b.contains<double>() == false);
DLIB_CASSERT(b.contains<std::string>() == false,""); DLIB_TEST(b.contains<std::string>() == false);
DLIB_CASSERT(b.contains<long>() == false,""); DLIB_TEST(b.contains<long>() == false);
DLIB_CASSERT(a.is_empty() == false,""); DLIB_TEST(a.is_empty() == false);
DLIB_CASSERT(a.contains<char>() == false,""); DLIB_TEST(a.contains<char>() == false);
DLIB_CASSERT(a.contains<float>() == false,""); DLIB_TEST(a.contains<float>() == false);
DLIB_CASSERT(a.contains<double>() == false,""); DLIB_TEST(a.contains<double>() == false);
DLIB_CASSERT(a.contains<std::string>() == true,""); DLIB_TEST(a.contains<std::string>() == true);
DLIB_CASSERT(a.contains<long>() == false,""); DLIB_TEST(a.contains<long>() == false);
last_kind = NONE; last_kind = NONE;
a.apply_to_contents(*this); a.apply_to_contents(*this);
DLIB_CASSERT(last_kind == STRING,""); DLIB_TEST(last_kind == STRING);
last_kind = NONE; last_kind = NONE;
b.apply_to_contents(*this); b.apply_to_contents(*this);
DLIB_CASSERT(last_kind == NONE,""); DLIB_TEST(last_kind == NONE);
a.get<char>() = 'a'; a.get<char>() = 'a';
b.get<char>() = 'b'; b.get<char>() = 'b';
DLIB_CASSERT(a.is_empty() == false,""); DLIB_TEST(a.is_empty() == false);
DLIB_CASSERT(a.contains<char>() == true,""); DLIB_TEST(a.contains<char>() == true);
DLIB_CASSERT(b.is_empty() == false,""); DLIB_TEST(b.is_empty() == false);
DLIB_CASSERT(b.contains<char>() == true,""); DLIB_TEST(b.contains<char>() == true);
DLIB_CASSERT(a.contains<float>() == false,""); DLIB_TEST(a.contains<float>() == false);
DLIB_CASSERT(b.contains<float>() == false,""); DLIB_TEST(b.contains<float>() == false);
DLIB_CASSERT(a.get<char>() == 'a',""); DLIB_TEST(a.get<char>() == 'a');
DLIB_CASSERT(b.get<char>() == 'b',""); DLIB_TEST(b.get<char>() == 'b');
swap(a,b); swap(a,b);
DLIB_CASSERT(a.is_empty() == false,""); DLIB_TEST(a.is_empty() == false);
DLIB_CASSERT(a.contains<char>() == true,""); DLIB_TEST(a.contains<char>() == true);
DLIB_CASSERT(b.is_empty() == false,""); DLIB_TEST(b.is_empty() == false);
DLIB_CASSERT(b.contains<char>() == true,""); DLIB_TEST(b.contains<char>() == true);
DLIB_CASSERT(a.contains<float>() == false,""); DLIB_TEST(a.contains<float>() == false);
DLIB_CASSERT(b.contains<float>() == false,""); DLIB_TEST(b.contains<float>() == false);
DLIB_CASSERT(a.get<char>() == 'b',""); DLIB_TEST(a.get<char>() == 'b');
DLIB_CASSERT(b.get<char>() == 'a',""); DLIB_TEST(b.get<char>() == 'a');
// ----------- // -----------
a.get<char>() = 'a'; a.get<char>() = 'a';
b.get<std::string>() = "a string"; b.get<std::string>() = "a string";
DLIB_CASSERT(a.is_empty() == false,""); DLIB_TEST(a.is_empty() == false);
DLIB_CASSERT(a.contains<char>() == true,""); DLIB_TEST(a.contains<char>() == true);
DLIB_CASSERT(b.is_empty() == false,""); DLIB_TEST(b.is_empty() == false);
DLIB_CASSERT(b.contains<char>() == false,""); DLIB_TEST(b.contains<char>() == false);
DLIB_CASSERT(a.contains<std::string>() == false,""); DLIB_TEST(a.contains<std::string>() == false);
DLIB_CASSERT(b.contains<std::string>() == true,""); DLIB_TEST(b.contains<std::string>() == true);
DLIB_CASSERT(a.get<char>() == 'a',""); DLIB_TEST(a.get<char>() == 'a');
DLIB_CASSERT(b.get<std::string>() == "a string",""); DLIB_TEST(b.get<std::string>() == "a string");
swap(a,b); swap(a,b);
DLIB_CASSERT(b.is_empty() == false,""); DLIB_TEST(b.is_empty() == false);
DLIB_CASSERT(b.contains<char>() == true,""); DLIB_TEST(b.contains<char>() == true);
DLIB_CASSERT(a.is_empty() == false,""); DLIB_TEST(a.is_empty() == false);
DLIB_CASSERT(a.contains<char>() == false,""); DLIB_TEST(a.contains<char>() == false);
DLIB_CASSERT(b.contains<std::string>() == false,""); DLIB_TEST(b.contains<std::string>() == false);
DLIB_CASSERT(a.contains<std::string>() == true,""); DLIB_TEST(a.contains<std::string>() == true);
DLIB_CASSERT(b.get<char>() == 'a',""); DLIB_TEST(b.get<char>() == 'a');
DLIB_CASSERT(a.get<std::string>() == "a string",""); DLIB_TEST(a.get<std::string>() == "a string");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment