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
This diff is collapsed.
...@@ -40,117 +40,117 @@ namespace ...@@ -40,117 +40,117 @@ namespace
enumerable<unsigned long>& e = test; enumerable<unsigned long>& e = test;
DLIB_CASSERT(e.at_start() == true,""); DLIB_TEST(e.at_start() == true);
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.move_next() == false,""); DLIB_TEST (e.move_next() == false);
DLIB_CASSERT (e.move_next() == false,""); DLIB_TEST (e.move_next() == false);
DLIB_CASSERT (e.move_next() == false,""); DLIB_TEST (e.move_next() == false);
DLIB_CASSERT (e.move_next() == false,""); DLIB_TEST (e.move_next() == false);
DLIB_CASSERT (e.move_next() == false,""); DLIB_TEST (e.move_next() == false);
DLIB_CASSERT(e.size() == 0,""); DLIB_TEST(e.size() == 0);
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);
e.reset(); e.reset();
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(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
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.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.size() == 0,""); DLIB_TEST(test.size() == 0);
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);
test.reset(); test.reset();
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);
test.clear(); test.clear();
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
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.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);
test.set_size(0,0); test.set_size(0,0);
DLIB_CASSERT(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
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.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);
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(test.at_start() == true,""); DLIB_TEST(test.at_start() == true);
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() == true,""); DLIB_TEST(test2.at_start() == true);
DLIB_CASSERT(test2.current_element_valid() == false, ""); DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
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);
test.reset(); test.reset();
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);
...@@ -184,46 +184,46 @@ namespace ...@@ -184,46 +184,46 @@ namespace
test.set_size(nr,nc); test.set_size(nr,nc);
DLIB_CASSERT(test.size() == static_cast<unsigned long>(nc*nr),""); DLIB_TEST(test.size() == static_cast<unsigned long>(nc*nr));
DLIB_CASSERT(test.nr() == nr,""); DLIB_TEST(test.nr() == nr);
DLIB_CASSERT(test.nc() == nc,""); DLIB_TEST(test.nc() == nc);
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);
unsigned long i = 0; unsigned long i = 0;
while (test.move_next()) while (test.move_next())
{ {
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
test.element() = i; test.element() = i;
DLIB_CASSERT(const_cast<const array2d&>(test).element() == i,""); DLIB_TEST(const_cast<const array2d&>(test).element() == i);
++i; ++i;
} }
DLIB_CASSERT(i == test.size(),""); DLIB_TEST(i == test.size());
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.nr() == nr,""); DLIB_TEST(test.nr() == nr);
DLIB_CASSERT(test.nc() == nc,""); DLIB_TEST(test.nc() == nc);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.size() == static_cast<unsigned long>(nc*nr),""); DLIB_TEST(test.size() == static_cast<unsigned long>(nc*nr));
i = 0; i = 0;
for (long row = 0; row < test.nr(); ++row) for (long row = 0; row < test.nr(); ++row)
{ {
for (long col = 0; col < test.nc(); ++col) for (long col = 0; col < test.nc(); ++col)
{ {
DLIB_CASSERT(test[row][col] == i, DLIB_TEST_MSG(test[row][col] == i,
"\n\trow: " << row << "\n\trow: " << row <<
"\n\tcol: " << col << "\n\tcol: " << col <<
"\n\ti: " << i << "\n\ti: " << i <<
"\n\ttest[row][col]: " << test[row][col]); "\n\ttest[row][col]: " << test[row][col]);
DLIB_CASSERT(test[row].nc() == test.nc(),""); DLIB_TEST(test[row].nc() == test.nc());
DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.nr() == nr,""); DLIB_TEST(test.nr() == nr);
DLIB_CASSERT(test.nc() == nc,""); DLIB_TEST(test.nc() == nc);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.size() == static_cast<unsigned long>(nc*nr),""); DLIB_TEST(test.size() == static_cast<unsigned long>(nc*nr));
++i; ++i;
} }
} }
...@@ -233,12 +233,12 @@ namespace ...@@ -233,12 +233,12 @@ namespace
i = 0; i = 0;
while (test.move_next()) while (test.move_next())
{ {
DLIB_CASSERT(test.element() == i,""); DLIB_TEST(test.element() == i);
++i; ++i;
DLIB_CASSERT(test.current_element_valid() == true,""); DLIB_TEST(test.current_element_valid() == true);
DLIB_CASSERT(test.at_start() == false,""); DLIB_TEST(test.at_start() == false);
} }
DLIB_CASSERT(i == test.size(),""); DLIB_TEST(i == test.size());
test.reset(); test.reset();
...@@ -247,46 +247,46 @@ namespace ...@@ -247,46 +247,46 @@ namespace
swap(test,test2); swap(test,test2);
DLIB_CASSERT(test2.size() == static_cast<unsigned long>(nc*nr),""); DLIB_TEST(test2.size() == static_cast<unsigned long>(nc*nr));
DLIB_CASSERT(test2.nr() == nr,""); DLIB_TEST(test2.nr() == nr);
DLIB_CASSERT(test2.nc() == nc,""); DLIB_TEST(test2.nc() == nc);
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);
i = 0; i = 0;
while (test2.move_next()) while (test2.move_next())
{ {
DLIB_CASSERT(test2.current_element_valid() == true,""); DLIB_TEST(test2.current_element_valid() == true);
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
test2.element() = i; test2.element() = i;
++i; ++i;
} }
DLIB_CASSERT(i == test2.size(),""); DLIB_TEST(i == test2.size());
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test2.nr() == nr,""); DLIB_TEST(test2.nr() == nr);
DLIB_CASSERT(test2.nr() == test2.nr(),""); DLIB_TEST(test2.nr() == test2.nr());
DLIB_CASSERT(test2.nc() == nc,""); DLIB_TEST(test2.nc() == nc);
DLIB_CASSERT(test2.nc() == test2.nc(),""); DLIB_TEST(test2.nc() == test2.nc());
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.size() == static_cast<unsigned long>(nc*nr),""); DLIB_TEST(test2.size() == static_cast<unsigned long>(nc*nr));
i = 0; i = 0;
for (long row = 0; row < test2.nr(); ++row) for (long row = 0; row < test2.nr(); ++row)
{ {
for (long col = 0; col < test2.nc(); ++col) for (long col = 0; col < test2.nc(); ++col)
{ {
DLIB_CASSERT(test2[row][col] == i,""); DLIB_TEST(test2[row][col] == i);
DLIB_CASSERT(const_cast<const array2d&>(test2)[row][col] == i,""); DLIB_TEST(const_cast<const array2d&>(test2)[row][col] == i);
DLIB_CASSERT(test2[row].nc() == test2.nc(),""); DLIB_TEST(test2[row].nc() == test2.nc());
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test2.nr() == nr,""); DLIB_TEST(test2.nr() == nr);
DLIB_CASSERT(test2.nr() == test2.nr(),""); DLIB_TEST(test2.nr() == test2.nr());
DLIB_CASSERT(test2.nc() == nc,""); DLIB_TEST(test2.nc() == nc);
DLIB_CASSERT(test2.nc() == test2.nc(),""); DLIB_TEST(test2.nc() == test2.nc());
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.size() == static_cast<unsigned long>(nc*nr),""); DLIB_TEST(test2.size() == static_cast<unsigned long>(nc*nr));
++i; ++i;
} }
} }
...@@ -296,30 +296,30 @@ namespace ...@@ -296,30 +296,30 @@ namespace
i = 0; i = 0;
while (test2.move_next()) while (test2.move_next())
{ {
DLIB_CASSERT(test2.element() == i,""); DLIB_TEST(test2.element() == i);
DLIB_CASSERT(const_cast<const array2d&>(test2).element() == i,""); DLIB_TEST(const_cast<const array2d&>(test2).element() == i);
++i; ++i;
DLIB_CASSERT(test2.current_element_valid() == true,""); DLIB_TEST(test2.current_element_valid() == true);
DLIB_CASSERT(test2.at_start() == false,""); DLIB_TEST(test2.at_start() == false);
} }
DLIB_CASSERT(i == test2.size(),""); DLIB_TEST(i == test2.size());
test2.clear(); test2.clear();
DLIB_CASSERT(test2.size() == 0,""); DLIB_TEST(test2.size() == 0);
DLIB_CASSERT(test2.nr() == 0,""); DLIB_TEST(test2.nr() == 0);
DLIB_CASSERT(test2.nc() == 0,""); DLIB_TEST(test2.nc() == 0);
DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test2.at_start() == true,""); DLIB_TEST(test2.at_start() == true);
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.nc() == 0,""); DLIB_TEST(test.nc() == 0);
DLIB_CASSERT(test.nr() == 0,""); DLIB_TEST(test.nr() == 0);
test.set_size(nr,nc); test.set_size(nr,nc);
DLIB_CASSERT(test.size() == static_cast<unsigned long>(nc*nr),""); DLIB_TEST(test.size() == static_cast<unsigned long>(nc*nr));
DLIB_CASSERT(test.nc() == nc,""); DLIB_TEST(test.nc() == nc);
DLIB_CASSERT(test.nr() == nr,""); DLIB_TEST(test.nr() == nr);
...@@ -335,12 +335,12 @@ namespace ...@@ -335,12 +335,12 @@ namespace
test.clear(); test.clear();
test2.clear(); test2.clear();
DLIB_CASSERT(test.size() == 0,""); DLIB_TEST(test.size() == 0);
DLIB_CASSERT(test.nc() == 0,""); DLIB_TEST(test.nc() == 0);
DLIB_CASSERT(test.nr() == 0,""); DLIB_TEST(test.nr() == 0);
DLIB_CASSERT(test2.size() == 0,""); DLIB_TEST(test2.size() == 0);
DLIB_CASSERT(test2.nc() == 0,""); DLIB_TEST(test2.nc() == 0);
DLIB_CASSERT(test2.nr() == 0,""); DLIB_TEST(test2.nr() == 0);
test.set_size(10,10); test.set_size(10,10);
...@@ -356,20 +356,20 @@ namespace ...@@ -356,20 +356,20 @@ namespace
sin.str(sout.str()); sin.str(sout.str());
deserialize(test2,sin); deserialize(test2,sin);
DLIB_CASSERT(test2.size() == test.size(),""); DLIB_TEST(test2.size() == test.size());
DLIB_CASSERT(test2.nc() == test.nc(),""); DLIB_TEST(test2.nc() == test.nc());
DLIB_CASSERT(test2.nr() == test.nr(),""); DLIB_TEST(test2.nr() == test.nr());
DLIB_CASSERT(test2.size() == 100,""); DLIB_TEST(test2.size() == 100);
DLIB_CASSERT(test2.nc() == 10,""); DLIB_TEST(test2.nc() == 10);
DLIB_CASSERT(test2.nr() == 10,""); DLIB_TEST(test2.nr() == 10);
for (long row = 0; row < test.nr(); ++row) for (long row = 0; row < test.nr(); ++row)
{ {
for (long col = 0; col < test.nc(); ++col) for (long col = 0; col < test.nc(); ++col)
{ {
DLIB_CASSERT(test[row][col] == static_cast<unsigned long>(row*col),""); DLIB_TEST(test[row][col] == static_cast<unsigned long>(row*col));
DLIB_CASSERT(test2[row][col] == static_cast<unsigned long>(row*col),""); DLIB_TEST(test2[row][col] == static_cast<unsigned long>(row*col));
} }
} }
...@@ -379,11 +379,11 @@ namespace ...@@ -379,11 +379,11 @@ namespace
test.set_size(10,11); test.set_size(10,11);
DLIB_CASSERT(test.nr() == 10,""); DLIB_TEST(test.nr() == 10);
DLIB_CASSERT(test.nc() == 11,""); DLIB_TEST(test.nc() == 11);
test.set_size(0,0); test.set_size(0,0);
DLIB_CASSERT(test.nr() == 0,""); DLIB_TEST(test.nr() == 0);
DLIB_CASSERT(test.nc() == 0,""); DLIB_TEST(test.nc() == 0);
} }
......
...@@ -59,7 +59,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -59,7 +59,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(wiki_encoded); sin.str(wiki_encoded);
test.decode(sin,sout); test.decode(sin,sout);
DLIB_CASSERT(sout.str() == wiki_normal, DLIB_TEST_MSG(sout.str() == wiki_normal,
"sout.str(): " << sout.str() << "sout.str(): " << sout.str() <<
"\nwiki_normal: " << wiki_normal); "\nwiki_normal: " << wiki_normal);
...@@ -91,7 +91,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -91,7 +91,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
} }
sin.clear(); sin.clear();
DLIB_CASSERT(a == b, DLIB_TEST_MSG(a == b,
"a: \n" << a << "a: \n" << a <<
"\n\nb: \n" << b); "\n\nb: \n" << b);
...@@ -104,7 +104,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -104,7 +104,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str()); sin.str(sout.str());
sout.str(""); sout.str("");
test.decode(sin,sout); test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "",""); DLIB_TEST(sout.str() == "");
sin.clear(); sin.clear();
sin.str("a"); sin.str("a");
...@@ -113,7 +113,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -113,7 +113,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str()); sin.str(sout.str());
sout.str(""); sout.str("");
test.decode(sin,sout); test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "a",""); DLIB_TEST(sout.str() == "a");
sin.clear(); sin.clear();
sin.str("da"); sin.str("da");
...@@ -122,7 +122,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -122,7 +122,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str()); sin.str(sout.str());
sout.str(""); sout.str("");
test.decode(sin,sout); test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "da",""); DLIB_TEST(sout.str() == "da");
sin.clear(); sin.clear();
sin.str("dav"); sin.str("dav");
...@@ -131,7 +131,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -131,7 +131,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str()); sin.str(sout.str());
sout.str(""); sout.str("");
test.decode(sin,sout); test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "dav",""); DLIB_TEST(sout.str() == "dav");
sin.clear(); sin.clear();
sin.str("davi"); sin.str("davi");
...@@ -140,7 +140,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -140,7 +140,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str()); sin.str(sout.str());
sout.str(""); sout.str("");
test.decode(sin,sout); test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "davi",""); DLIB_TEST(sout.str() == "davi");
for (int i = 0; i < 1000; ++i) for (int i = 0; i < 1000; ++i)
...@@ -165,7 +165,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -165,7 +165,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sout.str(""); sout.str("");
test.decode(sin,sout); test.decode(sin,sout);
DLIB_CASSERT(str == sout.str(),""); DLIB_TEST(str == sout.str());
} }
...@@ -176,7 +176,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; ...@@ -176,7 +176,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
} }
catch (typename base64::decode_error& e) catch (typename base64::decode_error& e)
{ {
DLIB_CASSERT(false, DLIB_TEST_MSG(false,
"decode_error thrown when it shouldn't have been (" << seed << "):\n " "decode_error thrown when it shouldn't have been (" << seed << "):\n "
<< e.info); << e.info);
} }
......
...@@ -75,10 +75,10 @@ namespace ...@@ -75,10 +75,10 @@ namespace
ostringstream sout; ostringstream sout;
serialize(bn, sout); serialize(bn, sout);
bn.clear(); bn.clear();
DLIB_CASSERT(bn.number_of_nodes() == 0,""); DLIB_TEST(bn.number_of_nodes() == 0);
istringstream sin(sout.str()); istringstream sin(sout.str());
deserialize(bn, sin); deserialize(bn, sin);
DLIB_CASSERT(bn.number_of_nodes() == 3,""); DLIB_TEST(bn.number_of_nodes() == 3);
} }
...@@ -209,10 +209,10 @@ namespace ...@@ -209,10 +209,10 @@ namespace
ostringstream sout; ostringstream sout;
serialize(bn, sout); serialize(bn, sout);
bn.clear(); bn.clear();
DLIB_CASSERT(bn.number_of_nodes() == 0,""); DLIB_TEST(bn.number_of_nodes() == 0);
istringstream sin(sout.str()); istringstream sin(sout.str());
deserialize(bn, sin); deserialize(bn, sin);
DLIB_CASSERT(bn.number_of_nodes() == 8,""); DLIB_TEST(bn.number_of_nodes() == 8);
} }
...@@ -242,36 +242,36 @@ namespace ...@@ -242,36 +242,36 @@ namespace
matrix<double,1,2> dist; matrix<double,1,2> dist;
dist = solution.probability(A); dist = solution.probability(A);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.01 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.01 ) < 1e-5);
dist = solution.probability(T); dist = solution.probability(T);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.0104) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.0104) < 1e-5);
dist = solution.probability(O); dist = solution.probability(O);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.064828) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.064828) < 1e-5);
dist = solution.probability(X); dist = solution.probability(X);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.11029004) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.11029004) < 1e-5);
dist = solution.probability(L); dist = solution.probability(L);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.055) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.055) < 1e-5);
dist = solution.probability(S); dist = solution.probability(S);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.5) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.5) < 1e-5);
dist = solution.probability(B); dist = solution.probability(B);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.4499999) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.4499999) < 1e-5);
dist = solution.probability(D); dist = solution.probability(D);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.4359706 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.4359706 ) < 1e-5);
// now lets modify the probabilities of the bayesian network by making O // now lets modify the probabilities of the bayesian network by making O
// not a deterministic node anymore but otherwise leave the network alone // not a deterministic node anymore but otherwise leave the network alone
...@@ -287,39 +287,39 @@ namespace ...@@ -287,39 +287,39 @@ namespace
// reload the solution now that we have changed the probabilities of node O // reload the solution now that we have changed the probabilities of node O
bayesian_network_join_tree(bn, join_tree).swap(solution); bayesian_network_join_tree(bn, join_tree).swap(solution);
DLIB_CASSERT(solution.number_of_nodes() == bn.number_of_nodes(),""); DLIB_TEST(solution.number_of_nodes() == bn.number_of_nodes());
dist = solution.probability(A); dist = solution.probability(A);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 1.0 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 1.0 ) < 1e-5);
dist = solution.probability(T); dist = solution.probability(T);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.253508694039 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.253508694039 ) < 1e-5);
dist = solution.probability(O); dist = solution.probability(O);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.77856184024 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.77856184024 ) < 1e-5);
dist = solution.probability(X); dist = solution.probability(X);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 1.0 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 1.0 ) < 1e-5);
dist = solution.probability(L); dist = solution.probability(L);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.5070173880 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.5070173880 ) < 1e-5);
dist = solution.probability(S); dist = solution.probability(S);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 1.0 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 1.0 ) < 1e-5);
dist = solution.probability(B); dist = solution.probability(B);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.6 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.6 ) < 1e-5);
dist = solution.probability(D); dist = solution.probability(D);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.7535685520 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.7535685520 ) < 1e-5);
// now lets test the bayesian_network_gibbs_sampler // now lets test the bayesian_network_gibbs_sampler
...@@ -354,33 +354,33 @@ namespace ...@@ -354,33 +354,33 @@ namespace
counts /= rounds; counts /= rounds;
DLIB_CASSERT(abs(counts(A) - 1.0 ) < 1e-2,""); DLIB_TEST(abs(counts(A) - 1.0 ) < 1e-2);
DLIB_CASSERT(abs(counts(T) - 0.253508694039 ) < 1e-2,""); DLIB_TEST(abs(counts(T) - 0.253508694039 ) < 1e-2);
DLIB_CASSERT(abs(counts(O) - 0.77856184024 ) < 1e-2,abs(counts(O) - 0.77856184024 ) ); DLIB_TEST_MSG(abs(counts(O) - 0.77856184024 ) < 1e-2,abs(counts(O) - 0.77856184024 ) );
DLIB_CASSERT(abs(counts(X) - 1.0 ) < 1e-2,""); DLIB_TEST(abs(counts(X) - 1.0 ) < 1e-2);
DLIB_CASSERT(abs(counts(L) - 0.5070173880 ) < 1e-2,""); DLIB_TEST(abs(counts(L) - 0.5070173880 ) < 1e-2);
DLIB_CASSERT(abs(counts(S) - 1.0 ) < 1e-2,""); DLIB_TEST(abs(counts(S) - 1.0 ) < 1e-2);
DLIB_CASSERT(abs(counts(B) - 0.6 ) < 1e-2,""); DLIB_TEST(abs(counts(B) - 0.6 ) < 1e-2);
DLIB_CASSERT(abs(counts(D) - 0.7535685520 ) < 1e-2,""); DLIB_TEST(abs(counts(D) - 0.7535685520 ) < 1e-2);
setup_simple_network(bn); setup_simple_network(bn);
create_moral_graph(bn, join_tree); create_moral_graph(bn, join_tree);
create_join_tree(join_tree, join_tree); create_join_tree(join_tree, join_tree);
bayesian_network_join_tree(bn, join_tree).swap(solution); bayesian_network_join_tree(bn, join_tree).swap(solution);
DLIB_CASSERT(solution.number_of_nodes() == bn.number_of_nodes(),""); DLIB_TEST(solution.number_of_nodes() == bn.number_of_nodes());
dist = solution.probability(A); dist = solution.probability(A);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.1 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.1 ) < 1e-5);
dist = solution.probability(T); dist = solution.probability(T);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.5 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.5 ) < 1e-5);
dist = solution.probability(S); dist = solution.probability(S);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,""); DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_CASSERT(abs(dist(1) - 0.5 ) < 1e-5,""); DLIB_TEST(abs(dist(1) - 0.5 ) < 1e-5);
} }
......
...@@ -104,33 +104,33 @@ namespace ...@@ -104,33 +104,33 @@ namespace
bint i = 0; bint i = 0;
bint a(5), b, c(0); bint a(5), b, c(0);
DLIB_CASSERT(5 - a == 0,""); DLIB_TEST(5 - a == 0);
DLIB_CASSERT(a - 5 == 0,""); DLIB_TEST(a - 5 == 0);
DLIB_CASSERT(0 - c == 0,""); DLIB_TEST(0 - c == 0);
DLIB_CASSERT(c - 0 == 0,""); DLIB_TEST(c - 0 == 0);
DLIB_CASSERT(0 + c == 0,""); DLIB_TEST(0 + c == 0);
DLIB_CASSERT(c + 0 == 0,""); DLIB_TEST(c + 0 == 0);
DLIB_CASSERT(0 + a == 5,""); DLIB_TEST(0 + a == 5);
DLIB_CASSERT(a + 0 == 5,""); DLIB_TEST(a + 0 == 5);
DLIB_CASSERT(0 - b == 0,""); DLIB_TEST(0 - b == 0);
DLIB_CASSERT(b - 0 == 0,""); DLIB_TEST(b - 0 == 0);
DLIB_CASSERT(0 + b == 0,""); DLIB_TEST(0 + b == 0);
DLIB_CASSERT(b + 0 == 0,""); DLIB_TEST(b + 0 == 0);
DLIB_CASSERT(i == 0,""); DLIB_TEST(i == 0);
DLIB_CASSERT(a == 5,""); DLIB_TEST(a == 5);
DLIB_CASSERT(b == 0,""); DLIB_TEST(b == 0);
DLIB_CASSERT(c == 0,""); DLIB_TEST(c == 0);
a -= 5; a -= 5;
DLIB_CASSERT(a == 0,""); DLIB_TEST(a == 0);
...@@ -145,13 +145,13 @@ namespace ...@@ -145,13 +145,13 @@ namespace
// big int multiplication algorithm. // big int multiplication algorithm.
c = a*b; c = a*b;
// make sure a and b ended up being the same number // make sure a and b ended up being the same number
DLIB_CASSERT(a == b, DLIB_TEST_MSG(a == b,
"k: " << k << "\n" "k: " << k << "\n"
"short_fact: " << a << "\n" "short_fact: " << a << "\n"
"big_fact: " << b "big_fact: " << b
); );
// make sure c really is the square of the factorial of k // make sure c really is the square of the factorial of k
DLIB_CASSERT(short_fact_squared<bint>(k) == c,"k: " << k); DLIB_TEST_MSG(short_fact_squared<bint>(k) == c,"k: " << k);
print_spinner(); print_spinner();
} }
...@@ -161,12 +161,12 @@ namespace ...@@ -161,12 +161,12 @@ namespace
bint a = short_fact<bint>(k); bint a = short_fact<bint>(k);
bint b = big_fact<bint>(k); bint b = big_fact<bint>(k);
bint c = a*b; bint c = a*b;
DLIB_CASSERT(a == b, DLIB_TEST_MSG(a == b,
"k: " << k << "\n" "k: " << k << "\n"
"short_fact: " << a << "\n" "short_fact: " << a << "\n"
"big_fact: " << b "big_fact: " << b
); );
DLIB_CASSERT(short_fact_squared<bint>(k) == c,"k: " << k); DLIB_TEST_MSG(short_fact_squared<bint>(k) == c,"k: " << k);
print_spinner(); print_spinner();
} }
...@@ -175,25 +175,25 @@ namespace ...@@ -175,25 +175,25 @@ namespace
// test the << and >> operators a little // test the << and >> operators a little
a = big_fact<bint>(20); a = big_fact<bint>(20);
sout << a; sout << a;
DLIB_CASSERT( sout.str() == "2432902008176640000","was: " << a); DLIB_TEST_MSG( sout.str() == "2432902008176640000","was: " << a);
sin.str("684626312793279327952039475203945"); sin.str("684626312793279327952039475203945");
sin >> a; sin >> a;
sout.str(""); sout.str("");
sout << a; sout << a;
DLIB_CASSERT(sout.str() == "684626312793279327952039475203945",""); DLIB_TEST(sout.str() == "684626312793279327952039475203945");
print_spinner(); print_spinner();
DLIB_CASSERT(a > 0,""); DLIB_TEST(a > 0);
// make sure that when you try to read something that isn't a number // make sure that when you try to read something that isn't a number
// into a bigint you get an error // into a bigint you get an error
DLIB_CASSERT(sin.fail() == false, ""); DLIB_TEST(sin.fail() == false);
sin.str("the cat ate some cheese"); sin.str("the cat ate some cheese");
sin >> a; sin >> a;
DLIB_CASSERT(sin.fail() == true, ""); DLIB_TEST(sin.fail() == true);
sin.clear(); sin.clear();
sin.str(""); sin.str("");
...@@ -201,11 +201,11 @@ namespace ...@@ -201,11 +201,11 @@ namespace
sin.str("3628913"); sin.str("3628913");
sin >> i; sin >> i;
DLIB_CASSERT(short_fact<bint>(10) + short_fact<bint>(5) - 7 == i,""); DLIB_TEST(short_fact<bint>(10) + short_fact<bint>(5) - 7 == i);
sin.str("2432902008173011193"); sin.str("2432902008173011193");
sin >> i; sin >> i;
DLIB_CASSERT(short_fact<bint>(20) - short_fact<bint>(10) - 7 == i,""); DLIB_TEST(short_fact<bint>(20) - short_fact<bint>(10) - 7 == i);
// test the serialization stuff // test the serialization stuff
sout.str(""); sout.str("");
...@@ -214,7 +214,7 @@ namespace ...@@ -214,7 +214,7 @@ namespace
sin.str(sout.str()); sin.str(sout.str());
deserialize(i,sin); deserialize(i,sin);
DLIB_CASSERT(short_fact<bint>(20) - short_fact<bint>(10) - 7 == i,""); DLIB_TEST(short_fact<bint>(20) - short_fact<bint>(10) - 7 == i);
...@@ -228,7 +228,7 @@ namespace ...@@ -228,7 +228,7 @@ namespace
sin >> b; sin >> b;
a = b; a = b;
++b; ++b;
DLIB_CASSERT ( a + 1 == b,"a==" << a << endl << "b==" << b << endl); DLIB_TEST_MSG ( a + 1 == b,"a==" << a << endl << "b==" << b << endl);
...@@ -251,7 +251,7 @@ namespace ...@@ -251,7 +251,7 @@ namespace
if ((mel&0xFFF) == 0) if ((mel&0xFFF) == 0)
print_spinner(); print_spinner();
} }
DLIB_CASSERT(a == b*(b+1)/2, "a==" << a << endl << "b*(b+1)/2==" << b*(b+1)/2 << endl); DLIB_TEST_MSG(a == b*(b+1)/2, "a==" << a << endl << "b*(b+1)/2==" << b*(b+1)/2 << endl);
...@@ -268,8 +268,8 @@ namespace ...@@ -268,8 +268,8 @@ namespace
sin.str("100000"); sin.str("100000");
sin >> b; sin >> b;
i = b; i = b;
DLIB_CASSERT(i == b,""); DLIB_TEST(i == b);
DLIB_CASSERT(i > 0,"i==" << i); DLIB_TEST_MSG(i > 0,"i==" << i);
mel = 0; mel = 0;
for (i = b; i > 0; --i) for (i = b; i > 0; --i)
{ {
...@@ -282,7 +282,7 @@ namespace ...@@ -282,7 +282,7 @@ namespace
if ((mel&0xFF) == 0) if ((mel&0xFF) == 0)
print_spinner(); print_spinner();
} }
DLIB_CASSERT(a == b*(b+1)/2, "a==" << a << endl << "b*(b+1)/2==" << b*(b+1)/2 << endl); DLIB_TEST_MSG(a == b*(b+1)/2, "a==" << a << endl << "b*(b+1)/2==" << b*(b+1)/2 << endl);
...@@ -294,22 +294,22 @@ namespace ...@@ -294,22 +294,22 @@ namespace
DLIB_CASSERT(short_fact<bint>(10)/short_fact<bint>(5) == 30240,""); DLIB_TEST(short_fact<bint>(10)/short_fact<bint>(5) == 30240);
DLIB_CASSERT(short_fact<bint>(10)/(short_fact<bint>(5)+1) == 29990,""); DLIB_TEST(short_fact<bint>(10)/(short_fact<bint>(5)+1) == 29990);
sin.str("221172909834240000"); sin.str("221172909834240000");
sin >> a; sin >> a;
DLIB_CASSERT(short_fact<bint>(20)/(short_fact<bint>(5)+1) == a/11,""); DLIB_TEST(short_fact<bint>(20)/(short_fact<bint>(5)+1) == a/11);
sin.str("670442388044"); sin.str("670442388044");
sin >> b; sin >> b;
DLIB_CASSERT(short_fact<bint>(20)/(short_fact<bint>(10)+1) == b,""); DLIB_TEST(short_fact<bint>(20)/(short_fact<bint>(10)+1) == b);
print_spinner(); print_spinner();
sin.str("1860479"); sin.str("1860479");
sin >> i; sin >> i;
DLIB_CASSERT(short_fact<bint>(20)/(short_fact<bint>(15)+1) == i,short_fact<bint>(20)/(short_fact<bint>(15)+1)); DLIB_TEST_MSG(short_fact<bint>(20)/(short_fact<bint>(15)+1) == i,short_fact<bint>(20)/(short_fact<bint>(15)+1));
// test the serialization stuff // test the serialization stuff
sout.str(""); sout.str("");
...@@ -318,7 +318,7 @@ namespace ...@@ -318,7 +318,7 @@ namespace
sin.str(sout.str()); sin.str(sout.str());
deserialize(i,sin); deserialize(i,sin);
DLIB_CASSERT(short_fact<bint>(20)/(short_fact<bint>(15)+1) == i,short_fact<bint>(20)/(short_fact<bint>(15)+1)); DLIB_TEST_MSG(short_fact<bint>(20)/(short_fact<bint>(15)+1) == i,short_fact<bint>(20)/(short_fact<bint>(15)+1));
print_spinner(); print_spinner();
...@@ -330,28 +330,28 @@ namespace ...@@ -330,28 +330,28 @@ namespace
i = 1234; i = 1234;
sin.str(sout.str()); sin.str(sout.str());
deserialize(i,sin); deserialize(i,sin);
DLIB_CASSERT(i == 0,""); DLIB_TEST(i == 0);
DLIB_CASSERT(short_fact<bint>(10000)/short_fact<bint>(9999) == 10000,""); DLIB_TEST(short_fact<bint>(10000)/short_fact<bint>(9999) == 10000);
DLIB_CASSERT(bint(5)%bint(1) == 0,""); DLIB_TEST(bint(5)%bint(1) == 0);
DLIB_CASSERT(bint(5)%bint(6) == 5,""); DLIB_TEST(bint(5)%bint(6) == 5);
DLIB_CASSERT(bint(25)%bint(6) == 1,""); DLIB_TEST(bint(25)%bint(6) == 1);
print_spinner(); print_spinner();
DLIB_CASSERT(bint(354)%bint(123) == 108,""); DLIB_TEST(bint(354)%bint(123) == 108);
DLIB_CASSERT(bint(20)%(bint(10)) == 0,""); DLIB_TEST(bint(20)%(bint(10)) == 0);
DLIB_CASSERT(bint(20)%(bint(10)+1) == 9,""); DLIB_TEST(bint(20)%(bint(10)+1) == 9);
DLIB_CASSERT(bint(20)%(bint(15)+1) == 4,""); DLIB_TEST(bint(20)%(bint(15)+1) == 4);
DLIB_CASSERT(short_fact<bint>(10)%(short_fact<bint>(5)+2) == 32,""); DLIB_TEST(short_fact<bint>(10)%(short_fact<bint>(5)+2) == 32);
sin.str("2908082"); sin.str("2908082");
sin >> i; sin >> i;
DLIB_CASSERT(short_fact<bint>(15)%(short_fact<bint>(10)+2) == i,""); DLIB_TEST(short_fact<bint>(15)%(short_fact<bint>(10)+2) == i);
...@@ -360,34 +360,34 @@ namespace ...@@ -360,34 +360,34 @@ namespace
// same as some of the above stuff but using big_fact // same as some of the above stuff but using big_fact
DLIB_CASSERT(big_fact<bint>(10)%(big_fact<bint>(5)+2) == 32,""); DLIB_TEST(big_fact<bint>(10)%(big_fact<bint>(5)+2) == 32);
sin.str("2908082"); sin.str("2908082");
sin >> i; sin >> i;
DLIB_CASSERT(big_fact<bint>(15)%(big_fact<bint>(10)+2) == i,""); DLIB_TEST(big_fact<bint>(15)%(big_fact<bint>(10)+2) == i);
print_spinner(); print_spinner();
DLIB_CASSERT(big_fact<bint>(10)/big_fact<bint>(5) == 30240,""); DLIB_TEST(big_fact<bint>(10)/big_fact<bint>(5) == 30240);
DLIB_CASSERT(big_fact<bint>(10)/(big_fact<bint>(5)+1) == 29990,""); DLIB_TEST(big_fact<bint>(10)/(big_fact<bint>(5)+1) == 29990);
sin.str("221172909834240000"); sin.str("221172909834240000");
sin >> a; sin >> a;
DLIB_CASSERT(big_fact<bint>(20)/(big_fact<bint>(5)+1) == a/11,""); DLIB_TEST(big_fact<bint>(20)/(big_fact<bint>(5)+1) == a/11);
sin.str("670442388044"); sin.str("670442388044");
sin >> b; sin >> b;
DLIB_CASSERT(big_fact<bint>(20)/(big_fact<bint>(10)+1) == b,""); DLIB_TEST(big_fact<bint>(20)/(big_fact<bint>(10)+1) == b);
sin.str("1860479"); sin.str("1860479");
sin >> i; sin >> i;
DLIB_CASSERT(big_fact<bint>(20)/(big_fact<bint>(15)+1) == i,big_fact<bint>(20)/(big_fact<bint>(15)+1)); DLIB_TEST_MSG(big_fact<bint>(20)/(big_fact<bint>(15)+1) == i,big_fact<bint>(20)/(big_fact<bint>(15)+1));
DLIB_CASSERT(big_fact<bint>(100)/big_fact<bint>(99) == 100,""); DLIB_TEST(big_fact<bint>(100)/big_fact<bint>(99) == 100);
...@@ -414,7 +414,7 @@ namespace ...@@ -414,7 +414,7 @@ namespace
sin.str(sout.str()); sin.str(sout.str());
sin >> c; sin >> c;
DLIB_CASSERT(a*b == c, DLIB_TEST_MSG(a*b == c,
"a*b: " << a*b << "a*b: " << a*b <<
"\nc: " << c); "\nc: " << c);
...@@ -426,50 +426,50 @@ namespace ...@@ -426,50 +426,50 @@ namespace
unsigned long j; unsigned long j;
for (j = 0; i < bint(100000); ++j) for (j = 0; i < bint(100000); ++j)
{ {
DLIB_CASSERT(i++ == bint(j),""); DLIB_TEST(i++ == bint(j));
++mel; ++mel;
if((mel&0xFF) == 0) if((mel&0xFF) == 0)
print_spinner(); print_spinner();
} }
DLIB_CASSERT(j == 100000,""); DLIB_TEST(j == 100000);
i = 1234; i = 1234;
DLIB_CASSERT(i == 1234,""); DLIB_TEST(i == 1234);
DLIB_CASSERT(i < 2345 ,""); DLIB_TEST(i < 2345 );
DLIB_CASSERT(i > 0 ,""); DLIB_TEST(i > 0 );
DLIB_CASSERT(i > 123 ,""); DLIB_TEST(i > 123 );
DLIB_CASSERT(i != 1334,""); DLIB_TEST(i != 1334);
DLIB_CASSERT(i <= 2345,""); DLIB_TEST(i <= 2345);
DLIB_CASSERT(i >= 0 ,""); DLIB_TEST(i >= 0 );
DLIB_CASSERT(i >= 123 ,""); DLIB_TEST(i >= 123 );
DLIB_CASSERT(i >= 1234,""); DLIB_TEST(i >= 1234);
DLIB_CASSERT(i <= 1234,""); DLIB_TEST(i <= 1234);
DLIB_CASSERT(1234 == i,""); DLIB_TEST(1234 == i);
DLIB_CASSERT(2345 > i,""); DLIB_TEST(2345 > i);
DLIB_CASSERT(0 < i,""); DLIB_TEST(0 < i);
DLIB_CASSERT(123 < i,""); DLIB_TEST(123 < i);
DLIB_CASSERT(1334 != i,""); DLIB_TEST(1334 != i);
DLIB_CASSERT(2345 >= i,""); DLIB_TEST(2345 >= i);
DLIB_CASSERT(0 <= i,""); DLIB_TEST(0 <= i);
DLIB_CASSERT(123 <= i,""); DLIB_TEST(123 <= i);
DLIB_CASSERT(1234 <= i,""); DLIB_TEST(1234 <= i);
DLIB_CASSERT(1234 >= i,""); DLIB_TEST(1234 >= i);
a = big_fact<bint>(200); a = big_fact<bint>(200);
b = big_fact<bint>(100); b = big_fact<bint>(100);
DLIB_CASSERT(a > b, ""); DLIB_TEST(a > b);
DLIB_CASSERT(a != b, ""); DLIB_TEST(a != b);
DLIB_CASSERT(b < a, ""); DLIB_TEST(b < a);
DLIB_CASSERT(b != a, ""); DLIB_TEST(b != a);
DLIB_CASSERT(b <= a, ""); DLIB_TEST(b <= a);
DLIB_CASSERT(a >= b, ""); DLIB_TEST(a >= b);
......
This diff is collapsed.
This diff is collapsed.
...@@ -82,7 +82,7 @@ namespace ...@@ -82,7 +82,7 @@ namespace
} }
DLIB_CASSERT(detected_error || sout.str() == old_buffer,(unsigned int)sout.str().size()); DLIB_TEST_MSG(detected_error || sout.str() == old_buffer,(unsigned int)sout.str().size());
...@@ -116,7 +116,7 @@ namespace ...@@ -116,7 +116,7 @@ namespace
sin.str(sout.str()); sin.str(sout.str());
sout.str(""); sout.str("");
test.decompress(sin,sout); test.decompress(sin,sout);
DLIB_CASSERT(sout.str() == buffer,""); DLIB_TEST(sout.str() == buffer);
} }
print_spinner(); print_spinner();
...@@ -153,7 +153,7 @@ namespace ...@@ -153,7 +153,7 @@ namespace
sout.str(""); sout.str("");
test.decompress(sin,sout); test.decompress(sin,sout);
buffer = ch; buffer = ch;
DLIB_CASSERT(sout.str() == buffer,""); DLIB_TEST(sout.str() == buffer);
...@@ -161,7 +161,7 @@ namespace ...@@ -161,7 +161,7 @@ namespace
sout.str(""); sout.str("");
test.decompress(sin,sout); test.decompress(sin,sout);
buffer = ch2; buffer = ch2;
DLIB_CASSERT(sout.str() == buffer,""); DLIB_TEST(sout.str() == buffer);
} }
...@@ -175,7 +175,7 @@ namespace ...@@ -175,7 +175,7 @@ namespace
sin.str(sout.str()); sin.str(sout.str());
sout.str(""); sout.str("");
test.decompress(sin,sout); test.decompress(sin,sout);
DLIB_CASSERT(sout.str() == "",sout.str()); DLIB_TEST_MSG(sout.str() == "",sout.str());
...@@ -206,7 +206,7 @@ namespace ...@@ -206,7 +206,7 @@ namespace
print_spinner(); print_spinner();
test.decompress(sin,sout); test.decompress(sin,sout);
DLIB_CASSERT(sout.str() == buffer,""); DLIB_TEST(sout.str() == buffer);
print_spinner(); print_spinner();
} }
...@@ -247,7 +247,7 @@ namespace ...@@ -247,7 +247,7 @@ namespace
print_spinner(); print_spinner();
test.decompress(sin,sout); test.decompress(sin,sout);
DLIB_CASSERT(sout.str() == buffer,""); DLIB_TEST(sout.str() == buffer);
print_spinner(); print_spinner();
......
This diff is collapsed.
...@@ -27,36 +27,36 @@ namespace ...@@ -27,36 +27,36 @@ namespace
config_reader& cr config_reader& cr
) )
{ {
DLIB_CASSERT(cr.is_key_defined("global"),""); DLIB_TEST(cr.is_key_defined("global"));
DLIB_CASSERT(cr.is_block_defined("all"),""); DLIB_TEST(cr.is_block_defined("all"));
DLIB_CASSERT(cr.is_key_defined("globalasfd") == false,""); DLIB_TEST(cr.is_key_defined("globalasfd") == false);
DLIB_CASSERT(cr.is_block_defined("all!") == false,""); DLIB_TEST(cr.is_block_defined("all!") == false);
DLIB_CASSERT(cr.size() == 1,""); DLIB_TEST(cr.size() == 1);
DLIB_CASSERT(cr["global"] == "hmm",""); DLIB_TEST(cr["global"] == "hmm");
DLIB_CASSERT(cr["global2"] == "hmm2",""); DLIB_TEST(cr["global2"] == "hmm2");
DLIB_CASSERT(cr.block("all").size() == 4,""); DLIB_TEST(cr.block("all").size() == 4);
DLIB_CASSERT(cr.block("all").block("block1").size() == 0,""); DLIB_TEST(cr.block("all").block("block1").size() == 0);
DLIB_CASSERT(cr.block("all").block("block2").size() == 0,""); DLIB_TEST(cr.block("all").block("block2").size() == 0);
DLIB_CASSERT(cr.block("all").block("block3").size() == 0,""); DLIB_TEST(cr.block("all").block("block3").size() == 0);
DLIB_CASSERT(cr.block("all").block("block4").size() == 0,""); DLIB_TEST(cr.block("all").block("block4").size() == 0);
DLIB_CASSERT(cr.block("all").block("block1").is_key_defined("name"),""); DLIB_TEST(cr.block("all").block("block1").is_key_defined("name"));
DLIB_CASSERT(cr.block("all").block("block2").is_key_defined("name"),""); DLIB_TEST(cr.block("all").block("block2").is_key_defined("name"));
DLIB_CASSERT(cr.block("all").block("block3").is_key_defined("name"),""); DLIB_TEST(cr.block("all").block("block3").is_key_defined("name"));
DLIB_CASSERT(cr.block("all").block("block4").is_key_defined("name"),""); DLIB_TEST(cr.block("all").block("block4").is_key_defined("name"));
DLIB_CASSERT(cr.block("all").block("block1").is_key_defined("age"),""); DLIB_TEST(cr.block("all").block("block1").is_key_defined("age"));
DLIB_CASSERT(cr.block("all").block("block2").is_key_defined("age"),""); DLIB_TEST(cr.block("all").block("block2").is_key_defined("age"));
DLIB_CASSERT(cr.block("all").block("block3").is_key_defined("age"),""); DLIB_TEST(cr.block("all").block("block3").is_key_defined("age"));
DLIB_CASSERT(cr.block("all").block("block4").is_key_defined("age"),""); DLIB_TEST(cr.block("all").block("block4").is_key_defined("age"));
DLIB_CASSERT(cr.block("all").block("block1")["name"] == "davis king",""); DLIB_TEST(cr.block("all").block("block1")["name"] == "davis king");
DLIB_CASSERT(cr.block("all").block("block2")["name"] == "joel",""); DLIB_TEST(cr.block("all").block("block2")["name"] == "joel");
DLIB_CASSERT(cr.block("all").block("block3")["name"] == "john",""); DLIB_TEST(cr.block("all").block("block3")["name"] == "john");
DLIB_CASSERT(cr.block("all").block("block4")["name"] == "dude",""); DLIB_TEST(cr.block("all").block("block4")["name"] == "dude");
DLIB_CASSERT(cr.block("all").block("block1")["age"] == "24",""); DLIB_TEST(cr.block("all").block("block1")["age"] == "24");
DLIB_CASSERT(cr.block("all").block("block2")["age"] == "24",""); DLIB_TEST(cr.block("all").block("block2")["age"] == "24");
DLIB_CASSERT(cr.block("all").block("block3")["age"] == "24",""); DLIB_TEST(cr.block("all").block("block3")["age"] == "24");
DLIB_CASSERT(cr.block("all").block("block4")["age"] == "53",""); DLIB_TEST(cr.block("all").block("block4")["age"] == "53");
int count1 = 0; int count1 = 0;
...@@ -64,26 +64,26 @@ namespace ...@@ -64,26 +64,26 @@ namespace
while (cr.move_next()) while (cr.move_next())
{ {
++count1; ++count1;
DLIB_CASSERT(cr.current_block_name() == "all",""); DLIB_TEST(cr.current_block_name() == "all");
DLIB_CASSERT(cr.element().is_key_defined("global") == false,""); DLIB_TEST(cr.element().is_key_defined("global") == false);
DLIB_CASSERT(cr.element().is_key_defined("global2") == false,""); DLIB_TEST(cr.element().is_key_defined("global2") == false);
DLIB_CASSERT(cr.element().is_key_defined("name") == false,""); DLIB_TEST(cr.element().is_key_defined("name") == false);
DLIB_CASSERT(cr.element().is_key_defined("age") == false,""); DLIB_TEST(cr.element().is_key_defined("age") == false);
while (cr.element().move_next()) while (cr.element().move_next())
{ {
++count2; ++count2;
ostringstream sout; ostringstream sout;
sout << "block" << count2; sout << "block" << count2;
DLIB_CASSERT(cr.element().current_block_name() == sout.str(),""); DLIB_TEST(cr.element().current_block_name() == sout.str());
DLIB_CASSERT(cr.element().size() == 4,""); DLIB_TEST(cr.element().size() == 4);
DLIB_CASSERT(cr.element().element().size() == 0,""); DLIB_TEST(cr.element().element().size() == 0);
DLIB_CASSERT(cr.element().element().is_key_defined("name"),""); DLIB_TEST(cr.element().element().is_key_defined("name"));
DLIB_CASSERT(cr.element().element().is_key_defined("age"),""); DLIB_TEST(cr.element().element().is_key_defined("age"));
} }
} }
DLIB_CASSERT(count1 == 1,""); DLIB_TEST(count1 == 1);
DLIB_CASSERT(count2 == 4,""); DLIB_TEST(count2 == 4);
} }
...@@ -163,8 +163,8 @@ namespace ...@@ -163,8 +163,8 @@ namespace
do_the_tests(cr2); do_the_tests(cr2);
cr.clear(); cr.clear();
DLIB_CASSERT(cr.size() == 0,""); DLIB_TEST(cr.size() == 0);
DLIB_CASSERT(cr.is_key_defined("global") == false,""); DLIB_TEST(cr.is_key_defined("global") == false);
} }
...@@ -215,10 +215,10 @@ namespace ...@@ -215,10 +215,10 @@ namespace
catch (typename config_reader::config_reader_error& e) catch (typename config_reader::config_reader_error& e)
{ {
error_found = true; error_found = true;
DLIB_CASSERT(e.line_number == 16,""); DLIB_TEST(e.line_number == 16);
DLIB_CASSERT(e.redefinition == false,""); DLIB_TEST(e.redefinition == false);
} }
DLIB_CASSERT(error_found,""); DLIB_TEST(error_found);
} }
{ {
...@@ -268,10 +268,10 @@ namespace ...@@ -268,10 +268,10 @@ namespace
catch (typename config_reader::config_reader_error& e) catch (typename config_reader::config_reader_error& e)
{ {
error_found = true; error_found = true;
DLIB_CASSERT(e.line_number == 31,e.line_number); DLIB_TEST_MSG(e.line_number == 31,e.line_number);
DLIB_CASSERT(e.redefinition == true,""); DLIB_TEST(e.redefinition == true);
} }
DLIB_CASSERT(error_found,""); DLIB_TEST(error_found);
} }
...@@ -321,10 +321,10 @@ namespace ...@@ -321,10 +321,10 @@ namespace
catch (typename config_reader::config_reader_error& e) catch (typename config_reader::config_reader_error& e)
{ {
error_found = true; error_found = true;
DLIB_CASSERT(e.line_number == 13,e.line_number); DLIB_TEST_MSG(e.line_number == 13,e.line_number);
DLIB_CASSERT(e.redefinition == true,""); DLIB_TEST(e.redefinition == true);
} }
DLIB_CASSERT(error_found,""); DLIB_TEST(error_found);
} }
......
This diff is collapsed.
...@@ -59,12 +59,12 @@ namespace ...@@ -59,12 +59,12 @@ namespace
DLIB_CASSERT(e.stream_is_set() == false,""); DLIB_TEST(e.stream_is_set() == false);
e.set_stream(sout); e.set_stream(sout);
DLIB_CASSERT(e.stream_is_set() == true,""); DLIB_TEST(e.stream_is_set() == true);
DLIB_CASSERT(&e.get_stream() == &sout,""); DLIB_TEST(&e.get_stream() == &sout);
unsigned char ch; unsigned char ch;
...@@ -98,14 +98,14 @@ namespace ...@@ -98,14 +98,14 @@ namespace
counts[ch] += 1; counts[ch] += 1;
} }
DLIB_CASSERT(e.stream_is_set() == true,""); DLIB_TEST(e.stream_is_set() == true);
DLIB_CASSERT(&e.get_stream() == &sout,""); DLIB_TEST(&e.get_stream() == &sout);
e.clear(); e.clear();
DLIB_CASSERT(e.stream_is_set() == false,""); DLIB_TEST(e.stream_is_set() == false);
// ***************************************** // *****************************************
...@@ -114,18 +114,18 @@ namespace ...@@ -114,18 +114,18 @@ namespace
decoder d; decoder d;
DLIB_CASSERT(d.stream_is_set() == false,""); DLIB_TEST(d.stream_is_set() == false);
DLIB_CASSERT(d.get_target_called() == false,""); DLIB_TEST(d.get_target_called() == false);
sin.str(sout.str()); sin.str(sout.str());
sout.str(""); sout.str("");
d.set_stream(sin); d.set_stream(sin);
DLIB_CASSERT(d.get_target_called() == false,""); DLIB_TEST(d.get_target_called() == false);
DLIB_CASSERT(d.stream_is_set() == true,""); DLIB_TEST(d.stream_is_set() == true);
DLIB_CASSERT(&d.get_stream() == &sin,""); DLIB_TEST(&d.get_stream() == &sin);
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {
...@@ -149,13 +149,13 @@ namespace ...@@ -149,13 +149,13 @@ namespace
} }
} }
DLIB_CASSERT(d.get_target_called() == false,""); DLIB_TEST(d.get_target_called() == false);
unsigned long target = d.get_target(total); unsigned long target = d.get_target(total);
DLIB_CASSERT(target < total,""); DLIB_TEST(target < total);
DLIB_CASSERT(d.get_target_called() == true,""); DLIB_TEST(d.get_target_called() == true);
unsigned long low_count; unsigned long low_count;
...@@ -178,19 +178,19 @@ namespace ...@@ -178,19 +178,19 @@ namespace
d.decode(low_count,high_count); d.decode(low_count,high_count);
DLIB_CASSERT(d.get_target_called() == false,""); DLIB_TEST(d.get_target_called() == false);
++total; ++total;
counts[ch] += 1; counts[ch] += 1;
} }
DLIB_CASSERT(d.stream_is_set() == true,""); DLIB_TEST(d.stream_is_set() == true);
DLIB_CASSERT(&d.get_stream() == &sin,""); DLIB_TEST(&d.get_stream() == &sin);
d.clear(); d.clear();
DLIB_CASSERT(d.stream_is_set() == false,""); DLIB_TEST(d.stream_is_set() == false);
DLIB_CASSERT(sout.str().size() == input.size(),"the test script is buggy"); DLIB_TEST_MSG(sout.str().size() == input.size(),"the test script is buggy");
if (sout.str() == input) if (sout.str() == input)
...@@ -264,7 +264,7 @@ namespace ...@@ -264,7 +264,7 @@ namespace
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
{ {
unsigned long N = d.get_target(total[i]); unsigned long N = d.get_target(total[i]);
DLIB_CASSERT(low_count[i] <= N && N < high_count[i],""); DLIB_TEST(low_count[i] <= N && N < high_count[i]);
d.decode(low_count[i],high_count[i]); d.decode(low_count[i],high_count[i]);
} }
...@@ -273,13 +273,13 @@ namespace ...@@ -273,13 +273,13 @@ namespace
DLIB_CASSERT(sin.rdbuf()->sgetc() != EOF,"num: " << num); DLIB_TEST_MSG(sin.rdbuf()->sgetc() != EOF,"num: " << num);
DLIB_CASSERT(sin.rdbuf()->sgetc() == 'a', DLIB_TEST_MSG(sin.rdbuf()->sgetc() == 'a',
"sin.rdbuf()->sgetc() == " << (char)sin.rdbuf()->sgetc() << "sin.rdbuf()->sgetc() == " << (char)sin.rdbuf()->sgetc() <<
"\nnum: " << num "\nnum: " << num
); );
DLIB_CASSERT(sin.rdbuf()->sbumpc() == 'a',""); DLIB_TEST(sin.rdbuf()->sbumpc() == 'a');
DLIB_CASSERT(sin.rdbuf()->sgetc() == EOF,""); DLIB_TEST(sin.rdbuf()->sgetc() == EOF);
} // for (int k = 0; k < 10000; ++k) } // for (int k = 0; k < 10000; ++k)
...@@ -298,7 +298,7 @@ namespace ...@@ -298,7 +298,7 @@ namespace
d.set_stream(sin); d.set_stream(sin);
unsigned long total = ::rand()%256 + 20; unsigned long total = ::rand()%256 + 20;
unsigned long target = d.get_target(total); unsigned long target = d.get_target(total);
DLIB_CASSERT(target<total,""); DLIB_TEST(target<total);
for (int i = 0; i < 30; ++i) for (int i = 0; i < 30; ++i)
{ {
...@@ -311,7 +311,7 @@ namespace ...@@ -311,7 +311,7 @@ namespace
d.decode(low_count,high_count); d.decode(low_count,high_count);
target = d.get_target(total); target = d.get_target(total);
DLIB_CASSERT(target<total,"target: " << target << " total: " << total); DLIB_TEST_MSG(target<total,"target: " << target << " total: " << total);
} }
} }
...@@ -365,12 +365,12 @@ namespace ...@@ -365,12 +365,12 @@ namespace
{ {
int k = 0; int k = 0;
DLIB_CASSERT(temp != temp2,""); DLIB_TEST(temp != temp2);
while (temp[k] == temp2[k])++k; while (temp[k] == temp2[k])++k;
} }
DLIB_CASSERT(temp2 == "","") DLIB_TEST_MSG(temp2 == "","")
} }
} }
...@@ -395,7 +395,7 @@ namespace ...@@ -395,7 +395,7 @@ namespace
string::size_type pos = temp.find_first_not_of("e"); string::size_type pos = temp.find_first_not_of("e");
temp = temp.substr(pos); temp = temp.substr(pos);
} }
DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"") /**/ DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"") /**/
dlog << LTRACE << 5; dlog << LTRACE << 5;
...@@ -403,16 +403,16 @@ namespace ...@@ -403,16 +403,16 @@ namespace
print_spinner(); print_spinner();
temp = "davis"; temp = "davis";
temp = test<encoder,decoder>(temp); DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"") temp = test<encoder,decoder>(temp); DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"")
temp = ""; temp = "";
temp = test<encoder,decoder>(temp); DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"") temp = test<encoder,decoder>(temp); DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"")
// test for each single character // test for each single character
for ( int i = 0; i <= 255; ++i) for ( int i = 0; i <= 255; ++i)
{ {
temp = (unsigned char)i; temp = (unsigned char)i;
temp = test<encoder,decoder>(temp); DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"") temp = test<encoder,decoder>(temp); DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"")
} }
dlog << LTRACE << 6; dlog << LTRACE << 6;
...@@ -423,7 +423,7 @@ namespace ...@@ -423,7 +423,7 @@ namespace
{ {
temp = temp + temp; temp = temp + temp;
} }
temp = test<encoder,decoder>(temp); DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"") temp = test<encoder,decoder>(temp); DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"")
dlog << LTRACE << 7; dlog << LTRACE << 7;
...@@ -437,7 +437,7 @@ namespace ...@@ -437,7 +437,7 @@ namespace
int a = ::rand()%256; int a = ::rand()%256;
temp += (unsigned char)a; temp += (unsigned char)a;
} }
temp = test<encoder,decoder>(temp); DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"") temp = test<encoder,decoder>(temp); DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"")
} }
...@@ -457,7 +457,7 @@ namespace ...@@ -457,7 +457,7 @@ namespace
int a = ::rand()%256; int a = ::rand()%256;
temp += (unsigned char)a; temp += (unsigned char)a;
} }
temp = test<encoder,decoder>(temp); DLIB_CASSERT(temp == "","seed: " << seed) temp = test<encoder,decoder>(temp); DLIB_TEST_MSG(temp == "","seed: " << seed)
} }
...@@ -478,7 +478,7 @@ namespace ...@@ -478,7 +478,7 @@ namespace
string::size_type pos = temp.find_first_not_of(" "); string::size_type pos = temp.find_first_not_of(" ");
temp = temp.substr(pos); temp = temp.substr(pos);
} }
DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"")/**/ DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"")/**/
...@@ -504,7 +504,7 @@ namespace ...@@ -504,7 +504,7 @@ namespace
temp += temp2; temp += temp2;
print_spinner(); print_spinner();
temp = test<encoder,decoder>(temp); temp = test<encoder,decoder>(temp);
DLIB_CASSERT(temp == "",""); DLIB_TEST(temp == "");
......
This diff is collapsed.
...@@ -41,14 +41,17 @@ namespace ...@@ -41,14 +41,17 @@ namespace
dlog << dlib::LINFO << "some message you want to log"; dlog << dlib::LINFO << "some message you want to log";
// This test is considered a success if this function doesn't throw an exception. // This test is considered a success if this function doesn't throw an exception.
// So we can use the DLIB_CASSERT macro to perform our tests since it throws an // So we can use the DLIB_TEST_MSG macro to perform our tests since it throws an
// exception containing a message if its first argument is false. // exception containing a message if its first argument is false.
// make sure 3 is bigger than 2 // make sure 3 is bigger than 2
DLIB_CASSERT(3 > 2,"This message prints if your compiler doesn't know 3 is bigger than 2"); DLIB_TEST_MSG(3 > 2,"This message prints if your compiler doesn't know 3 is bigger than 2");
// make sure 5 is not equal to 9 // make sure 5 is not equal to 9
DLIB_CASSERT(5 != 9,"This message prints if your compiler thinks 5 is the same as 9"); DLIB_TEST_MSG(5 != 9,"This message prints if your compiler thinks 5 is the same as 9");
// This is a form of test you can use when you don't care about haivng a message
DLIB_TEST(5 != 8);
// If your test takes a long time to run you can also call print_spinner() // If your test takes a long time to run you can also call print_spinner()
// periodically. This will cause a spinning / character to display on the // periodically. This will cause a spinning / character to display on the
......
...@@ -46,14 +46,14 @@ namespace ...@@ -46,14 +46,14 @@ namespace
dlog << dlib::LINFO << "the argument passed to this test was " << arg; dlog << dlib::LINFO << "the argument passed to this test was " << arg;
// This test is considered a success if this function doesn't throw an exception. // This test is considered a success if this function doesn't throw an exception.
// So we can use the DLIB_CASSERT macro to perform our tests since it throws an // So we can use the DLIB_TEST_MSG macro to perform our tests since it throws an
// exception containing a message if its first argument is false. // exception containing a message if its first argument is false.
// make sure 3 is bigger than 2 // make sure 3 is bigger than 2
DLIB_CASSERT(3 > 2,"This message prints if your compiler doesn't know 3 is bigger than 2"); DLIB_TEST_MSG(3 > 2,"This message prints if your compiler doesn't know 3 is bigger than 2");
// make sure 5 is not equal to 9 // make sure 5 is not equal to 9
DLIB_CASSERT(5 != 9,"This message prints if your compiler thinks 5 is the same as 9"); DLIB_TEST_MSG(5 != 9,"This message prints if your compiler thinks 5 is the same as 9");
// If your test takes a long time to run you can also call print_spinner() // If your test takes a long time to run you can also call print_spinner()
// periodically. This will cause a spinning / character to display on the // periodically. This will cause a spinning / character to display on the
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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