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
......@@ -51,53 +51,53 @@ namespace
for (unsigned long j = 0; j < a1.size(); ++j)
{
a1[j] = j;
DLIB_CASSERT(a1[j] == j,"");
DLIB_TEST(a1[j] == j);
}
}
}
}
DLIB_CASSERT(a1.max_size() == 0,"");
DLIB_CASSERT(a2.max_size() == 0,"");
DLIB_TEST(a1.max_size() == 0);
DLIB_TEST(a2.max_size() == 0);
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start(),"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start());
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.size() == 0);
swap(a1,a2);
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a2.current_element_valid() == false,"");
DLIB_CASSERT(a2.at_start() == false,"");
DLIB_CASSERT(a2.move_next() == false,"");
DLIB_CASSERT(a2.current_element_valid() == false,"");
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a2.at_start() == false,"");
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start(),"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a2.current_element_valid() == false);
DLIB_TEST(a2.at_start() == false);
DLIB_TEST(a2.move_next() == false);
DLIB_TEST(a2.current_element_valid() == false);
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a2.at_start() == false);
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start());
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.size() == 0);
a1.reset();
a2.reset();
......@@ -105,85 +105,85 @@ namespace
for (unsigned long k = 0; k < 4; ++k)
{
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start(),"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start());
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.size() == 0);
swap(a1,a2);
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a2.current_element_valid() == false,"");
DLIB_CASSERT(a2.at_start() == false,"");
DLIB_CASSERT(a2.move_next() == false,"");
DLIB_CASSERT(a2.current_element_valid() == false,"");
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a2.at_start() == false,"");
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start(),"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a2.current_element_valid() == false);
DLIB_TEST(a2.at_start() == false);
DLIB_TEST(a2.move_next() == false);
DLIB_TEST(a2.current_element_valid() == false);
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a2.at_start() == false);
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start());
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.size() == 0);
a1.clear();
a2.clear();
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start(),"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start());
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.size() == 0);
swap(a1,a2);
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a2.current_element_valid() == false,"");
DLIB_CASSERT(a2.at_start() == false,"");
DLIB_CASSERT(a2.move_next() == false,"");
DLIB_CASSERT(a2.current_element_valid() == false,"");
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a2.at_start() == false,"");
DLIB_CASSERT(a2.size() == 0,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start(),"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.move_next() == false,"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a2.current_element_valid() == false);
DLIB_TEST(a2.at_start() == false);
DLIB_TEST(a2.move_next() == false);
DLIB_TEST(a2.current_element_valid() == false);
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a2.at_start() == false);
DLIB_TEST(a2.size() == 0);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start());
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.move_next() == false);
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.at_start() == false);
DLIB_TEST(a1.size() == 0);
a1.clear();
a2.clear();
......@@ -194,61 +194,61 @@ namespace
a1.set_max_size(100000);
a2.set_max_size(100000);
a1.set_size(10000);
DLIB_CASSERT(a1.size() == 10000,"");
DLIB_TEST(a1.size() == 10000);
a2.set_size(10000);
DLIB_CASSERT(a2.size() == 10000,"");
DLIB_TEST(a2.size() == 10000);
for (unsigned long i = 0; i < a1.size(); ++i)
{
unsigned long a = static_cast<unsigned long>(rnd.get_random_32bit_number());
a1[i] = a;
a2[i] = i;
DLIB_CASSERT(a1[i] == a,"");
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a1[i] == a);
DLIB_TEST(a2[i] == i);
}
DLIB_CASSERT(a1.at_start(),"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.move_next(),"");
DLIB_CASSERT(a1.current_element_valid(),"");
DLIB_TEST(a1.at_start());
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.move_next());
DLIB_TEST(a1.current_element_valid());
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_TEST(a1.at_start() == false);
a1.sort();
DLIB_CASSERT(a1.at_start(),"");
DLIB_TEST(a1.at_start());
a2.sort();
DLIB_CASSERT(a1.size() == 10000,"");
DLIB_CASSERT(a2.size() == 10000,"");
DLIB_TEST(a1.size() == 10000);
DLIB_TEST(a2.size() == 10000);
for (unsigned long i = 0; i < a1.size(); ++i)
{
if (i+1 < a1.size())
{
DLIB_CASSERT(a1[i] <= a1[i+1],
DLIB_TEST_MSG(a1[i] <= a1[i+1],
"a1[i]: " << a1[i] << " a1[i+1]: " << a1[i+1]
<< " i: " << i);
}
DLIB_CASSERT(a2[i] == i,"i: " << i << " a2[i]: " << a2[i]);
DLIB_TEST_MSG(a2[i] == i,"i: " << i << " a2[i]: " << a2[i]);
}
unsigned long last = 0;
unsigned long count = 0;
while (a1.move_next())
{
DLIB_CASSERT(last <= a1.element(),"");
DLIB_TEST(last <= a1.element());
last = a1.element();
++count;
}
DLIB_CASSERT(count == a1.size(),"");
DLIB_TEST(count == a1.size());
last = 0;
count = 0;
while (a2.move_next())
{
DLIB_CASSERT(last <= a2.element(),"");
DLIB_TEST(last <= a2.element());
last = a2.element();
++count;
}
DLIB_CASSERT(count == a2.size(),"");
DLIB_TEST(count == a2.size());
a2.set_size(15000);
......@@ -256,27 +256,27 @@ namespace
{
if (i+1 < a1.size())
{
DLIB_CASSERT(a1[i] <= a1[i+1],"");
DLIB_TEST(a1[i] <= a1[i+1]);
}
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a2[i] == i);
}
for (unsigned long i = 10000; i < a2.size(); ++i)
{
a2[i] = i;
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a2[i] == i);
}
for (unsigned long i = 0; i < a2.size(); ++i)
{
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a2[i] == i);
}
a2.reset();
last = 0;
while (a2.move_next())
{
DLIB_CASSERT(last <= a2.element(),"");
DLIB_TEST(last <= a2.element());
last = a2.element();
}
......@@ -284,7 +284,7 @@ namespace
last = 0;
while (a1.move_next())
{
DLIB_CASSERT(last <= a1.element(),"");
DLIB_TEST(last <= a1.element());
last = a1.element();
}
......@@ -292,7 +292,7 @@ namespace
last = 0;
while (a1.move_next())
{
DLIB_CASSERT(last <= a1.element(),"");
DLIB_TEST(last <= a1.element());
last = a1.element();
}
......@@ -300,13 +300,13 @@ namespace
for (unsigned long i = 0; i < 15000; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
a1.clear();
DLIB_CASSERT(a1.max_size() == 0,"");
DLIB_TEST(a1.max_size() == 0);
......@@ -315,57 +315,57 @@ namespace
a2.clear();
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a2.size() == 0,"");
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a2.size() == 0);
a1.set_max_size(100000);
a2.set_max_size(100000);
a1.set_size(10000);
DLIB_CASSERT(a1.size() == 10000,"");
DLIB_TEST(a1.size() == 10000);
a2.set_size(10000);
DLIB_CASSERT(a2.size() == 10000,"");
DLIB_TEST(a2.size() == 10000);
for (unsigned long i = 0; i < a1.size(); ++i)
{
unsigned long a = static_cast<unsigned long>(rnd.get_random_32bit_number());
a1[i] = a;
a2[i] = i;
DLIB_CASSERT(a1[i] == a,"");
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a1[i] == a);
DLIB_TEST(a2[i] == i);
}
DLIB_CASSERT(a1.at_start(),"");
DLIB_CASSERT(a1.current_element_valid() == false,"");
DLIB_CASSERT(a1.move_next(),"");
DLIB_CASSERT(a1.current_element_valid(),"");
DLIB_TEST(a1.at_start());
DLIB_TEST(a1.current_element_valid() == false);
DLIB_TEST(a1.move_next());
DLIB_TEST(a1.current_element_valid());
DLIB_CASSERT(a1.at_start() == false,"");
DLIB_TEST(a1.at_start() == false);
a1.sort();
DLIB_CASSERT(a1.at_start(),"");
DLIB_TEST(a1.at_start());
a2.sort();
DLIB_CASSERT(a1.size() == 10000,"");
DLIB_CASSERT(a2.size() == 10000,"");
DLIB_TEST(a1.size() == 10000);
DLIB_TEST(a2.size() == 10000);
for (unsigned long i = 0; i < a1.size(); ++i)
{
if (i+1 < a1.size())
{
DLIB_CASSERT(a1[i] <= a1[i+1],"");
DLIB_TEST(a1[i] <= a1[i+1]);
}
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a2[i] == i);
}
last = 0;
while (a1.move_next())
{
DLIB_CASSERT(last <= a1.element(),"");
DLIB_TEST(last <= a1.element());
last = a1.element();
}
last = 0;
while (a2.move_next())
{
DLIB_CASSERT(last <= a2.element(),"");
DLIB_TEST(last <= a2.element());
last = a2.element();
}
......@@ -375,27 +375,27 @@ namespace
{
if (i+1 < a1.size())
{
DLIB_CASSERT(a1[i] <= a1[i+1],"");
DLIB_TEST(a1[i] <= a1[i+1]);
}
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a2[i] == i);
}
for (unsigned long i = 10000; i < a2.size(); ++i)
{
a2[i] = i;
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a2[i] == i);
}
for (unsigned long i = 0; i < a2.size(); ++i)
{
DLIB_CASSERT(a2[i] == i,"");
DLIB_TEST(a2[i] == i);
}
a2.reset();
last = 0;
while (a2.move_next())
{
DLIB_CASSERT(last <= a2.element(),"");
DLIB_TEST(last <= a2.element());
last = a2.element();
}
......@@ -403,7 +403,7 @@ namespace
last = 0;
while (a1.move_next())
{
DLIB_CASSERT(last <= a1.element(),"");
DLIB_TEST(last <= a1.element());
last = a1.element();
}
......@@ -411,7 +411,7 @@ namespace
last = 0;
while (a1.move_next())
{
DLIB_CASSERT(last <= a1.element(),"");
DLIB_TEST(last <= a1.element());
last = a1.element();
}
......@@ -419,13 +419,13 @@ namespace
for (unsigned long i = 0; i < 15000; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
a1.clear();
DLIB_CASSERT(a1.max_size() == 0,"");
DLIB_TEST(a1.max_size() == 0);
a2.clear();
print_spinner();
......@@ -434,11 +434,11 @@ namespace
a1.set_max_size(2000000);
DLIB_CASSERT(a1.max_size() == 2000000,"");
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a1.max_size() == 2000000);
DLIB_TEST(a1.size() == 0);
a1.set_size(2000000);
DLIB_CASSERT(a1.max_size() == 2000000,"");
DLIB_CASSERT(a1.size() == 2000000,"");
DLIB_TEST(a1.max_size() == 2000000);
DLIB_TEST(a1.size() == 2000000);
for (unsigned long i = 0; i < a1.size(); ++i)
{
......@@ -453,47 +453,47 @@ namespace
// load the state back into a1.
ostringstream sout;
serialize(a1,sout);
DLIB_CASSERT(a1.at_start() == true,"");
DLIB_TEST(a1.at_start() == true);
istringstream sin(sout.str());
a1.clear();
DLIB_CASSERT(a1.max_size() == 0,"");
DLIB_TEST(a1.max_size() == 0);
deserialize(a1,sin);
DLIB_CASSERT(a1.size() == 2000000,"");
DLIB_TEST(a1.size() == 2000000);
for (unsigned long i = 0; i < a1.size()-1; ++i)
{
DLIB_CASSERT(a1[i] <= a1[i+1],"");
DLIB_TEST(a1[i] <= a1[i+1]);
}
DLIB_CASSERT(a1.max_size() == 2000000,"");
DLIB_CASSERT(a1.size() == 2000000,"");
DLIB_TEST(a1.max_size() == 2000000);
DLIB_TEST(a1.size() == 2000000);
swap(a1,a2);
print_spinner();
DLIB_CASSERT(a2.size() == 2000000,"");
DLIB_TEST(a2.size() == 2000000);
for (unsigned long i = 0; i < a2.size()-1; ++i)
{
DLIB_CASSERT(a2[i] <= a2[i+1],"");
DLIB_TEST(a2[i] <= a2[i+1]);
}
DLIB_CASSERT(a2.max_size() == 2000000,"");
DLIB_CASSERT(a2.size() == 2000000,"");
DLIB_TEST(a2.max_size() == 2000000);
DLIB_TEST(a2.size() == 2000000);
swap(a1,a2);
a1.clear();
DLIB_CASSERT(a1.size() == 0,"");
DLIB_CASSERT(a1.max_size() == 0,"");
DLIB_TEST(a1.size() == 0);
DLIB_TEST(a1.max_size() == 0);
a1.resize(10);
DLIB_CASSERT(a1.size() == 10,"");
DLIB_CASSERT(a1.max_size() == 10,"");
DLIB_TEST(a1.size() == 10);
DLIB_TEST(a1.max_size() == 10);
for (unsigned long i = 0; i < a1.size(); ++i)
{
......@@ -502,92 +502,92 @@ namespace
print_spinner();
a1.resize(100);
DLIB_CASSERT(a1.size() == 100,"");
DLIB_CASSERT(a1.max_size() == 100,"");
DLIB_TEST(a1.size() == 100);
DLIB_TEST(a1.max_size() == 100);
for (unsigned long i = 0; i < 10; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
a1.resize(50);
DLIB_CASSERT(a1.size() == 50,"");
DLIB_CASSERT(a1.max_size() == 100,"");
DLIB_TEST(a1.size() == 50);
DLIB_TEST(a1.max_size() == 100);
for (unsigned long i = 0; i < 10; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
a1.resize(10);
DLIB_CASSERT(a1.size() == 10,"");
DLIB_CASSERT(a1.max_size() == 100,"");
DLIB_TEST(a1.size() == 10);
DLIB_TEST(a1.max_size() == 100);
for (unsigned long i = 0; i < 10; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
a1.resize(20);
DLIB_CASSERT(a1.size() == 20,"");
DLIB_CASSERT(a1.max_size() == 100,"");
DLIB_TEST(a1.size() == 20);
DLIB_TEST(a1.max_size() == 100);
for (unsigned long i = 0; i < 10; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
a1.resize(100);
DLIB_CASSERT(a1.size() == 100,"");
DLIB_CASSERT(a1.max_size() == 100,"");
DLIB_TEST(a1.size() == 100);
DLIB_TEST(a1.max_size() == 100);
for (unsigned long i = 0; i < 10; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
{
a1.clear();
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a1.size() == 0);
for (unsigned long i = 0; i < 100; ++i)
{
unsigned long a = i;
a1.push_back(a);
DLIB_CASSERT(a1.size() == i+1,"");
DLIB_CASSERT(a1.back() == i,"");
DLIB_TEST(a1.size() == i+1);
DLIB_TEST(a1.back() == i);
}
for (unsigned long i = 0; i < 100; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
for (unsigned long i = 0; i < 100; ++i)
{
unsigned long a = 0;
a1.pop_back(a);
DLIB_CASSERT(a == 99-i,"");
DLIB_TEST(a == 99-i);
}
}
{
a1.clear();
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a1.size() == 0);
for (unsigned long i = 0; i < 100; ++i)
{
unsigned long a = i;
a1.push_back(a);
DLIB_CASSERT(a1.size() == i+1,"");
DLIB_CASSERT(a1.back() == i,"");
DLIB_TEST(a1.size() == i+1);
DLIB_TEST(a1.back() == i);
}
for (unsigned long i = 0; i < 100; ++i)
{
DLIB_CASSERT(a1[i] == i,"");
DLIB_TEST(a1[i] == i);
}
for (unsigned long i = 0; i < 100; ++i)
{
a1.pop_back();
}
DLIB_CASSERT(a1.size() == 0,"");
DLIB_TEST(a1.size() == 0);
}
......
......@@ -40,117 +40,117 @@ namespace
enumerable<unsigned long>& e = test;
DLIB_CASSERT(e.at_start() == true,"");
DLIB_TEST(e.at_start() == true);
DLIB_CASSERT(e.size() == 0,"");
DLIB_CASSERT(e.at_start() == true,"");
DLIB_CASSERT(e.current_element_valid() == false, "");
DLIB_TEST(e.size() == 0);
DLIB_TEST(e.at_start() == true);
DLIB_TEST(e.current_element_valid() == false);
DLIB_CASSERT (e.move_next() == false,"");
DLIB_CASSERT (e.move_next() == false,"");
DLIB_CASSERT (e.move_next() == false,"");
DLIB_CASSERT (e.move_next() == false,"");
DLIB_CASSERT (e.move_next() == false,"");
DLIB_CASSERT (e.move_next() == false,"");
DLIB_TEST (e.move_next() == false);
DLIB_TEST (e.move_next() == false);
DLIB_TEST (e.move_next() == false);
DLIB_TEST (e.move_next() == false);
DLIB_TEST (e.move_next() == false);
DLIB_TEST (e.move_next() == false);
DLIB_CASSERT(e.size() == 0,"");
DLIB_CASSERT(e.at_start() == false,"");
DLIB_CASSERT(e.current_element_valid() == false, "");
DLIB_TEST(e.size() == 0);
DLIB_TEST(e.at_start() == false);
DLIB_TEST(e.current_element_valid() == false);
e.reset();
DLIB_CASSERT(e.size() == 0,"");
DLIB_CASSERT(e.at_start() == true,"");
DLIB_CASSERT(e.current_element_valid() == false, "");
DLIB_TEST(e.size() == 0);
DLIB_TEST(e.at_start() == true);
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_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false, "");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false, "");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
test.reset();
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false, "");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
test.clear();
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false, "");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
test.set_size(0,0);
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false, "");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_CASSERT (test.move_next() == false,"");
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
DLIB_TEST (test.move_next() == false);
swap(test,test2);
DLIB_CASSERT (test2.at_start() == false,"");
DLIB_CASSERT (test2.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false, "");
DLIB_TEST (test2.at_start() == false);
DLIB_TEST (test2.current_element_valid() == false);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
swap(test,test2);
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.current_element_valid() == false, "");
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false, "");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
test.reset();
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false, "");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
......@@ -184,46 +184,46 @@ namespace
test.set_size(nr,nc);
DLIB_CASSERT(test.size() == static_cast<unsigned long>(nc*nr),"");
DLIB_CASSERT(test.nr() == nr,"");
DLIB_CASSERT(test.nc() == nc,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.size() == static_cast<unsigned long>(nc*nr));
DLIB_TEST(test.nr() == nr);
DLIB_TEST(test.nc() == nc);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
unsigned long i = 0;
while (test.move_next())
{
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_TEST(test.current_element_valid() == true);
DLIB_TEST(test.at_start() == false);
test.element() = i;
DLIB_CASSERT(const_cast<const array2d&>(test).element() == i,"");
DLIB_TEST(const_cast<const array2d&>(test).element() == i);
++i;
}
DLIB_CASSERT(i == test.size(),"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(i == test.size());
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.nr() == nr,"");
DLIB_CASSERT(test.nc() == nc,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.size() == static_cast<unsigned long>(nc*nr),"");
DLIB_TEST(test.nr() == nr);
DLIB_TEST(test.nc() == nc);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.size() == static_cast<unsigned long>(nc*nr));
i = 0;
for (long row = 0; row < test.nr(); ++row)
{
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\tcol: " << col <<
"\n\ti: " << i <<
"\n\ttest[row][col]: " << test[row][col]);
DLIB_CASSERT(test[row].nc() == test.nc(),"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test[row].nc() == test.nc());
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.nr() == nr,"");
DLIB_CASSERT(test.nc() == nc,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.size() == static_cast<unsigned long>(nc*nr),"");
DLIB_TEST(test.nr() == nr);
DLIB_TEST(test.nc() == nc);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.size() == static_cast<unsigned long>(nc*nr));
++i;
}
}
......@@ -233,12 +233,12 @@ namespace
i = 0;
while (test.move_next())
{
DLIB_CASSERT(test.element() == i,"");
DLIB_TEST(test.element() == i);
++i;
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_TEST(test.current_element_valid() == true);
DLIB_TEST(test.at_start() == false);
}
DLIB_CASSERT(i == test.size(),"");
DLIB_TEST(i == test.size());
test.reset();
......@@ -247,46 +247,46 @@ namespace
swap(test,test2);
DLIB_CASSERT(test2.size() == static_cast<unsigned long>(nc*nr),"");
DLIB_CASSERT(test2.nr() == nr,"");
DLIB_CASSERT(test2.nc() == nc,"");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_TEST(test2.size() == static_cast<unsigned long>(nc*nr));
DLIB_TEST(test2.nr() == nr);
DLIB_TEST(test2.nc() == nc);
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.current_element_valid() == false);
i = 0;
while (test2.move_next())
{
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_TEST(test2.current_element_valid() == true);
DLIB_TEST(test2.at_start() == false);
test2.element() = i;
++i;
}
DLIB_CASSERT(i == test2.size(),"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_TEST(i == test2.size());
DLIB_TEST(test2.current_element_valid() == false);
DLIB_CASSERT(test2.nr() == nr,"");
DLIB_CASSERT(test2.nr() == test2.nr(),"");
DLIB_CASSERT(test2.nc() == nc,"");
DLIB_CASSERT(test2.nc() == test2.nc(),"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.size() == static_cast<unsigned long>(nc*nr),"");
DLIB_TEST(test2.nr() == nr);
DLIB_TEST(test2.nr() == test2.nr());
DLIB_TEST(test2.nc() == nc);
DLIB_TEST(test2.nc() == test2.nc());
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.size() == static_cast<unsigned long>(nc*nr));
i = 0;
for (long row = 0; row < test2.nr(); ++row)
{
for (long col = 0; col < test2.nc(); ++col)
{
DLIB_CASSERT(test2[row][col] == i,"");
DLIB_CASSERT(const_cast<const array2d&>(test2)[row][col] == i,"");
DLIB_CASSERT(test2[row].nc() == test2.nc(),"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.nr() == nr,"");
DLIB_CASSERT(test2.nr() == test2.nr(),"");
DLIB_CASSERT(test2.nc() == nc,"");
DLIB_CASSERT(test2.nc() == test2.nc(),"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.size() == static_cast<unsigned long>(nc*nr),"");
DLIB_TEST(test2[row][col] == i);
DLIB_TEST(const_cast<const array2d&>(test2)[row][col] == i);
DLIB_TEST(test2[row].nc() == test2.nc());
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.nr() == nr);
DLIB_TEST(test2.nr() == test2.nr());
DLIB_TEST(test2.nc() == nc);
DLIB_TEST(test2.nc() == test2.nc());
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.size() == static_cast<unsigned long>(nc*nr));
++i;
}
}
......@@ -296,30 +296,30 @@ namespace
i = 0;
while (test2.move_next())
{
DLIB_CASSERT(test2.element() == i,"");
DLIB_CASSERT(const_cast<const array2d&>(test2).element() == i,"");
DLIB_TEST(test2.element() == i);
DLIB_TEST(const_cast<const array2d&>(test2).element() == i);
++i;
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_TEST(test2.current_element_valid() == true);
DLIB_TEST(test2.at_start() == false);
}
DLIB_CASSERT(i == test2.size(),"");
DLIB_TEST(i == test2.size());
test2.clear();
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2.nr() == 0,"");
DLIB_CASSERT(test2.nc() == 0,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2.nr() == 0);
DLIB_TEST(test2.nc() == 0);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == true);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.nc() == 0,"");
DLIB_CASSERT(test.nr() == 0,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.nc() == 0);
DLIB_TEST(test.nr() == 0);
test.set_size(nr,nc);
DLIB_CASSERT(test.size() == static_cast<unsigned long>(nc*nr),"");
DLIB_CASSERT(test.nc() == nc,"");
DLIB_CASSERT(test.nr() == nr,"");
DLIB_TEST(test.size() == static_cast<unsigned long>(nc*nr));
DLIB_TEST(test.nc() == nc);
DLIB_TEST(test.nr() == nr);
......@@ -335,12 +335,12 @@ namespace
test.clear();
test2.clear();
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.nc() == 0,"");
DLIB_CASSERT(test.nr() == 0,"");
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2.nc() == 0,"");
DLIB_CASSERT(test2.nr() == 0,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.nc() == 0);
DLIB_TEST(test.nr() == 0);
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2.nc() == 0);
DLIB_TEST(test2.nr() == 0);
test.set_size(10,10);
......@@ -356,20 +356,20 @@ namespace
sin.str(sout.str());
deserialize(test2,sin);
DLIB_CASSERT(test2.size() == test.size(),"");
DLIB_CASSERT(test2.nc() == test.nc(),"");
DLIB_CASSERT(test2.nr() == test.nr(),"");
DLIB_CASSERT(test2.size() == 100,"");
DLIB_CASSERT(test2.nc() == 10,"");
DLIB_CASSERT(test2.nr() == 10,"");
DLIB_TEST(test2.size() == test.size());
DLIB_TEST(test2.nc() == test.nc());
DLIB_TEST(test2.nr() == test.nr());
DLIB_TEST(test2.size() == 100);
DLIB_TEST(test2.nc() == 10);
DLIB_TEST(test2.nr() == 10);
for (long row = 0; row < test.nr(); ++row)
{
for (long col = 0; col < test.nc(); ++col)
{
DLIB_CASSERT(test[row][col] == static_cast<unsigned long>(row*col),"");
DLIB_CASSERT(test2[row][col] == static_cast<unsigned long>(row*col),"");
DLIB_TEST(test[row][col] == static_cast<unsigned long>(row*col));
DLIB_TEST(test2[row][col] == static_cast<unsigned long>(row*col));
}
}
......@@ -379,11 +379,11 @@ namespace
test.set_size(10,11);
DLIB_CASSERT(test.nr() == 10,"");
DLIB_CASSERT(test.nc() == 11,"");
DLIB_TEST(test.nr() == 10);
DLIB_TEST(test.nc() == 11);
test.set_size(0,0);
DLIB_CASSERT(test.nr() == 0,"");
DLIB_CASSERT(test.nc() == 0,"");
DLIB_TEST(test.nr() == 0);
DLIB_TEST(test.nc() == 0);
}
......
......@@ -59,7 +59,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(wiki_encoded);
test.decode(sin,sout);
DLIB_CASSERT(sout.str() == wiki_normal,
DLIB_TEST_MSG(sout.str() == wiki_normal,
"sout.str(): " << sout.str() <<
"\nwiki_normal: " << wiki_normal);
......@@ -91,7 +91,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
}
sin.clear();
DLIB_CASSERT(a == b,
DLIB_TEST_MSG(a == b,
"a: \n" << a <<
"\n\nb: \n" << b);
......@@ -104,7 +104,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str());
sout.str("");
test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "","");
DLIB_TEST(sout.str() == "");
sin.clear();
sin.str("a");
......@@ -113,7 +113,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str());
sout.str("");
test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "a","");
DLIB_TEST(sout.str() == "a");
sin.clear();
sin.str("da");
......@@ -122,7 +122,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str());
sout.str("");
test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "da","");
DLIB_TEST(sout.str() == "da");
sin.clear();
sin.str("dav");
......@@ -131,7 +131,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str());
sout.str("");
test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "dav","");
DLIB_TEST(sout.str() == "dav");
sin.clear();
sin.str("davi");
......@@ -140,7 +140,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sin.str(sout.str());
sout.str("");
test.decode(sin,sout);
DLIB_CASSERT(sout.str() == "davi","");
DLIB_TEST(sout.str() == "davi");
for (int i = 0; i < 1000; ++i)
......@@ -165,7 +165,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
sout.str("");
test.decode(sin,sout);
DLIB_CASSERT(str == sout.str(),"");
DLIB_TEST(str == sout.str());
}
......@@ -176,7 +176,7 @@ LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
}
catch (typename base64::decode_error& e)
{
DLIB_CASSERT(false,
DLIB_TEST_MSG(false,
"decode_error thrown when it shouldn't have been (" << seed << "):\n "
<< e.info);
}
......
......@@ -75,10 +75,10 @@ namespace
ostringstream sout;
serialize(bn, sout);
bn.clear();
DLIB_CASSERT(bn.number_of_nodes() == 0,"");
DLIB_TEST(bn.number_of_nodes() == 0);
istringstream sin(sout.str());
deserialize(bn, sin);
DLIB_CASSERT(bn.number_of_nodes() == 3,"");
DLIB_TEST(bn.number_of_nodes() == 3);
}
......@@ -209,10 +209,10 @@ namespace
ostringstream sout;
serialize(bn, sout);
bn.clear();
DLIB_CASSERT(bn.number_of_nodes() == 0,"");
DLIB_TEST(bn.number_of_nodes() == 0);
istringstream sin(sout.str());
deserialize(bn, sin);
DLIB_CASSERT(bn.number_of_nodes() == 8,"");
DLIB_TEST(bn.number_of_nodes() == 8);
}
......@@ -242,36 +242,36 @@ namespace
matrix<double,1,2> dist;
dist = solution.probability(A);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.01 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.01 ) < 1e-5);
dist = solution.probability(T);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.0104) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.0104) < 1e-5);
dist = solution.probability(O);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.064828) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.064828) < 1e-5);
dist = solution.probability(X);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.11029004) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.11029004) < 1e-5);
dist = solution.probability(L);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.055) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.055) < 1e-5);
dist = solution.probability(S);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.5) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.5) < 1e-5);
dist = solution.probability(B);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.4499999) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.4499999) < 1e-5);
dist = solution.probability(D);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.4359706 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.4359706 ) < 1e-5);
// now lets modify the probabilities of the bayesian network by making O
// not a deterministic node anymore but otherwise leave the network alone
......@@ -287,39 +287,39 @@ namespace
// reload the solution now that we have changed the probabilities of node O
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);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 1.0 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 1.0 ) < 1e-5);
dist = solution.probability(T);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.253508694039 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.253508694039 ) < 1e-5);
dist = solution.probability(O);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.77856184024 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.77856184024 ) < 1e-5);
dist = solution.probability(X);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 1.0 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 1.0 ) < 1e-5);
dist = solution.probability(L);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.5070173880 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.5070173880 ) < 1e-5);
dist = solution.probability(S);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 1.0 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 1.0 ) < 1e-5);
dist = solution.probability(B);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.6 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.6 ) < 1e-5);
dist = solution.probability(D);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.7535685520 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.7535685520 ) < 1e-5);
// now lets test the bayesian_network_gibbs_sampler
......@@ -354,33 +354,33 @@ namespace
counts /= rounds;
DLIB_CASSERT(abs(counts(A) - 1.0 ) < 1e-2,"");
DLIB_CASSERT(abs(counts(T) - 0.253508694039 ) < 1e-2,"");
DLIB_CASSERT(abs(counts(O) - 0.77856184024 ) < 1e-2,abs(counts(O) - 0.77856184024 ) );
DLIB_CASSERT(abs(counts(X) - 1.0 ) < 1e-2,"");
DLIB_CASSERT(abs(counts(L) - 0.5070173880 ) < 1e-2,"");
DLIB_CASSERT(abs(counts(S) - 1.0 ) < 1e-2,"");
DLIB_CASSERT(abs(counts(B) - 0.6 ) < 1e-2,"");
DLIB_CASSERT(abs(counts(D) - 0.7535685520 ) < 1e-2,"");
DLIB_TEST(abs(counts(A) - 1.0 ) < 1e-2);
DLIB_TEST(abs(counts(T) - 0.253508694039 ) < 1e-2);
DLIB_TEST_MSG(abs(counts(O) - 0.77856184024 ) < 1e-2,abs(counts(O) - 0.77856184024 ) );
DLIB_TEST(abs(counts(X) - 1.0 ) < 1e-2);
DLIB_TEST(abs(counts(L) - 0.5070173880 ) < 1e-2);
DLIB_TEST(abs(counts(S) - 1.0 ) < 1e-2);
DLIB_TEST(abs(counts(B) - 0.6 ) < 1e-2);
DLIB_TEST(abs(counts(D) - 0.7535685520 ) < 1e-2);
setup_simple_network(bn);
create_moral_graph(bn, join_tree);
create_join_tree(join_tree, join_tree);
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);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.1 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.1 ) < 1e-5);
dist = solution.probability(T);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.5 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.5 ) < 1e-5);
dist = solution.probability(S);
DLIB_CASSERT(abs(sum(dist) - 1.0) < 1e-5,"");
DLIB_CASSERT(abs(dist(1) - 0.5 ) < 1e-5,"");
DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
DLIB_TEST(abs(dist(1) - 0.5 ) < 1e-5);
}
......
......@@ -104,33 +104,33 @@ namespace
bint i = 0;
bint a(5), b, c(0);
DLIB_CASSERT(5 - a == 0,"");
DLIB_CASSERT(a - 5 == 0,"");
DLIB_TEST(5 - a == 0);
DLIB_TEST(a - 5 == 0);
DLIB_CASSERT(0 - c == 0,"");
DLIB_CASSERT(c - 0 == 0,"");
DLIB_TEST(0 - c == 0);
DLIB_TEST(c - 0 == 0);
DLIB_CASSERT(0 + c == 0,"");
DLIB_CASSERT(c + 0 == 0,"");
DLIB_TEST(0 + c == 0);
DLIB_TEST(c + 0 == 0);
DLIB_CASSERT(0 + a == 5,"");
DLIB_CASSERT(a + 0 == 5,"");
DLIB_TEST(0 + a == 5);
DLIB_TEST(a + 0 == 5);
DLIB_CASSERT(0 - b == 0,"");
DLIB_CASSERT(b - 0 == 0,"");
DLIB_TEST(0 - b == 0);
DLIB_TEST(b - 0 == 0);
DLIB_CASSERT(0 + b == 0,"");
DLIB_CASSERT(b + 0 == 0,"");
DLIB_TEST(0 + b == 0);
DLIB_TEST(b + 0 == 0);
DLIB_CASSERT(i == 0,"");
DLIB_CASSERT(a == 5,"");
DLIB_CASSERT(b == 0,"");
DLIB_CASSERT(c == 0,"");
DLIB_TEST(i == 0);
DLIB_TEST(a == 5);
DLIB_TEST(b == 0);
DLIB_TEST(c == 0);
a -= 5;
DLIB_CASSERT(a == 0,"");
DLIB_TEST(a == 0);
......@@ -145,13 +145,13 @@ namespace
// big int multiplication algorithm.
c = a*b;
// make sure a and b ended up being the same number
DLIB_CASSERT(a == b,
DLIB_TEST_MSG(a == b,
"k: " << k << "\n"
"short_fact: " << a << "\n"
"big_fact: " << b
);
// 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();
}
......@@ -161,12 +161,12 @@ namespace
bint a = short_fact<bint>(k);
bint b = big_fact<bint>(k);
bint c = a*b;
DLIB_CASSERT(a == b,
DLIB_TEST_MSG(a == b,
"k: " << k << "\n"
"short_fact: " << a << "\n"
"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();
}
......@@ -175,25 +175,25 @@ namespace
// test the << and >> operators a little
a = big_fact<bint>(20);
sout << a;
DLIB_CASSERT( sout.str() == "2432902008176640000","was: " << a);
DLIB_TEST_MSG( sout.str() == "2432902008176640000","was: " << a);
sin.str("684626312793279327952039475203945");
sin >> a;
sout.str("");
sout << a;
DLIB_CASSERT(sout.str() == "684626312793279327952039475203945","");
DLIB_TEST(sout.str() == "684626312793279327952039475203945");
print_spinner();
DLIB_CASSERT(a > 0,"");
DLIB_TEST(a > 0);
// make sure that when you try to read something that isn't a number
// 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 >> a;
DLIB_CASSERT(sin.fail() == true, "");
DLIB_TEST(sin.fail() == true);
sin.clear();
sin.str("");
......@@ -201,11 +201,11 @@ namespace
sin.str("3628913");
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 >> 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
sout.str("");
......@@ -214,7 +214,7 @@ namespace
sin.str(sout.str());
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
sin >> b;
a = 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
if ((mel&0xFFF) == 0)
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
sin.str("100000");
sin >> b;
i = b;
DLIB_CASSERT(i == b,"");
DLIB_CASSERT(i > 0,"i==" << i);
DLIB_TEST(i == b);
DLIB_TEST_MSG(i > 0,"i==" << i);
mel = 0;
for (i = b; i > 0; --i)
{
......@@ -282,7 +282,7 @@ namespace
if ((mel&0xFF) == 0)
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
DLIB_CASSERT(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) == 30240);
DLIB_TEST(short_fact<bint>(10)/(short_fact<bint>(5)+1) == 29990);
sin.str("221172909834240000");
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 >> 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();
sin.str("1860479");
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
sout.str("");
......@@ -318,7 +318,7 @@ namespace
sin.str(sout.str());
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();
......@@ -330,28 +330,28 @@ namespace
i = 1234;
sin.str(sout.str());
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_CASSERT(bint(5)%bint(6) == 5,"");
DLIB_CASSERT(bint(25)%bint(6) == 1,"");
DLIB_TEST(bint(5)%bint(1) == 0);
DLIB_TEST(bint(5)%bint(6) == 5);
DLIB_TEST(bint(25)%bint(6) == 1);
print_spinner();
DLIB_CASSERT(bint(354)%bint(123) == 108,"");
DLIB_CASSERT(bint(20)%(bint(10)) == 0,"");
DLIB_CASSERT(bint(20)%(bint(10)+1) == 9,"");
DLIB_TEST(bint(354)%bint(123) == 108);
DLIB_TEST(bint(20)%(bint(10)) == 0);
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 >> 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
// 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 >> 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();
DLIB_CASSERT(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) == 30240);
DLIB_TEST(big_fact<bint>(10)/(big_fact<bint>(5)+1) == 29990);
sin.str("221172909834240000");
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 >> 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 >> 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
sin.str(sout.str());
sin >> c;
DLIB_CASSERT(a*b == c,
DLIB_TEST_MSG(a*b == c,
"a*b: " << a*b <<
"\nc: " << c);
......@@ -426,50 +426,50 @@ namespace
unsigned long j;
for (j = 0; i < bint(100000); ++j)
{
DLIB_CASSERT(i++ == bint(j),"");
DLIB_TEST(i++ == bint(j));
++mel;
if((mel&0xFF) == 0)
print_spinner();
}
DLIB_CASSERT(j == 100000,"");
DLIB_TEST(j == 100000);
i = 1234;
DLIB_CASSERT(i == 1234,"");
DLIB_CASSERT(i < 2345 ,"");
DLIB_CASSERT(i > 0 ,"");
DLIB_CASSERT(i > 123 ,"");
DLIB_TEST(i == 1234);
DLIB_TEST(i < 2345 );
DLIB_TEST(i > 0 );
DLIB_TEST(i > 123 );
DLIB_CASSERT(i != 1334,"");
DLIB_CASSERT(i <= 2345,"");
DLIB_CASSERT(i >= 0 ,"");
DLIB_CASSERT(i >= 123 ,"");
DLIB_CASSERT(i >= 1234,"");
DLIB_CASSERT(i <= 1234,"");
DLIB_TEST(i != 1334);
DLIB_TEST(i <= 2345);
DLIB_TEST(i >= 0 );
DLIB_TEST(i >= 123 );
DLIB_TEST(i >= 1234);
DLIB_TEST(i <= 1234);
DLIB_CASSERT(1234 == i,"");
DLIB_CASSERT(2345 > i,"");
DLIB_CASSERT(0 < i,"");
DLIB_CASSERT(123 < i,"");
DLIB_TEST(1234 == i);
DLIB_TEST(2345 > i);
DLIB_TEST(0 < i);
DLIB_TEST(123 < i);
DLIB_CASSERT(1334 != i,"");
DLIB_CASSERT(2345 >= i,"");
DLIB_CASSERT(0 <= i,"");
DLIB_CASSERT(123 <= i,"");
DLIB_CASSERT(1234 <= i,"");
DLIB_CASSERT(1234 >= i,"");
DLIB_TEST(1334 != i);
DLIB_TEST(2345 >= i);
DLIB_TEST(0 <= i);
DLIB_TEST(123 <= i);
DLIB_TEST(1234 <= i);
DLIB_TEST(1234 >= i);
a = big_fact<bint>(200);
b = big_fact<bint>(100);
DLIB_CASSERT(a > b, "");
DLIB_CASSERT(a != b, "");
DLIB_CASSERT(b < a, "");
DLIB_CASSERT(b != a, "");
DLIB_CASSERT(b <= a, "");
DLIB_CASSERT(a >= b, "");
DLIB_TEST(a > b);
DLIB_TEST(a != b);
DLIB_TEST(b < a);
DLIB_TEST(b != a);
DLIB_TEST(b <= a);
DLIB_TEST(a >= b);
......
......@@ -43,86 +43,86 @@ namespace
srand(static_cast<unsigned int>(time(0)));
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_TEST(test.count(3) == 0);
enumerable<map_pair<int,int> >& e = test;
DLIB_CASSERT(e.at_start() == true,"");
DLIB_TEST(e.at_start() == true);
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_TEST(test.count(3) == 0);
for (int i = 0; i < 4; ++i)
{
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_CASSERT(test.height() == 0,"");
DLIB_CASSERT(test[5] == 0,"");
DLIB_CASSERT(test[0] == 0,"");
DLIB_CASSERT(test.at_start(),"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.count(3) == 0);
DLIB_TEST(test.height() == 0);
DLIB_TEST(test[5] == 0);
DLIB_TEST(test[0] == 0);
DLIB_TEST(test.at_start());
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.count(3) == 0);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.count(3) == 0);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
test.clear();
test.position_enumerator(5);
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false, "");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
test.position_enumerator(5);
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false, "");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
test.position_enumerator(9);
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false, "");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
test.clear();
test.position_enumerator(5);
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false, "");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
test.position_enumerator(5);
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false, "");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
test.position_enumerator(9);
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false, "");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
test.clear();
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_TEST(test.count(3) == 0);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.height() == 0,"");
DLIB_CASSERT(test[5] == 0,"");
DLIB_CASSERT(test[0] == 0,"");
DLIB_CASSERT(const_cast<const bst&>(test)[5] == 0,"");
DLIB_CASSERT(const_cast<const bst&>(test)[0] == 0,"");
DLIB_CASSERT(test.at_start(),"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.height() == 0);
DLIB_TEST(test[5] == 0);
DLIB_TEST(test[0] == 0);
DLIB_TEST(const_cast<const bst&>(test)[5] == 0);
DLIB_TEST(const_cast<const bst&>(test)[0] == 0);
DLIB_TEST(test.at_start());
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_TEST(test.count(3) == 0);
test.reset();
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_TEST(test.count(3) == 0);
DLIB_CASSERT(test.at_start(),"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.at_start());
DLIB_TEST(test.current_element_valid() == false);
......@@ -137,7 +137,7 @@ namespace
int temp = a;
unsigned long count = test.count(a);
test.add(a,b);
DLIB_CASSERT(test.count(temp) == count+1,"");
DLIB_TEST(test.count(temp) == count+1);
}
......@@ -145,13 +145,13 @@ namespace
unsigned long count = test.count(3);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
}
......@@ -168,7 +168,7 @@ namespace
int temp = a;
unsigned long count = test.count(a);
test.add(a,b);
DLIB_CASSERT(test.count(temp) == count+1,"");
DLIB_TEST(test.count(temp) == count+1);
}
// serialize the state of test, then clear test, then
......@@ -179,42 +179,42 @@ namespace
test.clear();
deserialize(test,sin);
DLIB_CASSERT(test.size() == 10000,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.size() == 10000);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.height() > 13 && test.height() <= 26,"this is somewhat of an implementation dependent "
DLIB_TEST_MSG(test.height() > 13 && test.height() <= 26,"this is somewhat of an implementation dependent "
<< "but really it should be in this range or the implementation is just crap");
a = 0;
unsigned long count = 0;
while (test.move_next())
{
DLIB_CASSERT(a <= test.element().key(),"the numers are out of order but they should be in order");
DLIB_TEST_MSG(a <= test.element().key(),"the numers are out of order but they should be in order");
a = test.element().key();
++count;
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == true);
}
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(count == 10000,"");
DLIB_TEST(count == 10000);
DLIB_CASSERT(test.height() > 13 && test.height() <= 26,"this is somewhat of an implementation dependent "
DLIB_TEST_MSG(test.height() > 13 && test.height() <= 26,"this is somewhat of an implementation dependent "
<< "but really it should be in this range or the implementation is just crap");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.size() == 10000);
swap(test,test2);
......@@ -225,13 +225,13 @@ namespace
a = 0;
while (test2.move_next())
{
DLIB_CASSERT(a <= test2.element().key(),"the numers are out of order but they should be in order");
DLIB_TEST_MSG(a <= test2.element().key(),"the numers are out of order but they should be in order");
a = test2.element().key();
++count;
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == true);
if (count == 5000)
{
......@@ -239,9 +239,9 @@ namespace
}
}
DLIB_CASSERT(test2.move_next() == true,"");
DLIB_CASSERT(test2.move_next() == true,"");
DLIB_CASSERT(test2.move_next() == true,"");
DLIB_TEST(test2.move_next() == true);
DLIB_TEST(test2.move_next() == true);
DLIB_TEST(test2.move_next() == true);
test2.reset();
......@@ -250,19 +250,19 @@ namespace
a = 0;
while (test2.move_next())
{
DLIB_CASSERT(a <= test2.element().key(),"the numers are out of order but they should be in order");
DLIB_TEST_MSG(a <= test2.element().key(),"the numers are out of order but they should be in order");
a = test2.element().key();
++count;
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == true);
}
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_TEST(count == 10000);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.move_next() == false);
......@@ -273,24 +273,24 @@ namespace
int last = 0;
asc_pair_remover<int,int,typename bst::compare_type>& asdf = test2;
DLIB_CASSERT(asdf.size() > 0,"");
DLIB_TEST(asdf.size() > 0);
while (asdf.size() > 0)
{
asdf.remove_any(a,b);
DLIB_CASSERT(last <= a,"");
DLIB_TEST(last <= a);
last = a;
--count;
DLIB_CASSERT(asdf.size() == count,"");
DLIB_TEST(asdf.size() == count);
}
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2.height() ==0,"");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2.height() ==0);
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.move_next() == false);
......@@ -300,95 +300,95 @@ namespace
a = i;
b = i;
test2.add(a,b);
DLIB_CASSERT(test2.size() == (unsigned int)(i +1),"");
DLIB_CASSERT(test2.count(i) == 1,"");
DLIB_TEST(test2.size() == (unsigned int)(i +1));
DLIB_TEST(test2.count(i) == 1);
}
a = 0;
test2.position_enumerator(a);
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.element().key() == a, "");
DLIB_CASSERT(test2.element().value() == a, "");
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.element().key() == a);
DLIB_TEST(test2.element().value() == a);
a = 0;
test2.position_enumerator(a);
DLIB_CASSERT(test2.element().key() == a, "");
DLIB_CASSERT(test2.element().value() == a, "");
DLIB_TEST(test2.element().key() == a);
DLIB_TEST(test2.element().value() == a);
a = 8;
test2.position_enumerator(a);
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.element().key() == a, "");
DLIB_CASSERT(test2.element().value() == a, "");
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.element().key() == a);
DLIB_TEST(test2.element().value() == a);
a = 1;
test2.position_enumerator(a);
DLIB_CASSERT(test2.element().key() == a, "");
DLIB_CASSERT(test2.element().value() == a, "");
DLIB_TEST(test2.element().key() == a);
DLIB_TEST(test2.element().value() == a);
a = -29;
test2.position_enumerator(a);
DLIB_CASSERT(test2.element().key() == 0, "");
DLIB_CASSERT(test2.element().value() == 0, "");
DLIB_TEST(test2.element().key() == 0);
DLIB_TEST(test2.element().value() == 0);
a = 10000;
test2.position_enumerator(a);
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == false);
a = -29;
test2.position_enumerator(a);
DLIB_CASSERT(test2.element().key() == 0, "");
DLIB_CASSERT(test2.element().value() == 0, "");
DLIB_TEST(test2.element().key() == 0);
DLIB_TEST(test2.element().value() == 0);
a = 8;
test2.position_enumerator(a);
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.element().key() == a, "");
DLIB_CASSERT(test2.element().value() == a, "");
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.element().key() == a);
DLIB_TEST(test2.element().value() == a);
test2.reset();
DLIB_CASSERT(test2.height() > 13 && test2.height() <= 26,"this is somewhat of an implementation dependent "
DLIB_TEST_MSG(test2.height() > 13 && test2.height() <= 26,"this is somewhat of an implementation dependent "
<< "but really it should be in this range or the implementation is just crap");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.size() == 10000,"");
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.size() == 10000);
for (int i = 0; i < 10000; ++i)
{
DLIB_CASSERT(test2.move_next() == true,"");
DLIB_CASSERT(test2.element().key() == i,"");
DLIB_TEST(test2.move_next() == true);
DLIB_TEST(test2.element().key() == i);
}
DLIB_CASSERT(test2.height() > 13 && test2.height() <= 26,"this is somewhat of an implementation dependent "
DLIB_TEST_MSG(test2.height() > 13 && test2.height() <= 26,"this is somewhat of an implementation dependent "
<< "but really it should be in this range or the implementation is just crap");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_CASSERT(test2.size() == 10000,"");
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == true);
DLIB_TEST(test2.size() == 10000);
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.current_element_valid() == false);
a = 3;
test2.add(a,b);
DLIB_CASSERT(test2.count(3) == 2,"");
DLIB_TEST(test2.count(3) == 2);
for (int i = 0; i < 10000; ++i)
{
test2.remove(i,a,b);
DLIB_CASSERT(i == a,"");
DLIB_TEST(i == a);
}
test2.remove(3,a,b);
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2.height() == 0,"");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2.height() == 0);
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == false);
......@@ -403,17 +403,17 @@ namespace
test2.add(a,b);
}
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.move_next() == true,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_CASSERT(test2.move_next() == true,"");
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_CASSERT(test2.move_next() == true,"");
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_CASSERT(test2.move_next() == true,"");
DLIB_CASSERT(test2.current_element_valid() == true,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.move_next() == true);
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == true);
DLIB_TEST(test2.move_next() == true);
DLIB_TEST(test2.current_element_valid() == true);
DLIB_TEST(test2.move_next() == true);
DLIB_TEST(test2.current_element_valid() == true);
DLIB_TEST(test2.move_next() == true);
DLIB_TEST(test2.current_element_valid() == true);
DLIB_TEST(test2.at_start() == false);
for (int i = 0; i < 10000; ++i)
{
......@@ -421,30 +421,30 @@ namespace
test2.position_enumerator(a);
if (test2[a])
{
DLIB_CASSERT(test2.element().key() == a,"");
DLIB_TEST(test2.element().key() == a);
}
else if (a <= m)
{
DLIB_CASSERT(test2.element().key() > a,"");
DLIB_TEST(test2.element().key() > a);
}
}
test2.clear();
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2.height() == 0,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2.height() == 0);
for (int i = 0; i < 20000; ++i)
......@@ -455,7 +455,7 @@ namespace
}
DLIB_CASSERT(test2.size() == 20000,"");
DLIB_TEST(test2.size() == 20000);
......@@ -467,7 +467,7 @@ namespace
if (test2[a] != 0)
{
test2.remove(a,b,c);
DLIB_CASSERT(a == b,"");
DLIB_TEST(a == b);
}
}
......@@ -485,24 +485,24 @@ namespace
{
int* array = new int[test2.size()];
int* tmp = array;
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_TEST(test2.at_start() == true);
while (test2.move_next())
{
*tmp = test2.element().key();
++tmp;
}
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
tmp = array;
for (int i = 0; i < 10000; ++i)
{
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_CASSERT(*const_cast<const bst&>(test2)[*tmp] == *tmp,"");
DLIB_TEST(*test2[*tmp] == *tmp);
DLIB_TEST(*test2[*tmp] == *tmp);
DLIB_TEST(*test2[*tmp] == *tmp);
DLIB_TEST(*const_cast<const bst&>(test2)[*tmp] == *tmp);
++tmp;
}
......@@ -511,14 +511,14 @@ namespace
{
unsigned long count = test2.count(*tmp);
test2.destroy(*tmp);
DLIB_CASSERT(test2.count(*tmp)+1 == count,"");
DLIB_TEST(test2.count(*tmp)+1 == count);
++tmp;
}
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.at_start() == false);
test.swap(test2);
test.reset();
......@@ -526,14 +526,14 @@ namespace
}
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.height() == 0,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.height() == 0);
for (unsigned long i = 1; i < 100; ++i)
{
a = 1234;
test.add(a,b);
DLIB_CASSERT(test.count(1234) == i,"");
DLIB_TEST(test.count(1234) == i);
}
test.clear();
......@@ -548,20 +548,20 @@ namespace
test2.clear();
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2.height() == 0,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2.height() == 0);
int counter = 0;
......@@ -579,7 +579,7 @@ namespace
DLIB_CASSERT(test2.size() == 10000,"");
DLIB_TEST(test2.size() == 10000);
......@@ -590,7 +590,7 @@ namespace
if (test2[a] != 0)
{
test2.remove(a,b,c);
DLIB_CASSERT(a == b,"");
DLIB_TEST(a == b);
}
}
......@@ -611,7 +611,7 @@ namespace
int* array_val = new int[test2.size()];
int* tmp = array;
int* tmp_val = array_val;
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_TEST(test2.at_start() == true);
int count = 0;
while (test2.move_next())
{
......@@ -620,23 +620,23 @@ namespace
*tmp_val = test2.element().value();
++tmp_val;
DLIB_CASSERT(*test2[*(tmp-1)] == *(tmp_val-1),"");
DLIB_TEST(*test2[*(tmp-1)] == *(tmp_val-1));
++count;
}
DLIB_CASSERT(count == (int)test2.size(),"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_TEST(count == (int)test2.size());
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
tmp = array;
tmp_val = array_val;
for (unsigned long i = 0; i < test2.size(); ++i)
{
DLIB_CASSERT(*test2[*tmp] == *tmp_val,i);
DLIB_CASSERT(*test2[*tmp] == *tmp_val,"");
DLIB_CASSERT(*test2[*tmp] == *tmp_val,"");
DLIB_CASSERT(*const_cast<const bst&>(test2)[*tmp] == *tmp_val,"");
DLIB_TEST_MSG(*test2[*tmp] == *tmp_val,i);
DLIB_TEST(*test2[*tmp] == *tmp_val);
DLIB_TEST(*test2[*tmp] == *tmp_val);
DLIB_TEST(*const_cast<const bst&>(test2)[*tmp] == *tmp_val);
++tmp;
++tmp_val;
}
......@@ -649,14 +649,14 @@ namespace
{
unsigned long count = test2.count(*tmp);
test2.destroy(*tmp);
DLIB_CASSERT(test2.count(*tmp)+1 == count,"");
DLIB_TEST(test2.count(*tmp)+1 == count);
++tmp;
}
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_TEST(test2.at_start() == true);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.at_start() == false);
test.swap(test2);
test.reset();
......@@ -665,14 +665,14 @@ namespace
}
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.height() == 0,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.height() == 0);
for (unsigned long i = 1; i < 100; ++i)
{
a = 1234;
test.add(a,b);
DLIB_CASSERT(test.count(1234) == i,"");
DLIB_TEST(test.count(1234) == i);
}
test.clear();
......@@ -689,14 +689,14 @@ namespace
test.position_enumerator(0);
a = 0;
b = 0;
DLIB_CASSERT(test.height() == 1,"");
DLIB_TEST(test.height() == 1);
test.remove_current_element(a,b);
DLIB_CASSERT(a == 1, "");
DLIB_CASSERT(b == 2, "");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.height() == 0,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(a == 1);
DLIB_TEST(b == 2);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.height() == 0);
DLIB_TEST(test.size() == 0);
a = 1;
......@@ -709,22 +709,22 @@ namespace
test.position_enumerator(0);
a = 0;
b = 0;
DLIB_CASSERT(test.height() == 2,"");
DLIB_TEST(test.height() == 2);
test.remove_current_element(a,b);
DLIB_CASSERT(a == 1, "");
DLIB_CASSERT(b == 2, "");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_CASSERT(test.height() == 1,"");
DLIB_CASSERT(test.size() == 1,"");
DLIB_TEST(a == 1);
DLIB_TEST(b == 2);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == true);
DLIB_TEST(test.height() == 1);
DLIB_TEST(test.size() == 1);
test.remove_current_element(a,b);
DLIB_CASSERT(a == 1, "");
DLIB_CASSERT(b == 2, "");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.height() == 0,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(a == 1);
DLIB_TEST(b == 2);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.height() == 0);
DLIB_TEST(test.size() == 0);
for (int i = 0; i < 100; ++i)
{
......@@ -733,96 +733,96 @@ namespace
test.add(a,b);
}
DLIB_CASSERT(test.size() == 100,"");
DLIB_TEST(test.size() == 100);
test.remove_last_in_order(a,b);
DLIB_CASSERT(a == 99, "");
DLIB_CASSERT(b == 99, "");
DLIB_CASSERT(test.size() == 99,"");
DLIB_TEST(a == 99);
DLIB_TEST(b == 99);
DLIB_TEST(test.size() == 99);
test.remove_last_in_order(a,b);
DLIB_CASSERT(a == 98, "");
DLIB_CASSERT(b == 98, "");
DLIB_CASSERT(test.size() == 98,"");
DLIB_TEST(a == 98);
DLIB_TEST(b == 98);
DLIB_TEST(test.size() == 98);
test.position_enumerator(-10);
for (int i = 0; i < 97; ++i)
{
DLIB_CASSERT(test.element().key() == i, "");
DLIB_CASSERT(test.element().value() == i, "");
DLIB_CASSERT(test.move_next(), "");
DLIB_TEST(test.element().key() == i);
DLIB_TEST(test.element().value() == i);
DLIB_TEST(test.move_next());
}
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.current_element_valid() == false);
test.position_enumerator(10);
for (int i = 10; i < 97; ++i)
{
DLIB_CASSERT(test.element().key() == i, "");
DLIB_CASSERT(test.element().value() == i, "");
DLIB_CASSERT(test.move_next(), "");
DLIB_TEST(test.element().key() == i);
DLIB_TEST(test.element().value() == i);
DLIB_TEST(test.move_next());
}
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.current_element_valid() == false);
test.reset();
DLIB_CASSERT(test.at_start(),"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.at_start());
DLIB_TEST(test.current_element_valid() == false);
for (int i = 0; i < 98; ++i)
{
DLIB_CASSERT(test.move_next(), "");
DLIB_CASSERT(test.element().key() == i, "");
DLIB_CASSERT(test.element().value() == i, "");
DLIB_TEST(test.move_next());
DLIB_TEST(test.element().key() == i);
DLIB_TEST(test.element().value() == i);
}
DLIB_CASSERT(test.size() == 98, test.size());
DLIB_CASSERT(test.move_next() == false,"");
DLIB_TEST_MSG(test.size() == 98, test.size());
DLIB_TEST(test.move_next() == false);
test.position_enumerator(98);
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
test.position_enumerator(50);
DLIB_CASSERT(test.element().key() == 50,"");
DLIB_CASSERT(test.element().value() == 50,"");
DLIB_CASSERT(test[50] != 0,"");
DLIB_TEST(test.element().key() == 50);
DLIB_TEST(test.element().value() == 50);
DLIB_TEST(test[50] != 0);
test.remove_current_element(a,b);
DLIB_CASSERT(test[50] == 0,"");
DLIB_CASSERT(test.size() == 97, test.size());
DLIB_CASSERT(a == 50,"");
DLIB_CASSERT(b == 50,"");
DLIB_CASSERT(test.element().key() == 51,"");
DLIB_CASSERT(test.element().value() == 51,"");
DLIB_CASSERT(test.current_element_valid(),"");
DLIB_TEST(test[50] == 0);
DLIB_TEST_MSG(test.size() == 97, test.size());
DLIB_TEST(a == 50);
DLIB_TEST(b == 50);
DLIB_TEST(test.element().key() == 51);
DLIB_TEST(test.element().value() == 51);
DLIB_TEST(test.current_element_valid());
test.remove_current_element(a,b);
DLIB_CASSERT(test.size() == 96, test.size());
DLIB_CASSERT(a == 51,"");
DLIB_CASSERT(b == 51,"");
DLIB_CASSERT(test.element().key() == 52,test.element().key());
DLIB_CASSERT(test.element().value() == 52,test.element().value());
DLIB_CASSERT(test.current_element_valid(),"");
DLIB_TEST_MSG(test.size() == 96, test.size());
DLIB_TEST(a == 51);
DLIB_TEST(b == 51);
DLIB_TEST_MSG(test.element().key() == 52,test.element().key());
DLIB_TEST_MSG(test.element().value() == 52,test.element().value());
DLIB_TEST(test.current_element_valid());
test.remove_current_element(a,b);
DLIB_CASSERT(test.size() == 95, test.size());
DLIB_CASSERT(a == 52,"");
DLIB_CASSERT(b == 52,"");
DLIB_CASSERT(test.element().key() == 53,test.element().key());
DLIB_CASSERT(test.element().value() == 53,test.element().value());
DLIB_CASSERT(test.current_element_valid(),"");
DLIB_TEST_MSG(test.size() == 95, test.size());
DLIB_TEST(a == 52);
DLIB_TEST(b == 52);
DLIB_TEST_MSG(test.element().key() == 53,test.element().key());
DLIB_TEST_MSG(test.element().value() == 53,test.element().value());
DLIB_TEST(test.current_element_valid());
test.position_enumerator(50);
DLIB_CASSERT(test.element().key() == 53,test.element().key());
DLIB_CASSERT(test.element().value() == 53,test.element().value());
DLIB_CASSERT(test.current_element_valid(),"");
DLIB_TEST_MSG(test.element().key() == 53,test.element().key());
DLIB_TEST_MSG(test.element().value() == 53,test.element().value());
DLIB_TEST(test.current_element_valid());
test.position_enumerator(51);
DLIB_CASSERT(test.element().key() == 53,test.element().key());
DLIB_CASSERT(test.element().value() == 53,test.element().value());
DLIB_CASSERT(test.current_element_valid(),"");
DLIB_TEST_MSG(test.element().key() == 53,test.element().key());
DLIB_TEST_MSG(test.element().value() == 53,test.element().value());
DLIB_TEST(test.current_element_valid());
test.position_enumerator(52);
DLIB_CASSERT(test.element().key() == 53,test.element().key());
DLIB_CASSERT(test.element().value() == 53,test.element().value());
DLIB_CASSERT(test.current_element_valid(),"");
DLIB_TEST_MSG(test.element().key() == 53,test.element().key());
DLIB_TEST_MSG(test.element().value() == 53,test.element().value());
DLIB_TEST(test.current_element_valid());
test.position_enumerator(53);
DLIB_CASSERT(test.element().key() == 53,test.element().key());
DLIB_CASSERT(test.element().value() == 53,test.element().value());
DLIB_CASSERT(test.current_element_valid(),"");
DLIB_TEST_MSG(test.element().key() == 53,test.element().key());
DLIB_TEST_MSG(test.element().value() == 53,test.element().value());
DLIB_TEST(test.current_element_valid());
test.reset();
test.move_next();
......@@ -834,16 +834,16 @@ namespace
int c = test.element().key();
int d = test.element().value();
test.remove_current_element(a,b);
DLIB_CASSERT(c == a,"");
DLIB_CASSERT(d == a,"");
DLIB_CASSERT(lasta < a,"");
DLIB_CASSERT(lastb < b,"");
DLIB_TEST(c == a);
DLIB_TEST(d == a);
DLIB_TEST(lasta < a);
DLIB_TEST(lastb < b);
lasta = a;
lastb = b;
}
DLIB_CASSERT(count == 95, count);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.height() == 0,"");
DLIB_TEST_MSG(count == 95, count);
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.height() == 0);
test.clear();
......@@ -860,17 +860,17 @@ namespace
test.reset();
for (int j = 0; j < num; ++j)
{
DLIB_CASSERT(test.move_next(),"");
DLIB_TEST(test.move_next());
}
DLIB_CASSERT(test.current_element_valid(),"size: " << test.size() << " num: " << num);
DLIB_TEST_MSG(test.current_element_valid(),"size: " << test.size() << " num: " << num);
test.remove_current_element(a,b);
DLIB_CASSERT(test.current_element_valid(),"size: " << test.size() << " num: " << num);
DLIB_TEST_MSG(test.current_element_valid(),"size: " << test.size() << " num: " << num);
test.remove_current_element(a,b);
test.position_enumerator(1);
if (test.current_element_valid())
test.remove_current_element(a,b);
DLIB_CASSERT(a == 1,"");
DLIB_CASSERT(b == 1,"");
DLIB_TEST(a == 1);
DLIB_TEST(b == 1);
}
test.clear();
......
......@@ -48,27 +48,27 @@ namespace
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start(),"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start());
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.parsed_line() == false,"");
DLIB_CASSERT(test.option_is_defined(_dT(ct,"a")) == false,"");
DLIB_CASSERT(test.option_is_defined(_dT(ct,"a")) == false,"");
DLIB_CASSERT(test.option_is_defined(_dT(ct,"a")) == false,"");
DLIB_TEST(test.parsed_line() == false);
DLIB_TEST(test.option_is_defined(_dT(ct,"a")) == false);
DLIB_TEST(test.option_is_defined(_dT(ct,"a")) == false);
DLIB_TEST(test.option_is_defined(_dT(ct,"a")) == false);
DLIB_CASSERT(test.parsed_line() == false,"");
DLIB_CASSERT(test.option_is_defined(_dT(ct,"a")) == false,"");
DLIB_CASSERT(test.option_is_defined(_dT(ct,"b")) == false,"");
DLIB_CASSERT(test.option_is_defined(_dT(ct,"\0")) == false,"");
DLIB_TEST(test.parsed_line() == false);
DLIB_TEST(test.option_is_defined(_dT(ct,"a")) == false);
DLIB_TEST(test.option_is_defined(_dT(ct,"b")) == false);
DLIB_TEST(test.option_is_defined(_dT(ct,"\0")) == false);
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.current_element_valid() == false);
......@@ -94,24 +94,24 @@ namespace
try { test.parse(argc,argv); }
catch (error& e)
{
DLIB_CASSERT(false,e.info);
DLIB_TEST_MSG(false,e.info);
}
DLIB_CASSERT(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).name() == _dT(ct,"c"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).number_of_arguments() == 0,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).number_of_arguments() == 0,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.number_of_arguments() == 2,"");
DLIB_CASSERT(test[0] == _dT(ct,"arg1"),"");
DLIB_CASSERT(test[1] == _dT(ct,"arg2"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).count()==0,"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).count()==1,test.option(_dT(ct,"c")).count());
DLIB_CASSERT(test.option(_dT(ct,"Z")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"),"");
DLIB_TEST(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"));
DLIB_TEST(test.option(_dT(ct,"c")).name() == _dT(ct,"c"));
DLIB_TEST(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"));
DLIB_TEST(test.option(_dT(ct,"davis")).number_of_arguments() == 0);
DLIB_TEST(test.option(_dT(ct,"c")).number_of_arguments() == 0);
DLIB_TEST(test.option(_dT(ct,"Z")).number_of_arguments() == 2);
DLIB_TEST(test.number_of_arguments() == 2);
DLIB_TEST(test[0] == _dT(ct,"arg1"));
DLIB_TEST(test[1] == _dT(ct,"arg2"));
DLIB_TEST(test.option(_dT(ct,"d")).count()==0);
DLIB_TEST(test.option(_dT(ct,"davis")).count()==1);
DLIB_TEST_MSG(test.option(_dT(ct,"c")).count()==1,test.option(_dT(ct,"c")).count());
DLIB_TEST(test.option(_dT(ct,"Z")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"));
DLIB_TEST(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"));
}
......@@ -142,24 +142,24 @@ namespace
try { test2.parse(argc,argv); }
catch (error& e)
{
DLIB_CASSERT(false,e.info);
}
DLIB_CASSERT(test2.option(_dT(ct,"davis")).name() == _dT(ct,"davis"),"");
DLIB_CASSERT(test2.option(_dT(ct,"c")).name() == _dT(ct,"c"),"");
DLIB_CASSERT(test2.option(_dT(ct,"Z")).name() == _dT(ct,"Z"),"");
DLIB_CASSERT(test2.option(_dT(ct,"davis")).number_of_arguments() == 0,"");
DLIB_CASSERT(test2.option(_dT(ct,"c")).number_of_arguments() == 0,"");
DLIB_CASSERT(test2.option(_dT(ct,"Z")).number_of_arguments() == 2,"");
DLIB_CASSERT(test2.number_of_arguments() == 2,"");
DLIB_CASSERT(test2[0] == _dT(ct,"arg1"),"");
DLIB_CASSERT(test2[1] == _dT(ct,"arg2"),"");
DLIB_CASSERT(test2.option(_dT(ct,"d")).count()==0,"");
DLIB_CASSERT(test2.option(_dT(ct,"davis")).count()==1,"");
DLIB_CASSERT(test2.option(_dT(ct,"c")).count()==1,"");
DLIB_CASSERT(test2.option(_dT(ct,"Z")).count()==1,"");
DLIB_CASSERT(test2.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"),"");
DLIB_CASSERT(test2.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"),
DLIB_TEST_MSG(false,e.info);
}
DLIB_TEST(test2.option(_dT(ct,"davis")).name() == _dT(ct,"davis"));
DLIB_TEST(test2.option(_dT(ct,"c")).name() == _dT(ct,"c"));
DLIB_TEST(test2.option(_dT(ct,"Z")).name() == _dT(ct,"Z"));
DLIB_TEST(test2.option(_dT(ct,"davis")).number_of_arguments() == 0);
DLIB_TEST(test2.option(_dT(ct,"c")).number_of_arguments() == 0);
DLIB_TEST(test2.option(_dT(ct,"Z")).number_of_arguments() == 2);
DLIB_TEST(test2.number_of_arguments() == 2);
DLIB_TEST(test2[0] == _dT(ct,"arg1"));
DLIB_TEST(test2[1] == _dT(ct,"arg2"));
DLIB_TEST(test2.option(_dT(ct,"d")).count()==0);
DLIB_TEST(test2.option(_dT(ct,"davis")).count()==1);
DLIB_TEST(test2.option(_dT(ct,"c")).count()==1);
DLIB_TEST(test2.option(_dT(ct,"Z")).count()==1);
DLIB_TEST(test2.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"));
DLIB_TEST_MSG(test2.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"),
narrow(_dT(ct,"*") + test2.option(_dT(ct,"Z")).argument(0,0) + _dT(ct,"*")));
......@@ -193,10 +193,10 @@ namespace
try { test.parse(argc,argv); }
catch (error& e)
{
DLIB_CASSERT(false,e.info);
DLIB_TEST_MSG(false,e.info);
}
DLIB_CASSERT(test.parsed_line(),"");
DLIB_TEST(test.parsed_line());
int count = 0;
while (test.move_next())
......@@ -204,33 +204,33 @@ namespace
++count;
if (test.element().name() == _dT(ct,"d"))
{
DLIB_CASSERT(test.element().count() == 0,"");
DLIB_TEST(test.element().count() == 0);
}
else
{
DLIB_CASSERT(test.element().count() == 1,"");
}
}
DLIB_CASSERT(count == 4,count);
DLIB_CASSERT(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).name() == _dT(ct,"c"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).number_of_arguments() == 0,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.number_of_arguments() == 2,"");
DLIB_CASSERT(test[0] == _dT(ct,"arg1"),"");
DLIB_CASSERT(test[1] == _dT(ct,"arg2"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).count()==0,"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).argument(0,0) == _dT(ct,"darg"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).argument(1,0) == _dT(ct,"darg2"),
DLIB_TEST(test.element().count() == 1);
}
}
DLIB_TEST_MSG(count == 4,count);
DLIB_TEST(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"));
DLIB_TEST(test.option(_dT(ct,"c")).name() == _dT(ct,"c"));
DLIB_TEST(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"));
DLIB_TEST(test.option(_dT(ct,"davis")).number_of_arguments() == 2);
DLIB_TEST(test.option(_dT(ct,"c")).number_of_arguments() == 0);
DLIB_TEST(test.option(_dT(ct,"Z")).number_of_arguments() == 2);
DLIB_TEST(test.number_of_arguments() == 2);
DLIB_TEST(test[0] == _dT(ct,"arg1"));
DLIB_TEST(test[1] == _dT(ct,"arg2"));
DLIB_TEST(test.option(_dT(ct,"d")).count()==0);
DLIB_TEST(test.option(_dT(ct,"davis")).count()==1);
DLIB_TEST(test.option(_dT(ct,"c")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"));
DLIB_TEST(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"));
DLIB_TEST(test.option(_dT(ct,"davis")).argument(0,0) == _dT(ct,"darg"));
DLIB_TEST_MSG(test.option(_dT(ct,"davis")).argument(1,0) == _dT(ct,"darg2"),
narrow(test.option(_dT(ct,"davis")).argument(1,0)));
}
......@@ -274,10 +274,10 @@ namespace
try { test.parse(argc,argv); }
catch (error& e)
{
DLIB_CASSERT(false,e.info);
DLIB_TEST_MSG(false,e.info);
}
DLIB_CASSERT(test.parsed_line(),"");
DLIB_TEST(test.parsed_line());
int count = 0;
while (test.move_next())
......@@ -285,33 +285,33 @@ namespace
++count;
if (test.element().name() == _dT(ct,"d"))
{
DLIB_CASSERT(test.element().count() == 0,"");
DLIB_TEST(test.element().count() == 0);
}
else
{
DLIB_CASSERT(test.element().count() == 1,"");
}
}
DLIB_CASSERT(count == 4,count);
DLIB_CASSERT(test.option(_dT(ct,"dav-is")).name() == _dT(ct,"dav-is"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).name() == _dT(ct,"c"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"),"");
DLIB_CASSERT(test.option(_dT(ct,"dav-is")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).number_of_arguments() == 0,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.number_of_arguments() == 2,"");
DLIB_CASSERT(test[0] == _dT(ct,"arg1"),"");
DLIB_CASSERT(test[1] == _dT(ct,"arg2"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).count()==0,"");
DLIB_CASSERT(test.option(_dT(ct,"dav-is")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"),"");
DLIB_CASSERT(test.option(_dT(ct,"dav-is")).argument(0,0) == _dT(ct,"darg"),"");
DLIB_CASSERT(test.option(_dT(ct,"dav-is")).argument(1,0) == _dT(ct,"darg2"),
DLIB_TEST(test.element().count() == 1);
}
}
DLIB_TEST_MSG(count == 4,count);
DLIB_TEST(test.option(_dT(ct,"dav-is")).name() == _dT(ct,"dav-is"));
DLIB_TEST(test.option(_dT(ct,"c")).name() == _dT(ct,"c"));
DLIB_TEST(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"));
DLIB_TEST(test.option(_dT(ct,"dav-is")).number_of_arguments() == 2);
DLIB_TEST(test.option(_dT(ct,"c")).number_of_arguments() == 0);
DLIB_TEST(test.option(_dT(ct,"Z")).number_of_arguments() == 2);
DLIB_TEST(test.number_of_arguments() == 2);
DLIB_TEST(test[0] == _dT(ct,"arg1"));
DLIB_TEST(test[1] == _dT(ct,"arg2"));
DLIB_TEST(test.option(_dT(ct,"d")).count()==0);
DLIB_TEST(test.option(_dT(ct,"dav-is")).count()==1);
DLIB_TEST(test.option(_dT(ct,"c")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"));
DLIB_TEST(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"));
DLIB_TEST(test.option(_dT(ct,"dav-is")).argument(0,0) == _dT(ct,"darg"));
DLIB_TEST_MSG(test.option(_dT(ct,"dav-is")).argument(1,0) == _dT(ct,"darg2"),
narrow(test.option(_dT(ct,"dav-is")).argument(1,0)));
}
......@@ -354,10 +354,10 @@ namespace
try { test.parse(argc,argv); }
catch (error& e)
{
DLIB_CASSERT(false,e.info);
DLIB_TEST_MSG(false,e.info);
}
DLIB_CASSERT(test.parsed_line(),"");
DLIB_TEST(test.parsed_line());
int count = 0;
while (test.move_next())
......@@ -365,33 +365,33 @@ namespace
++count;
if (test.element().name() == _dT(ct,"d"))
{
DLIB_CASSERT(test.element().count() == 0,"");
DLIB_TEST(test.element().count() == 0);
}
else
{
DLIB_CASSERT(test.element().count() == 1,"");
}
}
DLIB_CASSERT(count == 4,count);
DLIB_CASSERT(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).name() == _dT(ct,"c"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).number_of_arguments() == 0,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.number_of_arguments() == 2,"");
DLIB_CASSERT(test[0] == _dT(ct,"arg1"),"");
DLIB_CASSERT(test[1] == _dT(ct,"arg2"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).count()==0,"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).argument(0,0) == _dT(ct,"darg"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).argument(1,0) == _dT(ct,"darg2"),
DLIB_TEST(test.element().count() == 1);
}
}
DLIB_TEST_MSG(count == 4,count);
DLIB_TEST(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"));
DLIB_TEST(test.option(_dT(ct,"c")).name() == _dT(ct,"c"));
DLIB_TEST(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"));
DLIB_TEST(test.option(_dT(ct,"davis")).number_of_arguments() == 2);
DLIB_TEST(test.option(_dT(ct,"c")).number_of_arguments() == 0);
DLIB_TEST(test.option(_dT(ct,"Z")).number_of_arguments() == 2);
DLIB_TEST(test.number_of_arguments() == 2);
DLIB_TEST(test[0] == _dT(ct,"arg1"));
DLIB_TEST(test[1] == _dT(ct,"arg2"));
DLIB_TEST(test.option(_dT(ct,"d")).count()==0);
DLIB_TEST(test.option(_dT(ct,"davis")).count()==1);
DLIB_TEST(test.option(_dT(ct,"c")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"));
DLIB_TEST(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"));
DLIB_TEST(test.option(_dT(ct,"davis")).argument(0,0) == _dT(ct,"darg"));
DLIB_TEST_MSG(test.option(_dT(ct,"davis")).argument(1,0) == _dT(ct,"darg2"),
narrow(test.option(_dT(ct,"davis")).argument(1,0)));
}
......@@ -433,10 +433,10 @@ namespace
try { test.parse(argc,argv); }
catch (error& e)
{
DLIB_CASSERT(false,e.info);
DLIB_TEST_MSG(false,e.info);
}
DLIB_CASSERT(test.parsed_line(),"");
DLIB_TEST(test.parsed_line());
int count = 0;
while (test.move_next())
......@@ -444,32 +444,32 @@ namespace
++count;
if (test.element().name() == _dT(ct,"d"))
{
DLIB_CASSERT(test.element().count() == 0,"");
DLIB_TEST(test.element().count() == 0);
}
else
{
DLIB_CASSERT(test.element().count() == 1,"");
DLIB_TEST(test.element().count() == 1);
}
}
DLIB_CASSERT(count == 4,count);
DLIB_TEST_MSG(count == 4,count);
DLIB_CASSERT(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).name() == _dT(ct,"c"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).number_of_arguments() == 1,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).number_of_arguments() == 0,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.number_of_arguments() == 2,"");
DLIB_CASSERT(test[0] == _dT(ct,"arg1"),"");
DLIB_CASSERT(test[1] == _dT(ct,"arg2"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).count()==0,"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).argument(0,0) == _dT(ct,"darg"),"");
DLIB_TEST(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"));
DLIB_TEST(test.option(_dT(ct,"c")).name() == _dT(ct,"c"));
DLIB_TEST(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"));
DLIB_TEST(test.option(_dT(ct,"davis")).number_of_arguments() == 1);
DLIB_TEST(test.option(_dT(ct,"c")).number_of_arguments() == 0);
DLIB_TEST(test.option(_dT(ct,"Z")).number_of_arguments() == 2);
DLIB_TEST(test.number_of_arguments() == 2);
DLIB_TEST(test[0] == _dT(ct,"arg1"));
DLIB_TEST(test[1] == _dT(ct,"arg2"));
DLIB_TEST(test.option(_dT(ct,"d")).count()==0);
DLIB_TEST(test.option(_dT(ct,"davis")).count()==1);
DLIB_TEST(test.option(_dT(ct,"c")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"));
DLIB_TEST(test.option(_dT(ct,"Z")).argument(1,0) == _dT(ct,"asdf"));
DLIB_TEST(test.option(_dT(ct,"davis")).argument(0,0) == _dT(ct,"darg"));
}
......@@ -510,10 +510,10 @@ namespace
try { test.parse(argc,argv); }
catch (error& e)
{
DLIB_CASSERT(false,e.info);
DLIB_TEST_MSG(false,e.info);
}
DLIB_CASSERT(test.parsed_line(),"");
DLIB_TEST(test.parsed_line());
int count = 0;
while (test.move_next())
......@@ -521,32 +521,32 @@ namespace
++count;
if (test.element().name() == _dT(ct,"d"))
{
DLIB_CASSERT(test.element().count() == 0,"");
DLIB_TEST(test.element().count() == 0);
}
else
{
DLIB_CASSERT(test.element().count() == 1,"");
DLIB_TEST(test.element().count() == 1);
}
}
DLIB_CASSERT(count == 4,count);
DLIB_TEST_MSG(count == 4,count);
DLIB_CASSERT(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).name() == _dT(ct,"c"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).number_of_arguments() == 1,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).number_of_arguments() == 0,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).number_of_arguments() == 2,"");
DLIB_CASSERT(test.number_of_arguments() == 2,"");
DLIB_CASSERT(test[0] == _dT(ct,"arg1"),"");
DLIB_CASSERT(test[1] == _dT(ct,"arg2"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).count()==0,"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"c")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(1) == _dT(ct,"asdf"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).argument(0,0) == _dT(ct,"darg"),"");
DLIB_TEST(test.option(_dT(ct,"davis")).name() == _dT(ct,"davis"));
DLIB_TEST(test.option(_dT(ct,"c")).name() == _dT(ct,"c"));
DLIB_TEST(test.option(_dT(ct,"Z")).name() == _dT(ct,"Z"));
DLIB_TEST(test.option(_dT(ct,"davis")).number_of_arguments() == 1);
DLIB_TEST(test.option(_dT(ct,"c")).number_of_arguments() == 0);
DLIB_TEST(test.option(_dT(ct,"Z")).number_of_arguments() == 2);
DLIB_TEST(test.number_of_arguments() == 2);
DLIB_TEST(test[0] == _dT(ct,"arg1"));
DLIB_TEST(test[1] == _dT(ct,"arg2"));
DLIB_TEST(test.option(_dT(ct,"d")).count()==0);
DLIB_TEST(test.option(_dT(ct,"davis")).count()==1);
DLIB_TEST(test.option(_dT(ct,"c")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).count()==1);
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"zarg"));
DLIB_TEST(test.option(_dT(ct,"Z")).argument(1) == _dT(ct,"asdf"));
DLIB_TEST(test.option(_dT(ct,"davis")).argument(0,0) == _dT(ct,"darg"));
}
......@@ -584,11 +584,11 @@ namespace
try { test.parse(argc,argv); }
catch (typename clp::cmd_line_parse_error& e)
{
DLIB_CASSERT(e.type == EINVALID_OPTION,"");
DLIB_CASSERT(e.item == _dT(ct,"avis"),"");
DLIB_TEST(e.type == EINVALID_OPTION);
DLIB_TEST(e.item == _dT(ct,"avis"));
ok = true;
}
DLIB_CASSERT(ok,"");
DLIB_TEST(ok);
}
......@@ -630,7 +630,7 @@ namespace
ok = false;
test.parse(argc,argv);
DLIB_CASSERT(test.option(_dT(ct,"c")).count()==2,"");
DLIB_TEST(test.option(_dT(ct,"c")).count()==2);
}
......@@ -669,10 +669,10 @@ namespace
test.add_option(_dT(ct,"Z"),_dT(ct,"Z option"),2);
DLIB_CASSERT(test.option(_dT(ct,"davis")).description() == _dT(ct,"davis option"),"");
DLIB_CASSERT(test.option(_dT(ct,"b")).description() == _dT(ct,"b option"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).description() == _dT(ct,"d option"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).description() == _dT(ct,"Z option"),"");
DLIB_TEST(test.option(_dT(ct,"davis")).description() == _dT(ct,"davis option"));
DLIB_TEST(test.option(_dT(ct,"b")).description() == _dT(ct,"b option"));
DLIB_TEST(test.option(_dT(ct,"d")).description() == _dT(ct,"d option"));
DLIB_TEST(test.option(_dT(ct,"Z")).description() == _dT(ct,"Z option"));
for (int k = 0; k < 5; ++k)
{
......@@ -681,12 +681,12 @@ namespace
try { test.parse(argc,argv); }
catch (typename clp::cmd_line_parse_error& e)
{
DLIB_CASSERT(e.type == ETOO_FEW_ARGS,"");
DLIB_CASSERT(e.num == 2,"");
DLIB_CASSERT(e.item == _dT(ct,"davis"),"");
DLIB_TEST(e.type == ETOO_FEW_ARGS);
DLIB_TEST(e.num == 2);
DLIB_TEST(e.item == _dT(ct,"davis"));
ok = true;
}
DLIB_CASSERT(ok,"");
DLIB_TEST(ok);
......@@ -694,10 +694,10 @@ namespace
while (test.move_next())
{
++count;
DLIB_CASSERT(test.element().count() == 0,"");
DLIB_CASSERT(test.option_is_defined(test.element().name()),"");
DLIB_TEST(test.element().count() == 0);
DLIB_TEST(test.option_is_defined(test.element().name()));
}
DLIB_CASSERT(count == 4,count);
DLIB_TEST_MSG(count == 4,count);
}
......@@ -740,10 +740,10 @@ namespace
test.add_option(_dT(ct,"Z"),_dT(ct,"Z option"),2);
DLIB_CASSERT(test.option(_dT(ct,"mavis")).description() == _dT(ct,"mavis option"),"");
DLIB_CASSERT(test.option(_dT(ct,"b")).description() == _dT(ct,"b option"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).description() == _dT(ct,"d option"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).description() == _dT(ct,"Z option"),"");
DLIB_TEST(test.option(_dT(ct,"mavis")).description() == _dT(ct,"mavis option"));
DLIB_TEST(test.option(_dT(ct,"b")).description() == _dT(ct,"b option"));
DLIB_TEST(test.option(_dT(ct,"d")).description() == _dT(ct,"d option"));
DLIB_TEST(test.option(_dT(ct,"Z")).description() == _dT(ct,"Z option"));
for (int k = 0; k < 5; ++k)
{
......@@ -752,11 +752,11 @@ namespace
try { test.parse(argc,argv); }
catch (typename clp::cmd_line_parse_error& e)
{
DLIB_CASSERT(e.type == EINVALID_OPTION,"");
DLIB_CASSERT(e.item == _dT(ct,"davis"),"");
DLIB_TEST(e.type == EINVALID_OPTION);
DLIB_TEST(e.item == _dT(ct,"davis"));
ok = true;
}
DLIB_CASSERT(ok,"");
DLIB_TEST(ok);
......@@ -764,10 +764,10 @@ namespace
while (test.move_next())
{
++count;
DLIB_CASSERT(test.element().count() == 0,"");
DLIB_CASSERT(test.option_is_defined(test.element().name()),"");
DLIB_TEST(test.element().count() == 0);
DLIB_TEST(test.option_is_defined(test.element().name()));
}
DLIB_CASSERT(count == 4,count);
DLIB_TEST_MSG(count == 4,count);
}
......@@ -799,10 +799,10 @@ namespace
test.add_option(_dT(ct,"Z"),_dT(ct,"Z option"),2);
DLIB_CASSERT(test.option(_dT(ct,"davis")).description() == _dT(ct,"davis option"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).description() == _dT(ct,"c option"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).description() == _dT(ct,"d option"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).description() == _dT(ct,"Z option"),"");
DLIB_TEST(test.option(_dT(ct,"davis")).description() == _dT(ct,"davis option"));
DLIB_TEST(test.option(_dT(ct,"c")).description() == _dT(ct,"c option"));
DLIB_TEST(test.option(_dT(ct,"d")).description() == _dT(ct,"d option"));
DLIB_TEST(test.option(_dT(ct,"Z")).description() == _dT(ct,"Z option"));
for (int k = 0; k < 5; ++k)
{
......@@ -810,16 +810,16 @@ namespace
test.parse(argc,argv);
DLIB_CASSERT(test.number_of_arguments() == 0,"");
DLIB_TEST(test.number_of_arguments() == 0);
int count = 0;
while (test.move_next())
{
++count;
DLIB_CASSERT(test.element().count() == 0,"");
DLIB_CASSERT(test.option_is_defined(test.element().name()),"");
DLIB_TEST(test.element().count() == 0);
DLIB_TEST(test.option_is_defined(test.element().name()));
}
DLIB_CASSERT(count == 4,count);
DLIB_TEST_MSG(count == 4,count);
}
......@@ -860,31 +860,31 @@ namespace
test.add_option(_dT(ct,"Z"),_dT(ct,"Z option"),1);
DLIB_CASSERT(test.option(_dT(ct,"davis")).description() == _dT(ct,"davis option"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).description() == _dT(ct,"c option"),"");
DLIB_CASSERT(test.option(_dT(ct,"d")).description() == _dT(ct,"d option"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).description() == _dT(ct,"Z option"),"");
DLIB_TEST(test.option(_dT(ct,"davis")).description() == _dT(ct,"davis option"));
DLIB_TEST(test.option(_dT(ct,"c")).description() == _dT(ct,"c option"));
DLIB_TEST(test.option(_dT(ct,"d")).description() == _dT(ct,"d option"));
DLIB_TEST(test.option(_dT(ct,"Z")).description() == _dT(ct,"Z option"));
for (int k = 0; k < 5; ++k)
{
test.parse(argc,argv);
DLIB_CASSERT(test.number_of_arguments() == 4,test.number_of_arguments());
DLIB_CASSERT(test[0] == _dT(ct,"arg1"),"");
DLIB_CASSERT(test[1] == _dT(ct,"arg2"),"");
DLIB_CASSERT(test[2] == _dT(ct,"-c"),"");
DLIB_CASSERT(test[3] == _dT(ct,"asdf"),"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).count()==1,"");
DLIB_CASSERT(test.option(_dT(ct,"davis")).argument() == _dT(ct,"-darg"),"");
DLIB_CASSERT(test.option(_dT(ct,"c")).count()==0,"");
DLIB_CASSERT(test.option(_dT(ct,"d")).count()==0,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).count()==3,"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"eat"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,1) == _dT(ct,"at"),"");
DLIB_CASSERT(test.option(_dT(ct,"Z")).argument(0,2) == _dT(ct,"joe's"),"");
DLIB_TEST_MSG(test.number_of_arguments() == 4,test.number_of_arguments());
DLIB_TEST(test[0] == _dT(ct,"arg1"));
DLIB_TEST(test[1] == _dT(ct,"arg2"));
DLIB_TEST(test[2] == _dT(ct,"-c"));
DLIB_TEST(test[3] == _dT(ct,"asdf"));
DLIB_TEST(test.option(_dT(ct,"davis")).count()==1);
DLIB_TEST(test.option(_dT(ct,"davis")).argument() == _dT(ct,"-darg"));
DLIB_TEST(test.option(_dT(ct,"c")).count()==0);
DLIB_TEST(test.option(_dT(ct,"d")).count()==0);
DLIB_TEST(test.option(_dT(ct,"Z")).count()==3);
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,0) == _dT(ct,"eat"));
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,1) == _dT(ct,"at"));
DLIB_TEST(test.option(_dT(ct,"Z")).argument(0,2) == _dT(ct,"joe's"));
}
......
......@@ -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
sin.str(sout.str());
sout.str("");
test.decompress(sin,sout);
DLIB_CASSERT(sout.str() == buffer,"");
DLIB_TEST(sout.str() == buffer);
}
print_spinner();
......@@ -153,7 +153,7 @@ namespace
sout.str("");
test.decompress(sin,sout);
buffer = ch;
DLIB_CASSERT(sout.str() == buffer,"");
DLIB_TEST(sout.str() == buffer);
......@@ -161,7 +161,7 @@ namespace
sout.str("");
test.decompress(sin,sout);
buffer = ch2;
DLIB_CASSERT(sout.str() == buffer,"");
DLIB_TEST(sout.str() == buffer);
}
......@@ -175,7 +175,7 @@ namespace
sin.str(sout.str());
sout.str("");
test.decompress(sin,sout);
DLIB_CASSERT(sout.str() == "",sout.str());
DLIB_TEST_MSG(sout.str() == "",sout.str());
......@@ -206,7 +206,7 @@ namespace
print_spinner();
test.decompress(sin,sout);
DLIB_CASSERT(sout.str() == buffer,"");
DLIB_TEST(sout.str() == buffer);
print_spinner();
}
......@@ -247,7 +247,7 @@ namespace
print_spinner();
test.decompress(sin,sout);
DLIB_CASSERT(sout.str() == buffer,"");
DLIB_TEST(sout.str() == buffer);
print_spinner();
......
......@@ -57,20 +57,20 @@ namespace
cc2 test2(gs2);
DLIB_CASSERT(test.get_memory_usage() != 0,"");
DLIB_TEST(test.get_memory_usage() != 0);
const unsigned long alphabet_size = 2;
DLIB_CASSERT(test.get_total() == 1,"");
DLIB_TEST(test.get_total() == 1);
DLIB_CASSERT(test.get_count(alphabet_size-1)==1,"");
DLIB_TEST(test.get_count(alphabet_size-1)==1);
for (unsigned long i = 0; i < alphabet_size-1; ++i)
{
unsigned long low_count, high_count, total_count;
DLIB_CASSERT(test.get_range(i,low_count,high_count,total_count) == 0,i);
DLIB_CASSERT(test.get_count(i) == 0,"");
DLIB_CASSERT(test.get_total() == 1,"");
DLIB_TEST_MSG(test.get_range(i,low_count,high_count,total_count) == 0,i);
DLIB_TEST(test.get_count(i) == 0);
DLIB_TEST(test.get_total() == 1);
}
......@@ -82,25 +82,25 @@ namespace
if (i ==alphabet_size-1)
{
DLIB_CASSERT(test.get_range(i,low_count,high_count,total_count) == 1+amount,"");
DLIB_TEST(test.get_range(i,low_count,high_count,total_count) == 1+amount);
DLIB_CASSERT(high_count == low_count+1+amount,"");
DLIB_CASSERT(total_count == test.get_total(),"");
DLIB_TEST(high_count == low_count+1+amount);
DLIB_TEST(total_count == test.get_total());
DLIB_CASSERT(test.get_count(i) == 1+amount,"");
DLIB_TEST(test.get_count(i) == 1+amount);
}
else
{
DLIB_CASSERT(test.get_range(i,low_count,high_count,total_count) == amount,"");
DLIB_TEST(test.get_range(i,low_count,high_count,total_count) == amount);
DLIB_CASSERT(high_count == low_count+amount,"");
DLIB_CASSERT(total_count == test.get_total(),"");
DLIB_TEST(high_count == low_count+amount);
DLIB_TEST(total_count == test.get_total());
DLIB_CASSERT(test.get_count(i) == amount,"");
DLIB_TEST(test.get_count(i) == amount);
}
DLIB_CASSERT(test.get_total() == (i+1)*amount + 1,"");
DLIB_TEST(test.get_total() == (i+1)*amount + 1);
}
......@@ -112,11 +112,11 @@ namespace
test.increment_count(i,static_cast<unsigned short>(amount));
if (i == alphabet_size-1)
{
DLIB_CASSERT(test.get_count(i) == (j+1)*amount + 1 + amount,"");
DLIB_TEST(test.get_count(i) == (j+1)*amount + 1 + amount);
}
else
{
DLIB_CASSERT(test.get_count(i) == (j+1)*amount + amount,"");
DLIB_TEST(test.get_count(i) == (j+1)*amount + amount);
}
}
......@@ -125,21 +125,21 @@ namespace
if (i == alphabet_size-1)
{
DLIB_CASSERT(test.get_range(symbol,low_count,high_count,total_count)==temp*amount+1+amount,"");
DLIB_CASSERT(high_count-low_count == temp*amount+1+amount,"");
DLIB_TEST(test.get_range(symbol,low_count,high_count,total_count)==temp*amount+1+amount);
DLIB_TEST(high_count-low_count == temp*amount+1+amount);
}
else
{
DLIB_CASSERT(test.get_range(symbol,low_count,high_count,total_count)==temp*amount + amount,"");
DLIB_CASSERT(high_count-low_count == temp*amount + amount,"");
DLIB_TEST(test.get_range(symbol,low_count,high_count,total_count)==temp*amount + amount);
DLIB_TEST(high_count-low_count == temp*amount + amount);
}
DLIB_CASSERT(total_count == test.get_total(),"");
DLIB_TEST(total_count == test.get_total());
test.get_symbol(target,symbol,low_count,high_count);
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_CASSERT(low_count <= target,"");
DLIB_CASSERT(target < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
DLIB_TEST(low_count <= target);
DLIB_TEST(target < high_count);
DLIB_TEST(high_count <= test.get_total());
}
......@@ -150,13 +150,13 @@ namespace
{
test.increment_count(i);
unsigned long low_count, high_count, total_count;
DLIB_CASSERT(test.get_range(i,low_count,high_count,total_count) == 1,"");
DLIB_TEST(test.get_range(i,low_count,high_count,total_count) == 1);
DLIB_CASSERT(high_count == low_count+1,"");
DLIB_CASSERT(total_count == test.get_total(),"");
DLIB_TEST(high_count == low_count+1);
DLIB_TEST(total_count == test.get_total());
DLIB_CASSERT(test.get_count(i) == 1,"");
DLIB_CASSERT(test.get_total() == i+2,"");
DLIB_TEST(test.get_count(i) == 1);
DLIB_TEST(test.get_total() == i+2);
}
......@@ -212,13 +212,13 @@ namespace
{
temp_total += test.get_count(a);
}
DLIB_CASSERT(temp_total == test.get_total(),
DLIB_TEST_MSG(temp_total == test.get_total(),
"temp_total == " << temp_total << endl <<
"test.get_total() == " << test.get_total()
);
DLIB_CASSERT(test.get_count(alphabet_size-1) == counts[alphabet_size-1],"");
DLIB_CASSERT(test.get_total() == total,
DLIB_TEST(test.get_count(alphabet_size-1) == counts[alphabet_size-1]);
DLIB_TEST_MSG(test.get_total() == total,
"test.get_total() == " << test.get_total() << endl <<
"total == " << total
);
......@@ -227,16 +227,16 @@ namespace
unsigned long symbol = i, low_count = 0, high_count = 0, total_count = 0;
DLIB_CASSERT(test.get_range(symbol,low_count,high_count,total_count)==counts[symbol],"");
DLIB_TEST(test.get_range(symbol,low_count,high_count,total_count)==counts[symbol]);
if (counts[symbol] != 0)
{
DLIB_CASSERT(total_count == total,"");
DLIB_TEST(total_count == total);
DLIB_CASSERT(high_count <= total,"");
DLIB_CASSERT(low_count < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_TEST(high_count <= total);
DLIB_TEST(low_count < high_count);
DLIB_TEST(high_count <= test.get_total());
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
}
......@@ -245,11 +245,11 @@ namespace
test.get_symbol(target,symbol,low_count,high_count);
DLIB_CASSERT(high_count <= total,"");
DLIB_CASSERT(low_count < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_CASSERT(test.get_count(symbol) == counts[symbol],"");
DLIB_TEST(high_count <= total);
DLIB_TEST(low_count < high_count);
DLIB_TEST(high_count <= test.get_total());
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
DLIB_TEST(test.get_count(symbol) == counts[symbol]);
}
......@@ -264,7 +264,7 @@ namespace
for (unsigned long h = 0; h < 10; ++h)
{
test.clear();
DLIB_CASSERT(test.get_total() == 1,"");
DLIB_TEST(test.get_total() == 1);
// fill out test with some numbers
unsigned long temp = ::rand()%30000 + 50000;
......@@ -286,7 +286,7 @@ namespace
{
temp_total += test.get_count(j);
}
DLIB_CASSERT(temp_total == test.get_total(),"");
DLIB_TEST(temp_total == test.get_total());
unsigned long low_counts[alphabet_size];
......@@ -296,8 +296,8 @@ namespace
{
unsigned long total;
unsigned long count = test.get_range(j,low_counts[j],high_counts[j],total);
DLIB_CASSERT(count == test.get_count(j),"");
DLIB_CASSERT(count == high_counts[j] - low_counts[j],"");
DLIB_TEST(count == test.get_count(j));
DLIB_TEST(count == high_counts[j] - low_counts[j]);
}
......@@ -309,8 +309,8 @@ namespace
{
unsigned long symbol, low_count, high_count;
test.get_symbol(k,symbol,low_count,high_count);
DLIB_CASSERT(high_count - low_count == test.get_count(symbol),"");
DLIB_CASSERT(j == symbol,
DLIB_TEST(high_count - low_count == test.get_count(symbol));
DLIB_TEST_MSG(j == symbol,
"j == " << j << endl <<
"k == " << k << endl <<
"symbol == " << symbol << endl <<
......@@ -322,12 +322,12 @@ namespace
"high_count == " << high_count << endl <<
"temp.count(j) == " << test.get_count(j)
);
DLIB_CASSERT(low_count == low_counts[j],
DLIB_TEST_MSG(low_count == low_counts[j],
"symbol: " << j << "\n" <<
"target: " << k << "\n" <<
"low_count: " << low_count << "\n" <<
"low_counts[j]: " << low_counts[j]);
DLIB_CASSERT(high_count == high_counts[j],"");
DLIB_TEST(high_count == high_counts[j]);
}
}
......@@ -378,22 +378,22 @@ namespace
}
DLIB_CASSERT(test.get_total() == total,"");
DLIB_TEST(test.get_total() == total);
unsigned long target = test.get_total()/2;
unsigned long symbol = i, low_count = 0, high_count = 0, total_count = 0;
DLIB_CASSERT(test.get_range(symbol,low_count,high_count,total_count)==counts[symbol],"");
DLIB_TEST(test.get_range(symbol,low_count,high_count,total_count)==counts[symbol]);
if (counts[symbol] != 0)
{
DLIB_CASSERT(total_count == total,"");
DLIB_TEST(total_count == total);
DLIB_CASSERT(high_count <= total,"");
DLIB_CASSERT(low_count < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_TEST(high_count <= total);
DLIB_TEST(low_count < high_count);
DLIB_TEST(high_count <= test.get_total());
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
}
......@@ -401,11 +401,11 @@ namespace
test.get_symbol(target,symbol,low_count,high_count);
DLIB_CASSERT(high_count <= total,"");
DLIB_CASSERT(low_count < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_CASSERT(test.get_count(symbol) == counts[symbol],"");
DLIB_TEST(high_count <= total);
DLIB_TEST(low_count < high_count);
DLIB_TEST(high_count <= test.get_total());
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
DLIB_TEST(test.get_count(symbol) == counts[symbol]);
......@@ -436,20 +436,20 @@ namespace
cc test(gs);
cc test2(gs);
DLIB_CASSERT(test.get_memory_usage() != 0,"");
DLIB_TEST(test.get_memory_usage() != 0);
const unsigned long alphabet_size = 256;
DLIB_CASSERT(test.get_total() == 1,"");
DLIB_TEST(test.get_total() == 1);
DLIB_CASSERT(test.get_count(alphabet_size-1)==1,"");
DLIB_TEST(test.get_count(alphabet_size-1)==1);
for (unsigned long i = 0; i < alphabet_size-1; ++i)
{
unsigned long low_count, high_count, total_count;
DLIB_CASSERT(test.get_range(i,low_count,high_count,total_count) == 0,"");
DLIB_CASSERT(test.get_count(i) == 0,"");
DLIB_CASSERT(test.get_total() == 1,"");
DLIB_TEST(test.get_range(i,low_count,high_count,total_count) == 0);
DLIB_TEST(test.get_count(i) == 0);
DLIB_TEST(test.get_total() == 1);
}
......@@ -465,26 +465,26 @@ namespace
{
if (i ==alphabet_size-1)
{
DLIB_CASSERT(test.get_range(i,low_count,high_count,total_count) == 1+amount,"");
DLIB_TEST(test.get_range(i,low_count,high_count,total_count) == 1+amount);
DLIB_CASSERT(high_count == low_count+1+amount,"");
DLIB_CASSERT(total_count == test.get_total(),"");
DLIB_TEST(high_count == low_count+1+amount);
DLIB_TEST(total_count == test.get_total());
DLIB_CASSERT(test.get_count(i) == 1+amount,"");
DLIB_TEST(test.get_count(i) == 1+amount);
}
else
{
DLIB_CASSERT(test.get_range(i,low_count,high_count,total_count) == amount,"");
DLIB_TEST(test.get_range(i,low_count,high_count,total_count) == amount);
DLIB_CASSERT(high_count == low_count+amount,"");
DLIB_CASSERT(total_count == test.get_total(),"");
DLIB_TEST(high_count == low_count+amount);
DLIB_TEST(total_count == test.get_total());
DLIB_CASSERT(test.get_count(i) == amount,"");
DLIB_TEST(test.get_count(i) == amount);
}
if (!oom)
DLIB_CASSERT(test.get_total() == (i+1)*amount + 1,"");
DLIB_TEST(test.get_total() == (i+1)*amount + 1);
}
}
......@@ -502,11 +502,11 @@ namespace
{
if (i == alphabet_size-1)
{
DLIB_CASSERT(test.get_count(i) == (j+1)*amount + 1 + amount,"");
DLIB_TEST(test.get_count(i) == (j+1)*amount + 1 + amount);
}
else
{
DLIB_CASSERT(test.get_count(i) == (j+1)*amount + amount,"");
DLIB_TEST(test.get_count(i) == (j+1)*amount + amount);
}
}
}
......@@ -518,22 +518,22 @@ namespace
{
if (i == alphabet_size-1)
{
DLIB_CASSERT(test.get_range(symbol,low_count,high_count,total_count)==temp*amount+1+amount,"");
DLIB_CASSERT(high_count-low_count == temp*amount+1+amount,"");
DLIB_TEST(test.get_range(symbol,low_count,high_count,total_count)==temp*amount+1+amount);
DLIB_TEST(high_count-low_count == temp*amount+1+amount);
}
else
{
DLIB_CASSERT(test.get_range(symbol,low_count,high_count,total_count)==temp*amount + amount,"");
DLIB_CASSERT(high_count-low_count == temp*amount + amount,"");
DLIB_TEST(test.get_range(symbol,low_count,high_count,total_count)==temp*amount + amount);
DLIB_TEST(high_count-low_count == temp*amount + amount);
}
DLIB_CASSERT(total_count == test.get_total(),"");
DLIB_TEST(total_count == test.get_total());
test.get_symbol(target,symbol,low_count,high_count);
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_CASSERT(low_count <= target,"");
DLIB_CASSERT(target < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
DLIB_TEST(low_count <= target);
DLIB_TEST(target < high_count);
DLIB_TEST(high_count <= test.get_total());
}
}
......@@ -550,13 +550,13 @@ namespace
if (!oom)
{
DLIB_CASSERT(test.get_range(i,low_count,high_count,total_count) == 1,"");
DLIB_TEST(test.get_range(i,low_count,high_count,total_count) == 1);
DLIB_CASSERT(high_count == low_count+1,"");
DLIB_CASSERT(total_count == test.get_total(),"");
DLIB_TEST(high_count == low_count+1);
DLIB_TEST(total_count == test.get_total());
DLIB_CASSERT(test.get_count(i) == 1,"");
DLIB_CASSERT(test.get_total() == i+2,"");
DLIB_TEST(test.get_count(i) == 1);
DLIB_TEST(test.get_total() == i+2);
}
}
......@@ -617,13 +617,13 @@ namespace
if (!oom)
{
DLIB_CASSERT(temp_total == test.get_total(),
DLIB_TEST_MSG(temp_total == test.get_total(),
"temp_total == " << temp_total << endl <<
"test.get_total() == " << test.get_total()
);
DLIB_CASSERT(test.get_count(alphabet_size-1) == counts[alphabet_size-1],"");
DLIB_CASSERT(test.get_total() == total,
DLIB_TEST(test.get_count(alphabet_size-1) == counts[alphabet_size-1]);
DLIB_TEST_MSG(test.get_total() == total,
"test.get_total() == " << test.get_total() << endl <<
"total == " << total
);
......@@ -635,16 +635,16 @@ namespace
if (!oom)
{
DLIB_CASSERT(test.get_range(symbol,low_count,high_count,total_count)==counts[symbol],"");
DLIB_TEST(test.get_range(symbol,low_count,high_count,total_count)==counts[symbol]);
if (counts[symbol] != 0)
{
DLIB_CASSERT(total_count == total,"");
DLIB_TEST(total_count == total);
DLIB_CASSERT(high_count <= total,"");
DLIB_CASSERT(low_count < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_TEST(high_count <= total);
DLIB_TEST(low_count < high_count);
DLIB_TEST(high_count <= test.get_total());
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
}
......@@ -653,11 +653,11 @@ namespace
test.get_symbol(target,symbol,low_count,high_count);
DLIB_CASSERT(high_count <= total,"");
DLIB_CASSERT(low_count < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_CASSERT(test.get_count(symbol) == counts[symbol],"");
DLIB_TEST(high_count <= total);
DLIB_TEST(low_count < high_count);
DLIB_TEST(high_count <= test.get_total());
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
DLIB_TEST(test.get_count(symbol) == counts[symbol]);
}
}
......@@ -671,7 +671,7 @@ namespace
for (unsigned long h = 0; h < 10; ++h)
{
test.clear();
DLIB_CASSERT(test.get_total() == 1,"");
DLIB_TEST(test.get_total() == 1);
// fill out test with some numbers
unsigned long temp = ::rand()%30000 + 50000;
......@@ -695,7 +695,7 @@ namespace
temp_total += test.get_count(j);
}
if (!oom)
DLIB_CASSERT(temp_total == test.get_total(),"");
DLIB_TEST(temp_total == test.get_total());
unsigned long low_counts[alphabet_size];
......@@ -709,8 +709,8 @@ namespace
{
unsigned long total;
unsigned long count = test.get_range(j,low_counts[j],high_counts[j],total);
DLIB_CASSERT(count == test.get_count(j),"");
DLIB_CASSERT(count == high_counts[j] - low_counts[j],"");
DLIB_TEST(count == test.get_count(j));
DLIB_TEST(count == high_counts[j] - low_counts[j]);
}
......@@ -724,8 +724,8 @@ namespace
{
unsigned long symbol, low_count, high_count;
test.get_symbol(k,symbol,low_count,high_count);
DLIB_CASSERT(high_count - low_count == test.get_count(symbol),"");
DLIB_CASSERT(j == symbol,
DLIB_TEST(high_count - low_count == test.get_count(symbol));
DLIB_TEST_MSG(j == symbol,
"j == " << j << endl <<
"k == " << k << endl <<
"symbol == " << symbol << endl <<
......@@ -737,12 +737,12 @@ namespace
"high_count == " << high_count << endl <<
"temp.count(j) == " << test.get_count(j)
);
DLIB_CASSERT(low_count == low_counts[j],
DLIB_TEST_MSG(low_count == low_counts[j],
"symbol: " << j << "\n" <<
"target: " << k << "\n" <<
"low_count: " << low_count << "\n" <<
"low_counts[j]: " << low_counts[j]);
DLIB_CASSERT(high_count == high_counts[j],"");
DLIB_TEST(high_count == high_counts[j]);
}
}
......@@ -793,22 +793,22 @@ namespace
}
DLIB_CASSERT(test.get_total() == total,"");
DLIB_TEST(test.get_total() == total);
unsigned long target = test.get_total()/2;
unsigned long symbol = i, low_count = 0, high_count = 0, total_count = 0;
DLIB_CASSERT(test.get_range(symbol,low_count,high_count,total_count)==counts[symbol],"");
DLIB_TEST(test.get_range(symbol,low_count,high_count,total_count)==counts[symbol]);
if (counts[symbol] != 0)
{
DLIB_CASSERT(total_count == total,"");
DLIB_TEST(total_count == total);
DLIB_CASSERT(high_count <= total,"");
DLIB_CASSERT(low_count < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_TEST(high_count <= total);
DLIB_TEST(low_count < high_count);
DLIB_TEST(high_count <= test.get_total());
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
}
......@@ -816,11 +816,11 @@ namespace
test.get_symbol(target,symbol,low_count,high_count);
DLIB_CASSERT(high_count <= total,"");
DLIB_CASSERT(low_count < high_count,"");
DLIB_CASSERT(high_count <= test.get_total(),"");
DLIB_CASSERT(test.get_count(symbol) == high_count-low_count,"");
DLIB_CASSERT(test.get_count(symbol) == counts[symbol],"");
DLIB_TEST(high_count <= total);
DLIB_TEST(low_count < high_count);
DLIB_TEST(high_count <= test.get_total());
DLIB_TEST(test.get_count(symbol) == high_count-low_count);
DLIB_TEST(test.get_count(symbol) == counts[symbol]);
......
......@@ -27,36 +27,36 @@ namespace
config_reader& cr
)
{
DLIB_CASSERT(cr.is_key_defined("global"),"");
DLIB_CASSERT(cr.is_block_defined("all"),"");
DLIB_CASSERT(cr.is_key_defined("globalasfd") == false,"");
DLIB_CASSERT(cr.is_block_defined("all!") == false,"");
DLIB_CASSERT(cr.size() == 1,"");
DLIB_CASSERT(cr["global"] == "hmm","");
DLIB_CASSERT(cr["global2"] == "hmm2","");
DLIB_CASSERT(cr.block("all").size() == 4,"");
DLIB_CASSERT(cr.block("all").block("block1").size() == 0,"");
DLIB_CASSERT(cr.block("all").block("block2").size() == 0,"");
DLIB_CASSERT(cr.block("all").block("block3").size() == 0,"");
DLIB_CASSERT(cr.block("all").block("block4").size() == 0,"");
DLIB_CASSERT(cr.block("all").block("block1").is_key_defined("name"),"");
DLIB_CASSERT(cr.block("all").block("block2").is_key_defined("name"),"");
DLIB_CASSERT(cr.block("all").block("block3").is_key_defined("name"),"");
DLIB_CASSERT(cr.block("all").block("block4").is_key_defined("name"),"");
DLIB_CASSERT(cr.block("all").block("block1").is_key_defined("age"),"");
DLIB_CASSERT(cr.block("all").block("block2").is_key_defined("age"),"");
DLIB_CASSERT(cr.block("all").block("block3").is_key_defined("age"),"");
DLIB_CASSERT(cr.block("all").block("block4").is_key_defined("age"),"");
DLIB_CASSERT(cr.block("all").block("block1")["name"] == "davis king","");
DLIB_CASSERT(cr.block("all").block("block2")["name"] == "joel","");
DLIB_CASSERT(cr.block("all").block("block3")["name"] == "john","");
DLIB_CASSERT(cr.block("all").block("block4")["name"] == "dude","");
DLIB_CASSERT(cr.block("all").block("block1")["age"] == "24","");
DLIB_CASSERT(cr.block("all").block("block2")["age"] == "24","");
DLIB_CASSERT(cr.block("all").block("block3")["age"] == "24","");
DLIB_CASSERT(cr.block("all").block("block4")["age"] == "53","");
DLIB_TEST(cr.is_key_defined("global"));
DLIB_TEST(cr.is_block_defined("all"));
DLIB_TEST(cr.is_key_defined("globalasfd") == false);
DLIB_TEST(cr.is_block_defined("all!") == false);
DLIB_TEST(cr.size() == 1);
DLIB_TEST(cr["global"] == "hmm");
DLIB_TEST(cr["global2"] == "hmm2");
DLIB_TEST(cr.block("all").size() == 4);
DLIB_TEST(cr.block("all").block("block1").size() == 0);
DLIB_TEST(cr.block("all").block("block2").size() == 0);
DLIB_TEST(cr.block("all").block("block3").size() == 0);
DLIB_TEST(cr.block("all").block("block4").size() == 0);
DLIB_TEST(cr.block("all").block("block1").is_key_defined("name"));
DLIB_TEST(cr.block("all").block("block2").is_key_defined("name"));
DLIB_TEST(cr.block("all").block("block3").is_key_defined("name"));
DLIB_TEST(cr.block("all").block("block4").is_key_defined("name"));
DLIB_TEST(cr.block("all").block("block1").is_key_defined("age"));
DLIB_TEST(cr.block("all").block("block2").is_key_defined("age"));
DLIB_TEST(cr.block("all").block("block3").is_key_defined("age"));
DLIB_TEST(cr.block("all").block("block4").is_key_defined("age"));
DLIB_TEST(cr.block("all").block("block1")["name"] == "davis king");
DLIB_TEST(cr.block("all").block("block2")["name"] == "joel");
DLIB_TEST(cr.block("all").block("block3")["name"] == "john");
DLIB_TEST(cr.block("all").block("block4")["name"] == "dude");
DLIB_TEST(cr.block("all").block("block1")["age"] == "24");
DLIB_TEST(cr.block("all").block("block2")["age"] == "24");
DLIB_TEST(cr.block("all").block("block3")["age"] == "24");
DLIB_TEST(cr.block("all").block("block4")["age"] == "53");
int count1 = 0;
......@@ -64,26 +64,26 @@ namespace
while (cr.move_next())
{
++count1;
DLIB_CASSERT(cr.current_block_name() == "all","");
DLIB_CASSERT(cr.element().is_key_defined("global") == false,"");
DLIB_CASSERT(cr.element().is_key_defined("global2") == false,"");
DLIB_CASSERT(cr.element().is_key_defined("name") == false,"");
DLIB_CASSERT(cr.element().is_key_defined("age") == false,"");
DLIB_TEST(cr.current_block_name() == "all");
DLIB_TEST(cr.element().is_key_defined("global") == false);
DLIB_TEST(cr.element().is_key_defined("global2") == false);
DLIB_TEST(cr.element().is_key_defined("name") == false);
DLIB_TEST(cr.element().is_key_defined("age") == false);
while (cr.element().move_next())
{
++count2;
ostringstream sout;
sout << "block" << count2;
DLIB_CASSERT(cr.element().current_block_name() == sout.str(),"");
DLIB_CASSERT(cr.element().size() == 4,"");
DLIB_CASSERT(cr.element().element().size() == 0,"");
DLIB_CASSERT(cr.element().element().is_key_defined("name"),"");
DLIB_CASSERT(cr.element().element().is_key_defined("age"),"");
DLIB_TEST(cr.element().current_block_name() == sout.str());
DLIB_TEST(cr.element().size() == 4);
DLIB_TEST(cr.element().element().size() == 0);
DLIB_TEST(cr.element().element().is_key_defined("name"));
DLIB_TEST(cr.element().element().is_key_defined("age"));
}
}
DLIB_CASSERT(count1 == 1,"");
DLIB_CASSERT(count2 == 4,"");
DLIB_TEST(count1 == 1);
DLIB_TEST(count2 == 4);
}
......@@ -163,8 +163,8 @@ namespace
do_the_tests(cr2);
cr.clear();
DLIB_CASSERT(cr.size() == 0,"");
DLIB_CASSERT(cr.is_key_defined("global") == false,"");
DLIB_TEST(cr.size() == 0);
DLIB_TEST(cr.is_key_defined("global") == false);
}
......@@ -215,10 +215,10 @@ namespace
catch (typename config_reader::config_reader_error& e)
{
error_found = true;
DLIB_CASSERT(e.line_number == 16,"");
DLIB_CASSERT(e.redefinition == false,"");
DLIB_TEST(e.line_number == 16);
DLIB_TEST(e.redefinition == false);
}
DLIB_CASSERT(error_found,"");
DLIB_TEST(error_found);
}
{
......@@ -268,10 +268,10 @@ namespace
catch (typename config_reader::config_reader_error& e)
{
error_found = true;
DLIB_CASSERT(e.line_number == 31,e.line_number);
DLIB_CASSERT(e.redefinition == true,"");
DLIB_TEST_MSG(e.line_number == 31,e.line_number);
DLIB_TEST(e.redefinition == true);
}
DLIB_CASSERT(error_found,"");
DLIB_TEST(error_found);
}
......@@ -321,10 +321,10 @@ namespace
catch (typename config_reader::config_reader_error& e)
{
error_found = true;
DLIB_CASSERT(e.line_number == 13,e.line_number);
DLIB_CASSERT(e.redefinition == true,"");
DLIB_TEST_MSG(e.line_number == 13,e.line_number);
DLIB_TEST(e.redefinition == true);
}
DLIB_CASSERT(error_found,"");
DLIB_TEST(error_found);
}
......
......@@ -46,29 +46,29 @@ namespace
directed_graph a, b;
set<unsigned long>::compare_1b_c s;
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_TEST(graph_contains_directed_cycle(a) == false);
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
DLIB_CASSERT(a.number_of_nodes() == 0,"");
DLIB_TEST(a.number_of_nodes() == 0);
DLIB_CASSERT(graph_contains_length_one_cycle(a) == false,"");
DLIB_TEST(graph_contains_length_one_cycle(a) == false);
a.set_number_of_nodes(5);
DLIB_CASSERT(graph_contains_length_one_cycle(a) == false,"");
DLIB_CASSERT(graph_is_connected(a) == false,"");
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_CASSERT(a.number_of_nodes() == 5,"");
DLIB_TEST(graph_contains_length_one_cycle(a) == false);
DLIB_TEST(graph_is_connected(a) == false);
DLIB_TEST(graph_contains_directed_cycle(a) == false);
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
DLIB_TEST(a.number_of_nodes() == 5);
for (int i = 0; i < 5; ++i)
{
a.node(i).data = i;
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
a.remove_node(1);
DLIB_CASSERT(a.number_of_nodes() == 4,"");
DLIB_TEST(a.number_of_nodes() == 4);
// make sure that only the number with data == 1 was remove
......@@ -76,181 +76,181 @@ namespace
for (int i = 0; i < 4; ++i)
{
count += a.node(i).data;
DLIB_CASSERT(a.node(i).number_of_children() == 0,"");
DLIB_CASSERT(a.node(i).number_of_parents() == 0,"");
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).number_of_children() == 0);
DLIB_TEST(a.node(i).number_of_parents() == 0);
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
DLIB_CASSERT(count == 9,"");
DLIB_TEST(count == 9);
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_TEST(graph_contains_directed_cycle(a) == false);
a.add_edge(1,1);
DLIB_CASSERT(graph_contains_length_one_cycle(a) == true,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_TEST(graph_contains_length_one_cycle(a) == true);
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
DLIB_CASSERT(graph_contains_directed_cycle(a) == true,"");
DLIB_TEST(graph_contains_directed_cycle(a) == true);
a.add_edge(1,2);
DLIB_CASSERT(graph_contains_directed_cycle(a) == true,"");
DLIB_TEST(graph_contains_directed_cycle(a) == true);
DLIB_CASSERT(a.node(1).number_of_children() == 2,"");
DLIB_CASSERT(a.node(1).number_of_parents() == 1,"");
DLIB_CASSERT(a.node(1).parent(0).index() == 1,"")
DLIB_TEST(a.node(1).number_of_children() == 2);
DLIB_TEST(a.node(1).number_of_parents() == 1);
DLIB_TEST_MSG(a.node(1).parent(0).index() == 1,"")
DLIB_CASSERT(a.node(1).child(0).index() + a.node(1).child(1).index() == 3,"")
DLIB_CASSERT(a.node(2).number_of_children() == 0,"");
DLIB_CASSERT(a.node(2).number_of_parents() == 1,"");
DLIB_CASSERT(a.node(2).index() == 2,"");
DLIB_TEST_MSG(a.node(1).child(0).index() + a.node(1).child(1).index() == 3,"")
DLIB_TEST(a.node(2).number_of_children() == 0);
DLIB_TEST(a.node(2).number_of_parents() == 1);
DLIB_TEST(a.node(2).index() == 2);
int val = a.node(1).data;
a.remove_node(1);
DLIB_CASSERT(graph_contains_length_one_cycle(a) == false,"");
DLIB_TEST(graph_contains_length_one_cycle(a) == false);
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_TEST(graph_contains_directed_cycle(a) == false);
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
DLIB_CASSERT(a.number_of_nodes() == 3,"");
DLIB_TEST(a.number_of_nodes() == 3);
count = 0;
for (int i = 0; i < 3; ++i)
{
count += a.node(i).data;
DLIB_CASSERT(a.node(i).number_of_children() == 0,"");
DLIB_CASSERT(a.node(i).number_of_parents() == 0,"");
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).number_of_children() == 0);
DLIB_TEST(a.node(i).number_of_parents() == 0);
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
DLIB_CASSERT(count == 9-val,"");
DLIB_TEST(count == 9-val);
val = a.add_node();
DLIB_CASSERT(val == 3,"");
DLIB_CASSERT(a.number_of_nodes() == 4,"");
DLIB_TEST(val == 3);
DLIB_TEST(a.number_of_nodes() == 4);
for (int i = 0; i < 4; ++i)
{
a.node(i).data = i;
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
for (int i = 0; i < 4; ++i)
{
DLIB_CASSERT(a.node(i).data == i,"");
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).data == i);
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
a.add_edge(0, 1);
a.add_edge(0, 2);
DLIB_CASSERT(graph_is_connected(a) == false,"");
DLIB_TEST(graph_is_connected(a) == false);
a.add_edge(1, 3);
DLIB_CASSERT(graph_is_connected(a) == true,"");
DLIB_TEST(graph_is_connected(a) == true);
a.add_edge(2, 3);
DLIB_CASSERT(graph_is_connected(a) == true,"");
DLIB_CASSERT(graph_contains_length_one_cycle(a) == false,"");
DLIB_TEST(graph_is_connected(a) == true);
DLIB_TEST(graph_contains_length_one_cycle(a) == false);
DLIB_CASSERT(a.has_edge(0, 1),"");
DLIB_CASSERT(a.has_edge(0, 2),"");
DLIB_CASSERT(a.has_edge(1, 3),"");
DLIB_CASSERT(a.has_edge(2, 3),"");
DLIB_TEST(a.has_edge(0, 1));
DLIB_TEST(a.has_edge(0, 2));
DLIB_TEST(a.has_edge(1, 3));
DLIB_TEST(a.has_edge(2, 3));
DLIB_CASSERT(!a.has_edge(1, 0),"");
DLIB_CASSERT(!a.has_edge(2, 0),"");
DLIB_CASSERT(!a.has_edge(3, 1),"");
DLIB_CASSERT(!a.has_edge(3, 2),"");
DLIB_TEST(!a.has_edge(1, 0));
DLIB_TEST(!a.has_edge(2, 0));
DLIB_TEST(!a.has_edge(3, 1));
DLIB_TEST(!a.has_edge(3, 2));
DLIB_CASSERT(a.node(0).number_of_parents() == 0,"");
DLIB_CASSERT(a.node(0).number_of_children() == 2,"");
DLIB_TEST(a.node(0).number_of_parents() == 0);
DLIB_TEST(a.node(0).number_of_children() == 2);
DLIB_CASSERT(a.node(1).number_of_parents() == 1,"");
DLIB_CASSERT(a.node(1).number_of_children() == 1,"");
DLIB_CASSERT(a.node(1).child(0).index() == 3,"");
DLIB_CASSERT(a.node(1).parent(0).index() == 0,"");
DLIB_TEST(a.node(1).number_of_parents() == 1);
DLIB_TEST(a.node(1).number_of_children() == 1);
DLIB_TEST(a.node(1).child(0).index() == 3);
DLIB_TEST(a.node(1).parent(0).index() == 0);
DLIB_CASSERT(a.node(2).number_of_parents() == 1,"");
DLIB_CASSERT(a.node(2).number_of_children() == 1,"");
DLIB_CASSERT(a.node(2).child(0).index() == 3,"");
DLIB_CASSERT(a.node(2).parent(0).index() == 0,"");
DLIB_TEST(a.node(2).number_of_parents() == 1);
DLIB_TEST(a.node(2).number_of_children() == 1);
DLIB_TEST(a.node(2).child(0).index() == 3);
DLIB_TEST(a.node(2).parent(0).index() == 0);
DLIB_CASSERT(a.node(3).number_of_parents() == 2,"");
DLIB_CASSERT(a.node(3).number_of_children() == 0,"");
DLIB_TEST(a.node(3).number_of_parents() == 2);
DLIB_TEST(a.node(3).number_of_children() == 0);
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_TEST(graph_contains_directed_cycle(a) == false);
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
a.remove_edge(0,1);
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_TEST(graph_contains_directed_cycle(a) == false);
DLIB_CASSERT(!a.has_edge(0, 1),"");
DLIB_CASSERT(a.has_edge(0, 2),"");
DLIB_CASSERT(a.has_edge(1, 3),"");
DLIB_CASSERT(a.has_edge(2, 3),"");
DLIB_TEST(!a.has_edge(0, 1));
DLIB_TEST(a.has_edge(0, 2));
DLIB_TEST(a.has_edge(1, 3));
DLIB_TEST(a.has_edge(2, 3));
DLIB_CASSERT(!a.has_edge(1, 0),"");
DLIB_CASSERT(!a.has_edge(2, 0),"");
DLIB_CASSERT(!a.has_edge(3, 1),"");
DLIB_CASSERT(!a.has_edge(3, 2),"");
DLIB_TEST(!a.has_edge(1, 0));
DLIB_TEST(!a.has_edge(2, 0));
DLIB_TEST(!a.has_edge(3, 1));
DLIB_TEST(!a.has_edge(3, 2));
DLIB_CASSERT(a.node(0).number_of_parents() == 0,"");
DLIB_CASSERT(a.node(0).number_of_children() == 1,"");
DLIB_TEST(a.node(0).number_of_parents() == 0);
DLIB_TEST(a.node(0).number_of_children() == 1);
DLIB_CASSERT(a.node(1).number_of_parents() == 0,"");
DLIB_CASSERT(a.node(1).number_of_children() == 1,"");
DLIB_CASSERT(a.node(1).child(0).index() == 3,"");
DLIB_TEST(a.node(1).number_of_parents() == 0);
DLIB_TEST(a.node(1).number_of_children() == 1);
DLIB_TEST(a.node(1).child(0).index() == 3);
DLIB_CASSERT(a.node(2).number_of_parents() == 1,"");
DLIB_CASSERT(a.node(2).number_of_children() == 1,"");
DLIB_CASSERT(a.node(2).child(0).index() == 3,"");
DLIB_CASSERT(a.node(2).parent(0).index() == 0,"");
DLIB_TEST(a.node(2).number_of_parents() == 1);
DLIB_TEST(a.node(2).number_of_children() == 1);
DLIB_TEST(a.node(2).child(0).index() == 3);
DLIB_TEST(a.node(2).parent(0).index() == 0);
DLIB_CASSERT(a.node(3).number_of_parents() == 2,"");
DLIB_CASSERT(a.node(3).number_of_children() == 0,"");
DLIB_TEST(a.node(3).number_of_parents() == 2);
DLIB_TEST(a.node(3).number_of_children() == 0);
for (int i = 0; i < 4; ++i)
{
DLIB_CASSERT(a.node(i).data == i,"");
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).data == i);
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
swap(a,b);
DLIB_CASSERT(a.number_of_nodes() == 0, "");
DLIB_CASSERT(b.number_of_nodes() == 4, "");
DLIB_CASSERT(b.node(0).number_of_parents() == 0,"");
DLIB_CASSERT(b.node(0).number_of_children() == 1,"");
DLIB_TEST(a.number_of_nodes() == 0);
DLIB_TEST(b.number_of_nodes() == 4);
DLIB_TEST(b.node(0).number_of_parents() == 0);
DLIB_TEST(b.node(0).number_of_children() == 1);
DLIB_CASSERT(b.node(1).number_of_parents() == 0,"");
DLIB_CASSERT(b.node(1).number_of_children() == 1,"");
DLIB_CASSERT(b.node(1).child(0).index() == 3,"");
DLIB_TEST(b.node(1).number_of_parents() == 0);
DLIB_TEST(b.node(1).number_of_children() == 1);
DLIB_TEST(b.node(1).child(0).index() == 3);
DLIB_CASSERT(b.node(2).number_of_parents() == 1,"");
DLIB_CASSERT(b.node(2).number_of_children() == 1,"");
DLIB_CASSERT(b.node(2).child(0).index() == 3,"");
DLIB_CASSERT(b.node(2).parent(0).index() == 0,"");
DLIB_TEST(b.node(2).number_of_parents() == 1);
DLIB_TEST(b.node(2).number_of_children() == 1);
DLIB_TEST(b.node(2).child(0).index() == 3);
DLIB_TEST(b.node(2).parent(0).index() == 0);
DLIB_CASSERT(b.node(3).number_of_parents() == 2,"");
DLIB_CASSERT(b.node(3).number_of_children() == 0,"");
DLIB_TEST(b.node(3).number_of_parents() == 2);
DLIB_TEST(b.node(3).number_of_children() == 0);
b.node(0).child_edge(0) = static_cast<unsigned short>(b.node(0).child(0).index()+1);
b.node(1).child_edge(0) = static_cast<unsigned short>(b.node(1).child(0).index()+1);
b.node(2).child_edge(0) = static_cast<unsigned short>(b.node(2).child(0).index()+1);
DLIB_CASSERT(b.node(0).child_edge(0) == b.node(0).child(0).index()+1,
DLIB_TEST_MSG(b.node(0).child_edge(0) == b.node(0).child(0).index()+1,
b.node(0).child_edge(0) << " " << b.node(0).child(0).index()+1);
DLIB_CASSERT(b.node(1).child_edge(0) == b.node(1).child(0).index()+1,
DLIB_TEST_MSG(b.node(1).child_edge(0) == b.node(1).child(0).index()+1,
b.node(1).child_edge(0) << " " << b.node(1).child(0).index()+1);
DLIB_CASSERT(b.node(2).child_edge(0) == b.node(2).child(0).index()+1,
DLIB_TEST_MSG(b.node(2).child_edge(0) == b.node(2).child(0).index()+1,
b.node(2).child_edge(0) << " " << b.node(2).child(0).index()+1);
DLIB_CASSERT(b.node(2).parent_edge(0) == 2+1,
DLIB_TEST_MSG(b.node(2).parent_edge(0) == 2+1,
b.node(2).parent_edge(0) << " " << 2+1);
DLIB_CASSERT(b.node(3).parent_edge(0) == 3+1,
DLIB_TEST_MSG(b.node(3).parent_edge(0) == 3+1,
b.node(3).parent_edge(0) << " " << 3+1);
DLIB_CASSERT(b.node(3).parent_edge(1) == 3+1,
DLIB_TEST_MSG(b.node(3).parent_edge(1) == 3+1,
b.node(3).parent_edge(1) << " " << 3+1);
ostringstream sout;
......@@ -260,87 +260,87 @@ namespace
istringstream sin(sout.str());
a.set_number_of_nodes(20);
DLIB_CASSERT(a.number_of_nodes() == 20,"");
DLIB_TEST(a.number_of_nodes() == 20);
deserialize(a, sin);
DLIB_CASSERT(a.number_of_nodes() == 4,"");
DLIB_TEST(a.number_of_nodes() == 4);
DLIB_CASSERT(!a.has_edge(0, 1),"");
DLIB_CASSERT(a.has_edge(0, 2),"");
DLIB_CASSERT(a.has_edge(1, 3),"");
DLIB_CASSERT(a.has_edge(2, 3),"");
DLIB_TEST(!a.has_edge(0, 1));
DLIB_TEST(a.has_edge(0, 2));
DLIB_TEST(a.has_edge(1, 3));
DLIB_TEST(a.has_edge(2, 3));
DLIB_CASSERT(!a.has_edge(1, 0),"");
DLIB_CASSERT(!a.has_edge(2, 0),"");
DLIB_CASSERT(!a.has_edge(3, 1),"");
DLIB_CASSERT(!a.has_edge(3, 2),"");
DLIB_TEST(!a.has_edge(1, 0));
DLIB_TEST(!a.has_edge(2, 0));
DLIB_TEST(!a.has_edge(3, 1));
DLIB_TEST(!a.has_edge(3, 2));
DLIB_CASSERT(a.node(0).child_edge(0) == a.node(0).child(0).index()+1,
DLIB_TEST_MSG(a.node(0).child_edge(0) == a.node(0).child(0).index()+1,
a.node(0).child_edge(0) << " " << a.node(0).child(0).index()+1);
DLIB_CASSERT(a.node(1).child_edge(0) == a.node(1).child(0).index()+1,
DLIB_TEST_MSG(a.node(1).child_edge(0) == a.node(1).child(0).index()+1,
a.node(1).child_edge(0) << " " << a.node(1).child(0).index()+1);
DLIB_CASSERT(a.node(2).child_edge(0) == a.node(2).child(0).index()+1,
DLIB_TEST_MSG(a.node(2).child_edge(0) == a.node(2).child(0).index()+1,
a.node(2).child_edge(0) << " " << a.node(2).child(0).index()+1);
DLIB_CASSERT(a.node(2).parent_edge(0) == 2+1,
DLIB_TEST_MSG(a.node(2).parent_edge(0) == 2+1,
a.node(2).parent_edge(0) << " " << 2+1);
DLIB_CASSERT(a.node(3).parent_edge(0) == 3+1,
DLIB_TEST_MSG(a.node(3).parent_edge(0) == 3+1,
a.node(3).parent_edge(0) << " " << 3+1);
DLIB_CASSERT(a.node(3).parent_edge(1) == 3+1,
DLIB_TEST_MSG(a.node(3).parent_edge(1) == 3+1,
a.node(3).parent_edge(1) << " " << 3+1);
for (int i = 0; i < 4; ++i)
{
DLIB_CASSERT(a.node(i).data == i,"");
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).data == i);
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
DLIB_CASSERT(b.number_of_nodes() == 4, "");
DLIB_CASSERT(b.node(0).number_of_parents() == 0,"");
DLIB_CASSERT(b.node(0).number_of_children() == 1,"");
DLIB_TEST(b.number_of_nodes() == 4);
DLIB_TEST(b.node(0).number_of_parents() == 0);
DLIB_TEST(b.node(0).number_of_children() == 1);
DLIB_CASSERT(b.node(1).number_of_parents() == 0,"");
DLIB_CASSERT(b.node(1).number_of_children() == 1,"");
DLIB_CASSERT(b.node(1).child(0).index() == 3,"");
DLIB_TEST(b.node(1).number_of_parents() == 0);
DLIB_TEST(b.node(1).number_of_children() == 1);
DLIB_TEST(b.node(1).child(0).index() == 3);
DLIB_CASSERT(b.node(2).number_of_parents() == 1,"");
DLIB_CASSERT(b.node(2).number_of_children() == 1,"");
DLIB_CASSERT(b.node(2).child(0).index() == 3,"");
DLIB_CASSERT(b.node(2).parent(0).index() == 0,"");
DLIB_TEST(b.node(2).number_of_parents() == 1);
DLIB_TEST(b.node(2).number_of_children() == 1);
DLIB_TEST(b.node(2).child(0).index() == 3);
DLIB_TEST(b.node(2).parent(0).index() == 0);
DLIB_CASSERT(b.node(3).number_of_parents() == 2,"");
DLIB_CASSERT(b.node(3).number_of_children() == 0,"");
DLIB_TEST(b.node(3).number_of_parents() == 2);
DLIB_TEST(b.node(3).number_of_children() == 0);
DLIB_CASSERT(a.number_of_nodes() == 4, "");
DLIB_CASSERT(a.node(0).number_of_parents() == 0,"");
DLIB_CASSERT(a.node(0).number_of_children() == 1,"");
DLIB_TEST(a.number_of_nodes() == 4);
DLIB_TEST(a.node(0).number_of_parents() == 0);
DLIB_TEST(a.node(0).number_of_children() == 1);
DLIB_CASSERT(a.node(1).number_of_parents() == 0,"");
DLIB_CASSERT(a.node(1).number_of_children() == 1,"");
DLIB_CASSERT(a.node(1).child(0).index() == 3,"");
DLIB_TEST(a.node(1).number_of_parents() == 0);
DLIB_TEST(a.node(1).number_of_children() == 1);
DLIB_TEST(a.node(1).child(0).index() == 3);
DLIB_CASSERT(a.node(2).number_of_parents() == 1,"");
DLIB_CASSERT(a.node(2).number_of_children() == 1,"");
DLIB_CASSERT(a.node(2).child(0).index() == 3,"");
DLIB_CASSERT(a.node(2).parent(0).index() == 0,"");
DLIB_TEST(a.node(2).number_of_parents() == 1);
DLIB_TEST(a.node(2).number_of_children() == 1);
DLIB_TEST(a.node(2).child(0).index() == 3);
DLIB_TEST(a.node(2).parent(0).index() == 0);
DLIB_CASSERT(a.node(3).number_of_parents() == 2,"");
DLIB_CASSERT(a.node(3).number_of_children() == 0,"");
DLIB_TEST(a.node(3).number_of_parents() == 2);
DLIB_TEST(a.node(3).number_of_children() == 0);
DLIB_CASSERT(a.number_of_nodes() == 4, "");
DLIB_TEST(a.number_of_nodes() == 4);
a.clear();
DLIB_CASSERT(a.number_of_nodes() == 0, "");
DLIB_TEST(a.number_of_nodes() == 0);
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_TEST(graph_contains_directed_cycle(a) == false);
a.set_number_of_nodes(10);
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_TEST(graph_contains_directed_cycle(a) == false);
a.add_edge(0,1);
a.add_edge(1,2);
......@@ -350,18 +350,18 @@ namespace
a.add_edge(4,5);
a.add_edge(5,1);
DLIB_CASSERT(graph_contains_directed_cycle(a) == true,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_TEST(graph_contains_directed_cycle(a) == true);
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
a.remove_edge(5,1);
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
DLIB_TEST(graph_contains_directed_cycle(a) == false);
a.add_edge(7,8);
DLIB_CASSERT(graph_contains_directed_cycle(a) == false,"");
DLIB_TEST(graph_contains_directed_cycle(a) == false);
a.add_edge(8,7);
DLIB_CASSERT(graph_contains_directed_cycle(a) == true,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_TEST(graph_contains_directed_cycle(a) == true);
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
a.clear();
......@@ -387,60 +387,60 @@ namespace
set<set<unsigned long>::compare_1b_c>::kernel_1b_c sos;
create_join_tree(g, join_tree);
DLIB_CASSERT(is_join_tree(g, join_tree),"");
DLIB_CASSERT(join_tree.number_of_nodes() == 2,"");
DLIB_CASSERT(graph_contains_undirected_cycle(join_tree) == false,"");
DLIB_CASSERT(graph_is_connected(join_tree) == true,"");
DLIB_TEST(is_join_tree(g, join_tree));
DLIB_TEST(join_tree.number_of_nodes() == 2);
DLIB_TEST(graph_contains_undirected_cycle(join_tree) == false);
DLIB_TEST(graph_is_connected(join_tree) == true);
unsigned long temp;
triangulate_graph_and_find_cliques(g,sos);
temp = 2; s.add(temp);
temp = 3; s.add(temp);
DLIB_CASSERT(sos.is_member(s),"");
DLIB_TEST(sos.is_member(s));
s.clear();
temp = 0; s.add(temp);
temp = 1; s.add(temp);
temp = 2; s.add(temp);
DLIB_CASSERT(sos.is_member(s),"");
DLIB_CASSERT(sos.size() == 2,"");
DLIB_CASSERT(sos.is_member(join_tree.node(0).data), "");
DLIB_CASSERT(sos.is_member(join_tree.node(1).data), "");
DLIB_TEST(sos.is_member(s));
DLIB_TEST(sos.size() == 2);
DLIB_TEST(sos.is_member(join_tree.node(0).data));
DLIB_TEST(sos.is_member(join_tree.node(1).data));
s.clear();
temp = 0; s.add(temp);
DLIB_CASSERT(is_clique(g,s) == true,"");
DLIB_CASSERT(is_maximal_clique(g,s) == false,"");
DLIB_TEST(is_clique(g,s) == true);
DLIB_TEST(is_maximal_clique(g,s) == false);
temp = 3; s.add(temp);
DLIB_CASSERT(is_clique(g,s) == false,"");
DLIB_TEST(is_clique(g,s) == false);
s.destroy(3);
DLIB_CASSERT(is_clique(g,s) == true,"");
DLIB_TEST(is_clique(g,s) == true);
temp = 2; s.add(temp);
DLIB_CASSERT(is_clique(g,s) == true,"");
DLIB_CASSERT(is_maximal_clique(g,s) == false,"");
DLIB_TEST(is_clique(g,s) == true);
DLIB_TEST(is_maximal_clique(g,s) == false);
temp = 1; s.add(temp);
DLIB_CASSERT(is_clique(g,s) == true,"");
DLIB_CASSERT(is_maximal_clique(g,s) == true,"");
DLIB_TEST(is_clique(g,s) == true);
DLIB_TEST(is_maximal_clique(g,s) == true);
s.clear();
DLIB_CASSERT(is_clique(g,s) == true,"");
DLIB_TEST(is_clique(g,s) == true);
temp = 3; s.add(temp);
DLIB_CASSERT(is_clique(g,s) == true,"");
DLIB_TEST(is_clique(g,s) == true);
temp = 2; s.add(temp);
DLIB_CASSERT(is_clique(g,s) == true,"");
DLIB_CASSERT(is_maximal_clique(g,s) == true,"");
DLIB_TEST(is_clique(g,s) == true);
DLIB_TEST(is_maximal_clique(g,s) == true);
DLIB_CASSERT(a.number_of_nodes() == 4,"");
DLIB_CASSERT(g.number_of_nodes() == 4,"");
DLIB_TEST(a.number_of_nodes() == 4);
DLIB_TEST(g.number_of_nodes() == 4);
for (unsigned long i = 0; i < 4; ++i)
DLIB_CASSERT( a.node(i).data == (int)i,"");
DLIB_CASSERT(g.has_edge(0,1),"");
DLIB_CASSERT(g.has_edge(0,2),"");
DLIB_CASSERT(g.has_edge(1,2),"");
DLIB_CASSERT(g.has_edge(3,2),"");
DLIB_CASSERT(g.has_edge(0,3) == false,"");
DLIB_CASSERT(g.has_edge(1,3) == false,"");
DLIB_TEST( a.node(i).data == (int)i);
DLIB_TEST(g.has_edge(0,1));
DLIB_TEST(g.has_edge(0,2));
DLIB_TEST(g.has_edge(1,2));
DLIB_TEST(g.has_edge(3,2));
DLIB_TEST(g.has_edge(0,3) == false);
DLIB_TEST(g.has_edge(1,3) == false);
}
......
......@@ -59,12 +59,12 @@ namespace
DLIB_CASSERT(e.stream_is_set() == false,"");
DLIB_TEST(e.stream_is_set() == false);
e.set_stream(sout);
DLIB_CASSERT(e.stream_is_set() == true,"");
DLIB_CASSERT(&e.get_stream() == &sout,"");
DLIB_TEST(e.stream_is_set() == true);
DLIB_TEST(&e.get_stream() == &sout);
unsigned char ch;
......@@ -98,14 +98,14 @@ namespace
counts[ch] += 1;
}
DLIB_CASSERT(e.stream_is_set() == true,"");
DLIB_CASSERT(&e.get_stream() == &sout,"");
DLIB_TEST(e.stream_is_set() == true);
DLIB_TEST(&e.get_stream() == &sout);
e.clear();
DLIB_CASSERT(e.stream_is_set() == false,"");
DLIB_TEST(e.stream_is_set() == false);
// *****************************************
......@@ -114,18 +114,18 @@ namespace
decoder d;
DLIB_CASSERT(d.stream_is_set() == false,"");
DLIB_CASSERT(d.get_target_called() == false,"");
DLIB_TEST(d.stream_is_set() == false);
DLIB_TEST(d.get_target_called() == false);
sin.str(sout.str());
sout.str("");
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_CASSERT(&d.get_stream() == &sin,"");
DLIB_TEST(d.stream_is_set() == true);
DLIB_TEST(&d.get_stream() == &sin);
for (int i = 0; i < 256; ++i)
{
......@@ -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);
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;
......@@ -178,19 +178,19 @@ namespace
d.decode(low_count,high_count);
DLIB_CASSERT(d.get_target_called() == false,"");
DLIB_TEST(d.get_target_called() == false);
++total;
counts[ch] += 1;
}
DLIB_CASSERT(d.stream_is_set() == true,"");
DLIB_CASSERT(&d.get_stream() == &sin,"");
DLIB_TEST(d.stream_is_set() == true);
DLIB_TEST(&d.get_stream() == &sin);
d.clear();
DLIB_CASSERT(d.stream_is_set() == false,"");
DLIB_CASSERT(sout.str().size() == input.size(),"the test script is buggy");
DLIB_TEST(d.stream_is_set() == false);
DLIB_TEST_MSG(sout.str().size() == input.size(),"the test script is buggy");
if (sout.str() == input)
......@@ -264,7 +264,7 @@ namespace
for (int i = 0; i < num; ++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]);
}
......@@ -273,13 +273,13 @@ namespace
DLIB_CASSERT(sin.rdbuf()->sgetc() != EOF,"num: " << num);
DLIB_CASSERT(sin.rdbuf()->sgetc() == 'a',
DLIB_TEST_MSG(sin.rdbuf()->sgetc() != EOF,"num: " << num);
DLIB_TEST_MSG(sin.rdbuf()->sgetc() == 'a',
"sin.rdbuf()->sgetc() == " << (char)sin.rdbuf()->sgetc() <<
"\nnum: " << num
);
DLIB_CASSERT(sin.rdbuf()->sbumpc() == 'a',"");
DLIB_CASSERT(sin.rdbuf()->sgetc() == EOF,"");
DLIB_TEST(sin.rdbuf()->sbumpc() == 'a');
DLIB_TEST(sin.rdbuf()->sgetc() == EOF);
} // for (int k = 0; k < 10000; ++k)
......@@ -298,7 +298,7 @@ namespace
d.set_stream(sin);
unsigned long total = ::rand()%256 + 20;
unsigned long target = d.get_target(total);
DLIB_CASSERT(target<total,"");
DLIB_TEST(target<total);
for (int i = 0; i < 30; ++i)
{
......@@ -311,7 +311,7 @@ namespace
d.decode(low_count,high_count);
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
{
int k = 0;
DLIB_CASSERT(temp != temp2,"");
DLIB_TEST(temp != temp2);
while (temp[k] == temp2[k])++k;
}
DLIB_CASSERT(temp2 == "","")
DLIB_TEST_MSG(temp2 == "","")
}
}
......@@ -395,7 +395,7 @@ namespace
string::size_type pos = temp.find_first_not_of("e");
temp = temp.substr(pos);
}
DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"") /**/
DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"") /**/
dlog << LTRACE << 5;
......@@ -403,16 +403,16 @@ namespace
print_spinner();
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 = 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
for ( int i = 0; i <= 255; ++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;
......@@ -423,7 +423,7 @@ namespace
{
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;
......@@ -437,7 +437,7 @@ namespace
int a = ::rand()%256;
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
int a = ::rand()%256;
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
string::size_type pos = temp.find_first_not_of(" ");
temp = temp.substr(pos);
}
DLIB_CASSERT(temp == "","decoded string: \"" << temp << "\"")/**/
DLIB_TEST_MSG(temp == "","decoded string: \"" << temp << "\"")/**/
......@@ -504,7 +504,7 @@ namespace
temp += temp2;
print_spinner();
temp = test<encoder,decoder>(temp);
DLIB_CASSERT(temp == "","");
DLIB_TEST(temp == "");
......
......@@ -97,34 +97,34 @@ namespace
dlen.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
dlit.decode(temp);
DLIB_CASSERT(temp == 9,"");
DLIB_TEST(temp == 9);
dlen.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
dlit.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
dlen.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
dlit.decode(temp);
DLIB_CASSERT(temp == 4,"");
DLIB_TEST(temp == 4);
dlen.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
dlit.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
dlen.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
dlit.decode(temp);
DLIB_CASSERT(temp == 2,"");
DLIB_TEST(temp == 2);
dlen.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
dlit.decode(temp);
DLIB_CASSERT(temp == 0,"");
DLIB_TEST(temp == 0);
......
......@@ -41,14 +41,17 @@ namespace
dlog << dlib::LINFO << "some message you want to log";
// 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.
// 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
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()
// periodically. This will cause a spinning / character to display on the
......
......@@ -46,14 +46,14 @@ namespace
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.
// 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.
// 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
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()
// periodically. This will cause a spinning / character to display on the
......
......@@ -33,51 +33,51 @@ namespace
point p1;
point p2(2,3);
DLIB_CASSERT(p1.x() == 0,"");
DLIB_CASSERT(p1.y() == 0,"");
DLIB_CASSERT(p2.x() == 2,"");
DLIB_CASSERT(p2.y() == 3,"");
DLIB_TEST(p1.x() == 0);
DLIB_TEST(p1.y() == 0);
DLIB_TEST(p2.x() == 2);
DLIB_TEST(p2.y() == 3);
DLIB_CASSERT((-p2).x() == -2,"");
DLIB_CASSERT((-p2).y() == -3,"");
DLIB_TEST((-p2).x() == -2);
DLIB_TEST((-p2).y() == -3);
p2 += p2;
DLIB_CASSERT(p2.x() == 4,"");
DLIB_CASSERT(p2.y() == 6,"");
DLIB_TEST(p2.x() == 4);
DLIB_TEST(p2.y() == 6);
dlib::vector<double> v1 = point(1,0);
dlib::vector<double> v2(0,0,1);
p1 = v2.cross(v1);
DLIB_CASSERT(p1 == point(0,1),"");
DLIB_CASSERT(p1 != point(1,1),"");
DLIB_CASSERT(p1 != point(1,0),"");
DLIB_TEST(p1 == point(0,1));
DLIB_TEST(p1 != point(1,1));
DLIB_TEST(p1 != point(1,0));
p1 = point(2,3);
rectangle rect1 = p1;
DLIB_CASSERT(rect1.width() == 1,"");
DLIB_CASSERT(rect1.height() == 1,"");
DLIB_TEST(rect1.width() == 1);
DLIB_TEST(rect1.height() == 1);
p2 = point(1,1);
rect1 += p2;
DLIB_CASSERT(rect1.left() == 1,"");
DLIB_CASSERT(rect1.top() == 1,"");
DLIB_CASSERT(rect1.right() == 2,"");
DLIB_CASSERT(rect1.bottom() == 3,"");
DLIB_TEST(rect1.left() == 1);
DLIB_TEST(rect1.top() == 1);
DLIB_TEST(rect1.right() == 2);
DLIB_TEST(rect1.bottom() == 3);
DLIB_CASSERT(rect1.width() == 2,"");
DLIB_CASSERT(rect1.height() == 3,"");
DLIB_TEST(rect1.width() == 2);
DLIB_TEST(rect1.height() == 3);
// test the iostream << and >> operators (via string_cast and cast_to_string)
DLIB_CASSERT(string_cast<point>(" (1, 2 )") == point(1,2),"");
DLIB_CASSERT(string_cast<point>(" ( -1, 2 )") == point(-1,2),"");
DLIB_CASSERT(string_cast<rectangle>(" [(1, 2 )(3,4)]") == rectangle(1,2,3,4),"");
DLIB_CASSERT(string_cast<dlib::vector<double> >(" (1, 2 , 3.5)") == dlib::vector<double>(1,2,3.5),"");
DLIB_TEST(string_cast<point>(" (1, 2 )") == point(1,2));
DLIB_TEST(string_cast<point>(" ( -1, 2 )") == point(-1,2));
DLIB_TEST(string_cast<rectangle>(" [(1, 2 )(3,4)]") == rectangle(1,2,3,4));
DLIB_TEST(string_cast<dlib::vector<double> >(" (1, 2 , 3.5)") == dlib::vector<double>(1,2,3.5));
DLIB_CASSERT(string_cast<rectangle>(cast_to_string(rect1)) == rect1,"");
DLIB_CASSERT(string_cast<point>(cast_to_string(p1)) == p1,"");
DLIB_CASSERT(string_cast<dlib::vector<double> >(cast_to_string(v1)) == v1,"");
DLIB_TEST(string_cast<rectangle>(cast_to_string(rect1)) == rect1);
DLIB_TEST(string_cast<point>(cast_to_string(p1)) == p1);
DLIB_TEST(string_cast<dlib::vector<double> >(cast_to_string(v1)) == v1);
rectangle rect2;
......@@ -95,17 +95,17 @@ namespace
deserialize(rect2,sin);
deserialize(p2,sin);
deserialize(v2,sin);
DLIB_CASSERT(rect2 == rect1,"");
DLIB_CASSERT(p2 == p1,"");
DLIB_CASSERT(v2 == v1,"");
DLIB_TEST(rect2 == rect1);
DLIB_TEST(p2 == p1);
DLIB_TEST(v2 == v1);
deserialize(rect2,sin);
deserialize(p2,sin);
deserialize(v2,sin);
DLIB_CASSERT(rect2 == rect1,"");
DLIB_CASSERT(p2 == p1,"");
DLIB_CASSERT(v2 == v1,"");
DLIB_CASSERT(sin,"");
DLIB_CASSERT(sin.get() == EOF,"");
DLIB_TEST(rect2 == rect1);
DLIB_TEST(p2 == p1);
DLIB_TEST(v2 == v1);
DLIB_TEST(sin);
DLIB_TEST(sin.get() == EOF);
v1.x() = 1;
......@@ -113,25 +113,25 @@ namespace
v1.z() = 3;
matrix<double> mv = v1;
DLIB_CASSERT(mv.nr() == 3,"");
DLIB_CASSERT(mv.nc() == 1,"");
DLIB_CASSERT(mv(0) == 1,"");
DLIB_CASSERT(mv(1) == 2,"");
DLIB_CASSERT(mv(2) == 3,"");
DLIB_TEST(mv.nr() == 3);
DLIB_TEST(mv.nc() == 1);
DLIB_TEST(mv(0) == 1);
DLIB_TEST(mv(1) == 2);
DLIB_TEST(mv(2) == 3);
set_all_elements(mv,0);
DLIB_CASSERT(mv(0) == 0,"");
DLIB_CASSERT(mv(1) == 0,"");
DLIB_CASSERT(mv(2) == 0,"");
DLIB_TEST(mv(0) == 0);
DLIB_TEST(mv(1) == 0);
DLIB_TEST(mv(2) == 0);
mv(0) = 5;
mv(1) = 6;
mv(2) = 7;
v1 = mv;
DLIB_CASSERT(v1.x() == 5,"");
DLIB_CASSERT(v1.y() == 6,"");
DLIB_CASSERT(v1.z() == 7,"");
DLIB_TEST(v1.x() == 5);
DLIB_TEST(v1.y() == 6);
DLIB_TEST(v1.z() == 7);
{
......@@ -153,31 +153,31 @@ namespace
vl3 = vd3;
DLIB_CASSERT(vd2.z() == 0,"");
DLIB_CASSERT(vd3.z() == 0,"");
DLIB_CASSERT(vl2.z() == 0,"");
DLIB_CASSERT(vl3.z() == 0,"");
DLIB_TEST(vd2.z() == 0);
DLIB_TEST(vd3.z() == 0);
DLIB_TEST(vl2.z() == 0);
DLIB_TEST(vl3.z() == 0);
DLIB_CASSERT(vl2.x() == 2,"");
DLIB_CASSERT(vl3.x() == 2,"");
DLIB_CASSERT(vl2.y() == 5,"");
DLIB_CASSERT(vl3.y() == 5,"");
DLIB_TEST(vl2.x() == 2);
DLIB_TEST(vl3.x() == 2);
DLIB_TEST(vl2.y() == 5);
DLIB_TEST(vl3.y() == 5);
DLIB_CASSERT(abs(vd2.cross(vd3).dot(vd2)) < 1e-7,"");
DLIB_CASSERT(abs(vd3.cross(vd2).dot(vd2)) < 1e-7,"");
DLIB_CASSERT(abs(vd2.cross(vd3).dot(vd3)) < 1e-7,"");
DLIB_CASSERT(abs(vd3.cross(vd2).dot(vd3)) < 1e-7,"");
DLIB_TEST(abs(vd2.cross(vd3).dot(vd2)) < 1e-7);
DLIB_TEST(abs(vd3.cross(vd2).dot(vd2)) < 1e-7);
DLIB_TEST(abs(vd2.cross(vd3).dot(vd3)) < 1e-7);
DLIB_TEST(abs(vd3.cross(vd2).dot(vd3)) < 1e-7);
DLIB_CASSERT(abs(vl2.cross(vl3).dot(vl2)) == 0,"");
DLIB_CASSERT(abs(vl3.cross(vl2).dot(vl2)) == 0,"");
DLIB_CASSERT(abs(vl2.cross(vl3).dot(vl3)) == 0,"");
DLIB_CASSERT(abs(vl3.cross(vl2).dot(vl3)) == 0,"");
DLIB_TEST(abs(vl2.cross(vl3).dot(vl2)) == 0);
DLIB_TEST(abs(vl3.cross(vl2).dot(vl2)) == 0);
DLIB_TEST(abs(vl2.cross(vl3).dot(vl3)) == 0);
DLIB_TEST(abs(vl3.cross(vl2).dot(vl3)) == 0);
DLIB_CASSERT((vd2-vd3).length() < 1e-7,"");
DLIB_TEST((vd2-vd3).length() < 1e-7);
DLIB_CASSERT(vl2 == vl3,"");
DLIB_TEST(vl2 == vl3);
vl2.x() = 0;
......@@ -187,8 +187,8 @@ namespace
vl2.x() = 4;
vl3.y() = 3;
DLIB_CASSERT(vl2.cross(vl3).length() == 12,"");
DLIB_CASSERT(vl3.cross(vl2).length() == 12,"");
DLIB_TEST(vl2.cross(vl3).length() == 12);
DLIB_TEST(vl3.cross(vl2).length() == 12);
matrix<double> m(3,3);
......@@ -202,9 +202,9 @@ namespace
vd3 = m*vd3;
DLIB_CASSERT(vd3.x() == 1*2 + 2*3 + 3*4,vd3.x() << " == " << (1*2 + 2*3 + 3*4));
DLIB_CASSERT(vd3.y() == 4*2 + 5*3 + 6*4,"");
DLIB_CASSERT(vd3.z() == 7*2 + 8*3 + 9*4,"");
DLIB_TEST_MSG(vd3.x() == 1*2 + 2*3 + 3*4,vd3.x() << " == " << (1*2 + 2*3 + 3*4));
DLIB_TEST(vd3.y() == 4*2 + 5*3 + 6*4);
DLIB_TEST(vd3.z() == 7*2 + 8*3 + 9*4);
(vd3*2).dot(vd3);
(vd2*2).dot(vd3);
......@@ -232,21 +232,21 @@ namespace
vd2.x() = 6.5;
vd2.y() = 7.5;
DLIB_CASSERT((vl3 + vd2).x() == 1+6.5,"");
DLIB_CASSERT((vl3 + vd2).y() == 2+7.5,"");
DLIB_CASSERT((vl3 + vd2).z() == 3+0,"");
DLIB_TEST((vl3 + vd2).x() == 1+6.5);
DLIB_TEST((vl3 + vd2).y() == 2+7.5);
DLIB_TEST((vl3 + vd2).z() == 3+0);
DLIB_CASSERT((vl3 - vd2).x() == 1-6.5,"");
DLIB_CASSERT((vl3 - vd2).y() == 2-7.5,"");
DLIB_CASSERT((vl3 - vd2).z() == 3-0,"");
DLIB_TEST((vl3 - vd2).x() == 1-6.5);
DLIB_TEST((vl3 - vd2).y() == 2-7.5);
DLIB_TEST((vl3 - vd2).z() == 3-0);
}
{
dlib::vector<double> v(3,4,5);
DLIB_CASSERT((-v).x() == -3.0,"");
DLIB_CASSERT((-v).y() == -4.0,"");
DLIB_CASSERT((-v).z() == -5.0,"");
DLIB_TEST((-v).x() == -3.0);
DLIB_TEST((-v).y() == -4.0);
DLIB_TEST((-v).z() == -5.0);
}
{
......@@ -262,10 +262,10 @@ namespace
rect += bl;
rect += br;
DLIB_CASSERT(rect.tl_corner() == tl, "");
DLIB_CASSERT(rect.tr_corner() == tr, "");
DLIB_CASSERT(rect.bl_corner() == bl, "");
DLIB_CASSERT(rect.br_corner() == br, "");
DLIB_TEST(rect.tl_corner() == tl);
DLIB_TEST(rect.tr_corner() == tr);
DLIB_TEST(rect.bl_corner() == bl);
DLIB_TEST(rect.br_corner() == br);
}
......
......@@ -47,26 +47,26 @@ namespace
graph a, b;
set<unsigned long>::compare_1b_c s;
DLIB_CASSERT(graph_contains_length_one_cycle(a) == false,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_TEST(graph_contains_length_one_cycle(a) == false);
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
DLIB_CASSERT(a.number_of_nodes() == 0,"");
DLIB_TEST(a.number_of_nodes() == 0);
a.set_number_of_nodes(5);
DLIB_CASSERT(graph_is_connected(a) == false,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_CASSERT(a.number_of_nodes() == 5,"");
DLIB_CASSERT(graph_contains_length_one_cycle(a) == false,"");
DLIB_TEST(graph_is_connected(a) == false);
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
DLIB_TEST(a.number_of_nodes() == 5);
DLIB_TEST(graph_contains_length_one_cycle(a) == false);
for (int i = 0; i < 5; ++i)
{
a.node(i).data = i;
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
a.remove_node(1);
DLIB_CASSERT(a.number_of_nodes() == 4,"");
DLIB_TEST(a.number_of_nodes() == 4);
// make sure that only the number with data == 1 was removed
......@@ -74,69 +74,69 @@ namespace
for (int i = 0; i < 4; ++i)
{
count += a.node(i).data;
DLIB_CASSERT(a.node(i).number_of_neighbors() == 0,"");
DLIB_CASSERT(a.node(i).index() == (unsigned int)i,"");
DLIB_TEST(a.node(i).number_of_neighbors() == 0);
DLIB_TEST(a.node(i).index() == (unsigned int)i);
}
DLIB_CASSERT(count == 9,"");
DLIB_TEST(count == 9);
a.add_edge(1,1);
DLIB_CASSERT(graph_contains_length_one_cycle(a) == true,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_CASSERT(a.has_edge(1,1),"");
DLIB_CASSERT(a.node(1).number_of_neighbors() == 1,"");
DLIB_TEST(graph_contains_length_one_cycle(a) == true);
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
DLIB_TEST(a.has_edge(1,1));
DLIB_TEST(a.node(1).number_of_neighbors() == 1);
a.add_edge(1,3);
DLIB_CASSERT(a.node(1).number_of_neighbors() == 2,"");
DLIB_CASSERT(a.node(2).number_of_neighbors() == 0,"");
DLIB_CASSERT(a.node(3).number_of_neighbors() == 1,"");
DLIB_CASSERT(a.has_edge(1,1),"");
DLIB_CASSERT(a.has_edge(1,3),"");
DLIB_CASSERT(a.has_edge(3,1),"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_TEST(a.node(1).number_of_neighbors() == 2);
DLIB_TEST(a.node(2).number_of_neighbors() == 0);
DLIB_TEST(a.node(3).number_of_neighbors() == 1);
DLIB_TEST(a.has_edge(1,1));
DLIB_TEST(a.has_edge(1,3));
DLIB_TEST(a.has_edge(3,1));
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
a.remove_edge(1,1);
DLIB_CASSERT(graph_contains_length_one_cycle(a) == false,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_CASSERT(a.node(1).number_of_neighbors() == 1,"");
DLIB_CASSERT(a.node(2).number_of_neighbors() == 0,"");
DLIB_CASSERT(a.node(3).number_of_neighbors() == 1,"");
DLIB_CASSERT(a.has_edge(1,1) == false,"");
DLIB_CASSERT(a.has_edge(1,3),"");
DLIB_CASSERT(a.has_edge(3,1),"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_TEST(graph_contains_length_one_cycle(a) == false);
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
DLIB_TEST(a.node(1).number_of_neighbors() == 1);
DLIB_TEST(a.node(2).number_of_neighbors() == 0);
DLIB_TEST(a.node(3).number_of_neighbors() == 1);
DLIB_TEST(a.has_edge(1,1) == false);
DLIB_TEST(a.has_edge(1,3));
DLIB_TEST(a.has_edge(3,1));
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
swap(a,b);
DLIB_CASSERT(graph_contains_undirected_cycle(b) == false,"");
DLIB_CASSERT(b.node(1).number_of_neighbors() == 1,"");
DLIB_CASSERT(b.node(2).number_of_neighbors() == 0,"");
DLIB_CASSERT(b.node(3).number_of_neighbors() == 1,"");
DLIB_CASSERT(b.has_edge(1,1) == false,"");
DLIB_CASSERT(b.has_edge(1,3),"");
DLIB_CASSERT(b.has_edge(3,1),"");
DLIB_CASSERT(graph_contains_undirected_cycle(b) == false,"");
DLIB_TEST(graph_contains_undirected_cycle(b) == false);
DLIB_TEST(b.node(1).number_of_neighbors() == 1);
DLIB_TEST(b.node(2).number_of_neighbors() == 0);
DLIB_TEST(b.node(3).number_of_neighbors() == 1);
DLIB_TEST(b.has_edge(1,1) == false);
DLIB_TEST(b.has_edge(1,3));
DLIB_TEST(b.has_edge(3,1));
DLIB_TEST(graph_contains_undirected_cycle(b) == false);
DLIB_CASSERT(a.number_of_nodes() == 0,"");
DLIB_CASSERT(b.number_of_nodes() == 4,"");
DLIB_TEST(a.number_of_nodes() == 0);
DLIB_TEST(b.number_of_nodes() == 4);
copy_graph_structure(b,b);
DLIB_CASSERT(b.number_of_nodes() == 4,"");
DLIB_TEST(b.number_of_nodes() == 4);
b.add_edge(1,2);
DLIB_CASSERT(graph_contains_undirected_cycle(b) == false,"");
DLIB_CASSERT(graph_contains_undirected_cycle(b) == false,"");
DLIB_TEST(graph_contains_undirected_cycle(b) == false);
DLIB_TEST(graph_contains_undirected_cycle(b) == false);
b.add_edge(3,2);
DLIB_CASSERT(graph_contains_undirected_cycle(b) == true,"");
DLIB_TEST(graph_contains_undirected_cycle(b) == true);
b.add_edge(1,1);
DLIB_CASSERT(graph_is_connected(b) == false,"");
DLIB_TEST(graph_is_connected(b) == false);
b.add_edge(0,2);
DLIB_CASSERT(graph_is_connected(b) == true,"");
DLIB_TEST(graph_is_connected(b) == true);
DLIB_CASSERT(graph_contains_undirected_cycle(b) == true,"");
DLIB_TEST(graph_contains_undirected_cycle(b) == true);
DLIB_CASSERT(a.number_of_nodes() == 0,"");
DLIB_TEST(a.number_of_nodes() == 0);
for (unsigned long i = 0; i < b.number_of_nodes(); ++i)
{
......@@ -155,11 +155,11 @@ namespace
serialize(b, sout);
istringstream sin(sout.str());
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
a.set_number_of_nodes(10);
deserialize(a, sin);
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
for (unsigned long i = 0; i < a.number_of_nodes(); ++i)
{
......@@ -168,32 +168,32 @@ namespace
if ((i == 0 && a.node(i).neighbor(j).index() == e2) ||
(i == e2 && a.node(i).neighbor(j).index() == 0) )
{
DLIB_CASSERT(a.node(i).edge(j) == 'n',"");
DLIB_TEST(a.node(i).edge(j) == 'n');
}
else if ((i == 1 && a.node(i).neighbor(j).index() == e1) ||
(i == e1 && a.node(i).neighbor(j).index() == 1))
{
DLIB_CASSERT(a.node(i).edge(j) == 'a',"");
DLIB_TEST(a.node(i).edge(j) == 'a');
}
else
{
DLIB_CASSERT(i != 0 || a.node(i).neighbor(j).index() != e2,"");
DLIB_CASSERT(a.node(i).edge(j) == 'c',a.node(i).edge(j));
DLIB_TEST(i != 0 || a.node(i).neighbor(j).index() != e2);
DLIB_TEST_MSG(a.node(i).edge(j) == 'c',a.node(i).edge(j));
}
}
}
DLIB_CASSERT(a.number_of_nodes() == 4,"");
DLIB_CASSERT(a.has_edge(1,2) == true,"");
DLIB_CASSERT(a.has_edge(3,2) == true,"");
DLIB_CASSERT(a.has_edge(1,1) == true,"");
DLIB_CASSERT(a.has_edge(0,2) == true,"");
DLIB_CASSERT(a.has_edge(1,3) == true,"");
DLIB_CASSERT(a.has_edge(0,1) == false,"");
DLIB_CASSERT(a.has_edge(0,3) == false,"");
DLIB_CASSERT(a.has_edge(0,0) == false,"");
DLIB_CASSERT(a.has_edge(1,0) == false,"");
DLIB_CASSERT(a.has_edge(3,0) == false,"");
DLIB_TEST(a.number_of_nodes() == 4);
DLIB_TEST(a.has_edge(1,2) == true);
DLIB_TEST(a.has_edge(3,2) == true);
DLIB_TEST(a.has_edge(1,1) == true);
DLIB_TEST(a.has_edge(0,2) == true);
DLIB_TEST(a.has_edge(1,3) == true);
DLIB_TEST(a.has_edge(0,1) == false);
DLIB_TEST(a.has_edge(0,3) == false);
DLIB_TEST(a.has_edge(0,0) == false);
DLIB_TEST(a.has_edge(1,0) == false);
DLIB_TEST(a.has_edge(3,0) == false);
for (unsigned long i = 0; i < a.number_of_nodes(); ++i)
......@@ -202,27 +202,27 @@ namespace
}
a.remove_node(2);
DLIB_CASSERT(a.number_of_nodes() == 3,"");
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_TEST(a.number_of_nodes() == 3);
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
count = 0;
for (unsigned long i = 0; i < a.number_of_nodes(); ++i)
{
if (a.node(i).data == 0)
{
DLIB_CASSERT(a.node(i).number_of_neighbors() == 0,"");
DLIB_TEST(a.node(i).number_of_neighbors() == 0);
}
else if (a.node(i).data == 1)
{
DLIB_CASSERT(a.node(i).number_of_neighbors() == 2,"");
DLIB_TEST(a.node(i).number_of_neighbors() == 2);
}
else if (a.node(i).data == 3)
{
DLIB_CASSERT(a.node(i).number_of_neighbors() == 1,"");
DLIB_TEST(a.node(i).number_of_neighbors() == 1);
}
else
{
DLIB_CASSERT(false,"this is impossible");
DLIB_TEST_MSG(false,"this is impossible");
}
for (unsigned long j = 0; j < a.number_of_nodes(); ++j)
......@@ -231,23 +231,23 @@ namespace
(a.node(i).data == 1 && a.node(j).data == 3) ||
(a.node(i).data == 3 && a.node(j).data == 1))
{
DLIB_CASSERT(a.has_edge(i,j) == true,"");
DLIB_TEST(a.has_edge(i,j) == true);
++count;
}
else
{
DLIB_CASSERT(a.has_edge(i,j) == false,"");
DLIB_TEST(a.has_edge(i,j) == false);
}
}
}
DLIB_CASSERT(count == 3,count);
DLIB_CASSERT(graph_contains_undirected_cycle(a) == true,"");
DLIB_TEST_MSG(count == 3,count);
DLIB_TEST(graph_contains_undirected_cycle(a) == true);
a.remove_edge(1,1);
DLIB_CASSERT(graph_contains_undirected_cycle(a) == false,"");
DLIB_TEST(graph_contains_undirected_cycle(a) == false);
DLIB_CASSERT(b.number_of_nodes() == 4,"");
DLIB_TEST(b.number_of_nodes() == 4);
b.clear();
DLIB_CASSERT(b.number_of_nodes() == 0,"");
DLIB_TEST(b.number_of_nodes() == 0);
a.clear();
......@@ -271,53 +271,53 @@ namespace
a.add_edge(7,0);
a.add_edge(0,5);
DLIB_CASSERT(graph_is_connected(a),"");
DLIB_TEST(graph_is_connected(a));
set<set<unsigned long>::compare_1b_c>::kernel_1b_c sos;
dlib::graph<set<unsigned long>::compare_1b_c, set<unsigned long>::compare_1b_c>::kernel_1a_c join_tree;
unsigned long temp;
triangulate_graph_and_find_cliques(a,sos);
DLIB_CASSERT(a.number_of_nodes() == 8,"");
DLIB_TEST(a.number_of_nodes() == 8);
create_join_tree(a, join_tree);
DLIB_CASSERT(join_tree.number_of_nodes() == 6,"");
DLIB_CASSERT(graph_is_connected(join_tree) == true,"");
DLIB_CASSERT(graph_contains_undirected_cycle(join_tree) == false,"");
DLIB_CASSERT(is_join_tree(a, join_tree),"");
DLIB_TEST(join_tree.number_of_nodes() == 6);
DLIB_TEST(graph_is_connected(join_tree) == true);
DLIB_TEST(graph_contains_undirected_cycle(join_tree) == false);
DLIB_TEST(is_join_tree(a, join_tree));
// check old edges
DLIB_CASSERT(a.has_edge(1,2),"");
DLIB_CASSERT(a.has_edge(2,3),"");
DLIB_CASSERT(a.has_edge(3,4),"");
DLIB_CASSERT(a.has_edge(3,5),"");
DLIB_CASSERT(a.has_edge(3,6),"");
DLIB_CASSERT(a.has_edge(6,7),"");
DLIB_CASSERT(a.has_edge(7,0),"");
DLIB_CASSERT(a.has_edge(0,5),"");
DLIB_TEST(a.has_edge(1,2));
DLIB_TEST(a.has_edge(2,3));
DLIB_TEST(a.has_edge(3,4));
DLIB_TEST(a.has_edge(3,5));
DLIB_TEST(a.has_edge(3,6));
DLIB_TEST(a.has_edge(6,7));
DLIB_TEST(a.has_edge(7,0));
DLIB_TEST(a.has_edge(0,5));
DLIB_CASSERT(graph_is_connected(a),"");
DLIB_TEST(graph_is_connected(a));
DLIB_CASSERT(sos.size() == 6,"");
DLIB_TEST(sos.size() == 6);
temp = 1; s.add(temp);
temp = 2; s.add(temp);
DLIB_CASSERT(sos.is_member(s),"");
DLIB_TEST(sos.is_member(s));
s.clear();
temp = 2; s.add(temp);
temp = 3; s.add(temp);
DLIB_CASSERT(sos.is_member(s),"");
DLIB_TEST(sos.is_member(s));
s.clear();
temp = 4; s.add(temp);
temp = 3; s.add(temp);
DLIB_CASSERT(sos.is_member(s),"");
DLIB_TEST(sos.is_member(s));
sos.reset();
while (sos.move_next())
{
DLIB_CASSERT(is_clique(a, sos.element()),"");
DLIB_CASSERT(is_maximal_clique(a, sos.element()),"");
DLIB_TEST(is_clique(a, sos.element()));
DLIB_TEST(is_maximal_clique(a, sos.element()));
}
}
......
......@@ -41,99 +41,99 @@ namespace
hash_map test, test2;
enumerable<map_pair<int,int> >& e = test;
DLIB_CASSERT(e.at_start() == true,"");
DLIB_TEST(e.at_start() == true);
for (int j = 0; j < 4; ++j)
{
print_spinner();
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.is_in_domain(5) == false,"");
DLIB_CASSERT(test.is_in_domain(0) == false,"");
DLIB_CASSERT(test.is_in_domain(-999) == false,"");
DLIB_CASSERT(test.is_in_domain(4999) == false,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.is_in_domain(5) == false);
DLIB_TEST(test.is_in_domain(0) == false);
DLIB_TEST(test.is_in_domain(-999) == false);
DLIB_TEST(test.is_in_domain(4999) == false);
int a,b;
a = 8;
b = 94;
test.add(a,b);
DLIB_CASSERT(test.size() == 1,"");
DLIB_CASSERT(test.is_in_domain(8) == true,"");
DLIB_CASSERT(test.is_in_domain(5) == false,"");
DLIB_CASSERT(test.is_in_domain(0) == false,"");
DLIB_CASSERT(test.is_in_domain(-999) == false,"");
DLIB_CASSERT(test.is_in_domain(4999) == false,"");
DLIB_CASSERT(test[8] == 94,"");
DLIB_TEST(test.size() == 1);
DLIB_TEST(test.is_in_domain(8) == true);
DLIB_TEST(test.is_in_domain(5) == false);
DLIB_TEST(test.is_in_domain(0) == false);
DLIB_TEST(test.is_in_domain(-999) == false);
DLIB_TEST(test.is_in_domain(4999) == false);
DLIB_TEST(test[8] == 94);
a = 53;
b = 4;
test.add(a,b);
DLIB_CASSERT(test.size() == 2,"");
DLIB_CASSERT(test.is_in_domain(53) == true,"");
DLIB_CASSERT(test.is_in_domain(5) == false,"");
DLIB_CASSERT(test.is_in_domain(0) == false,"");
DLIB_CASSERT(test.is_in_domain(-999) == false,"");
DLIB_CASSERT(test.is_in_domain(4999) == false,"");
DLIB_CASSERT(test[53] == 4,"");
DLIB_TEST(test.size() == 2);
DLIB_TEST(test.is_in_domain(53) == true);
DLIB_TEST(test.is_in_domain(5) == false);
DLIB_TEST(test.is_in_domain(0) == false);
DLIB_TEST(test.is_in_domain(-999) == false);
DLIB_TEST(test.is_in_domain(4999) == false);
DLIB_TEST(test[53] == 4);
swap(test,test2);
DLIB_CASSERT(test2.size() == 2,test2.size());
DLIB_CASSERT(test2.is_in_domain(8) == true,"");
DLIB_CASSERT(test2.is_in_domain(5) == false,"");
DLIB_CASSERT(test2.is_in_domain(0) == false,"");
DLIB_CASSERT(test2.is_in_domain(-999) == false,"");
DLIB_CASSERT(test2.is_in_domain(4999) == false,"");
DLIB_CASSERT(test2[8] == 94,"");
DLIB_CASSERT(test2.size() == 2,"");
DLIB_CASSERT(test2.is_in_domain(53) == true,"");
DLIB_CASSERT(test2.is_in_domain(5) == false,"");
DLIB_CASSERT(test2.is_in_domain(0) == false,"");
DLIB_CASSERT(test2.is_in_domain(-999) == false,"");
DLIB_CASSERT(test2.is_in_domain(4999) == false,"");
DLIB_CASSERT(test2[53] == 4,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.is_in_domain(8) == false,"");
DLIB_CASSERT(test.is_in_domain(5) == false,"");
DLIB_CASSERT(test.is_in_domain(0) == false,"");
DLIB_CASSERT(test.is_in_domain(-999) == false,"");
DLIB_CASSERT(test.is_in_domain(4999) == false,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.is_in_domain(53) == false,"");
DLIB_CASSERT(test.is_in_domain(5) == false,"");
DLIB_CASSERT(test.is_in_domain(0) == false,"");
DLIB_CASSERT(test.is_in_domain(-999) == false,"");
DLIB_CASSERT(test.is_in_domain(4999) == false,"");
DLIB_TEST_MSG(test2.size() == 2,test2.size());
DLIB_TEST(test2.is_in_domain(8) == true);
DLIB_TEST(test2.is_in_domain(5) == false);
DLIB_TEST(test2.is_in_domain(0) == false);
DLIB_TEST(test2.is_in_domain(-999) == false);
DLIB_TEST(test2.is_in_domain(4999) == false);
DLIB_TEST(test2[8] == 94);
DLIB_TEST(test2.size() == 2);
DLIB_TEST(test2.is_in_domain(53) == true);
DLIB_TEST(test2.is_in_domain(5) == false);
DLIB_TEST(test2.is_in_domain(0) == false);
DLIB_TEST(test2.is_in_domain(-999) == false);
DLIB_TEST(test2.is_in_domain(4999) == false);
DLIB_TEST(test2[53] == 4);
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.is_in_domain(8) == false);
DLIB_TEST(test.is_in_domain(5) == false);
DLIB_TEST(test.is_in_domain(0) == false);
DLIB_TEST(test.is_in_domain(-999) == false);
DLIB_TEST(test.is_in_domain(4999) == false);
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.is_in_domain(53) == false);
DLIB_TEST(test.is_in_domain(5) == false);
DLIB_TEST(test.is_in_domain(0) == false);
DLIB_TEST(test.is_in_domain(-999) == false);
DLIB_TEST(test.is_in_domain(4999) == false);
test.clear();
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(test.size() == 0);
while (test.size() < 10000)
{
......@@ -143,9 +143,9 @@ namespace
test.add(a,b);
}
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
test.clear();
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(test.size() == 0);
while (test.size() < 10000)
{
......@@ -155,67 +155,67 @@ namespace
test.add(a,b);
}
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
int count = 0;
while (test.move_next())
{
DLIB_CASSERT(test.element().key() == test.element().key(),"");
DLIB_CASSERT(test.element().value() == test.element().value(),"");
DLIB_CASSERT(test.element().key() == test.element().key(),"");
DLIB_CASSERT(test.element().value() == test.element().value(),"");
DLIB_TEST(test.element().key() == test.element().key());
DLIB_TEST(test.element().value() == test.element().value());
DLIB_TEST(test.element().key() == test.element().key());
DLIB_TEST(test.element().value() == test.element().value());
++count;
}
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(count == 10000,"");
DLIB_TEST(count == 10000);
test.swap(test2);
DLIB_CASSERT(test.size() == 2,"");
DLIB_CASSERT(test2.size() == 10000,"");
DLIB_TEST(test.size() == 2);
DLIB_TEST(test2.size() == 10000);
count = 0;
test2.reset();
test2.move_next();
test2.element().value() = 99;
DLIB_CASSERT(test2[test2.element().key()] == 99,"");
DLIB_CASSERT(test2.element().value() == 99,"");
DLIB_TEST(test2[test2.element().key()] == 99);
DLIB_TEST(test2.element().value() == 99);
test2.reset();
while (test2.move_next())
{
DLIB_CASSERT(test2[test2.element().key()] == test2.element().value(),"");
DLIB_CASSERT(test2.element().key() == test2.element().key(),"");
DLIB_CASSERT(test2.element().value() == test2.element().value(),"");
DLIB_CASSERT(test2.element().key() == test2.element().key(),"");
DLIB_CASSERT(test2.element().value() == test2.element().value(),"");
DLIB_TEST(test2[test2.element().key()] == test2.element().value());
DLIB_TEST(test2.element().key() == test2.element().key());
DLIB_TEST(test2.element().value() == test2.element().value());
DLIB_TEST(test2.element().key() == test2.element().key());
DLIB_TEST(test2.element().value() == test2.element().value());
++count;
}
DLIB_CASSERT(test2.size() == 10000,"");
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_TEST(test2.size() == 10000);
DLIB_TEST(count == 10000);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.move_next() == false);
test2.clear();
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2.at_start() == true);
while (test.size() < 20000)
{
......@@ -225,7 +225,7 @@ namespace
test.add(a,b);
}
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
{
int* array1 = new int[test.size()];
......@@ -240,39 +240,39 @@ namespace
// load the state back into test.
ostringstream sout;
serialize(test,sout);
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
istringstream sin(sout.str());
test.clear();
deserialize(test,sin);
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
count = 0;
while (test.move_next())
{
DLIB_CASSERT(test.element().key() == test.element().key(),"");
DLIB_CASSERT(test.element().value() == test.element().value(),"");
DLIB_CASSERT(test.element().key() == test.element().key(),"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_TEST(test.element().key() == test.element().key());
DLIB_TEST(test.element().value() == test.element().value());
DLIB_TEST(test.element().key() == test.element().key());
DLIB_TEST(test.current_element_valid() == true);
*tmp1 = test.element().key();
*tmp2 = test.element().value();
++tmp1;
++tmp2;
++count;
}
DLIB_CASSERT(count == 20000,"");
DLIB_TEST(count == 20000);
tmp1 = array1;
tmp2 = array2;
for (int i = 0; i < 20000; ++i)
{
DLIB_CASSERT(test.is_in_domain(*tmp1) == true,"");
DLIB_CASSERT(test[*tmp1] == *tmp2,"");
DLIB_TEST(test.is_in_domain(*tmp1) == true);
DLIB_TEST(test[*tmp1] == *tmp2);
++tmp1;
++tmp2;
}
DLIB_CASSERT(test.size() == 20000,"");
DLIB_TEST(test.size() == 20000);
tmp1 = array1;
tmp2 = array2;
......@@ -280,29 +280,29 @@ namespace
while (test.size() > 10000)
{
test.remove(*tmp1,a,b);
DLIB_CASSERT(*tmp1 == a,"");
DLIB_CASSERT(*tmp2 == b,"");
DLIB_TEST(*tmp1 == a);
DLIB_TEST(*tmp2 == b);
++tmp1;
++tmp2;
++count;
}
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(count == 10000);
DLIB_TEST(test.size() == 10000);
while (test.move_next())
{
DLIB_CASSERT(test.element().key() == *tmp1,"");
DLIB_CASSERT(test.element().key() == *tmp1,"");
DLIB_CASSERT(test.element().key() == *tmp1,"");
DLIB_CASSERT(test.element().value() == *tmp2,"");
DLIB_CASSERT(test.element().value() == *tmp2,"");
DLIB_CASSERT(test.element().value() == *tmp2,"");
DLIB_TEST(test.element().key() == *tmp1);
DLIB_TEST(test.element().key() == *tmp1);
DLIB_TEST(test.element().key() == *tmp1);
DLIB_TEST(test.element().value() == *tmp2);
DLIB_TEST(test.element().value() == *tmp2);
DLIB_TEST(test.element().value() == *tmp2);
++tmp1;
++tmp2;
++count;
}
DLIB_CASSERT(count == 20000,"");
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(count == 20000);
DLIB_TEST(test.size() == 10000);
while (test.size() < 20000)
{
......@@ -317,15 +317,15 @@ namespace
count = 0;
while (test2.move_next())
{
DLIB_CASSERT(test2.element().key() == test2.element().key(),"");
DLIB_CASSERT(test2.element().value() == test2.element().value(),"");
DLIB_CASSERT(test2.element().key() == test2.element().key(),"");
DLIB_TEST(test2.element().key() == test2.element().key());
DLIB_TEST(test2.element().value() == test2.element().value());
DLIB_TEST(test2.element().key() == test2.element().key());
++count;
}
DLIB_CASSERT(count == 20000,"");
DLIB_CASSERT(test2.size() == 20000,"");
DLIB_TEST(count == 20000);
DLIB_TEST(test2.size() == 20000);
int c = 0;
while (test2.size()>0)
......@@ -334,7 +334,7 @@ namespace
}
DLIB_CASSERT(test2.size() == 0,"");
DLIB_TEST(test2.size() == 0);
delete [] array1;
delete [] array2;
}
......@@ -353,12 +353,12 @@ namespace
while (test.move_next())
{
DLIB_CASSERT(test[test.element().key()] == test.element().value(),"");
DLIB_TEST(test[test.element().key()] == test.element().value());
++count;
if (count == 5000)
break;
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_TEST(test.current_element_valid() == true);
}
test.reset();
......@@ -369,10 +369,10 @@ namespace
{
++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();
......@@ -384,26 +384,26 @@ namespace
{
test.clear();
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(test.size() == 0);
int a = 5;
int b = 6;
test.add(a,b);
a = 7;
b = 8;
test.add(a,b);
DLIB_CASSERT(test.size() == 2,"");
DLIB_CASSERT(test[7] == 8,"");
DLIB_CASSERT(test[5] == 6,"");
DLIB_CASSERT(test.is_in_domain(7),"");
DLIB_CASSERT(test.is_in_domain(5),"");
DLIB_TEST(test.size() == 2);
DLIB_TEST(test[7] == 8);
DLIB_TEST(test[5] == 6);
DLIB_TEST(test.is_in_domain(7));
DLIB_TEST(test.is_in_domain(5));
test.destroy(7);
DLIB_CASSERT(test.size() == 1,"");
DLIB_CASSERT(!test.is_in_domain(7),"");
DLIB_CASSERT(test.is_in_domain(5),"");
DLIB_TEST(test.size() == 1);
DLIB_TEST(!test.is_in_domain(7));
DLIB_TEST(test.is_in_domain(5));
test.destroy(5);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(!test.is_in_domain(7),"");
DLIB_CASSERT(!test.is_in_domain(5),"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(!test.is_in_domain(7));
DLIB_TEST(!test.is_in_domain(5));
}
......
......@@ -43,94 +43,94 @@ namespace
enumerable<const int>& e = test;
DLIB_CASSERT(e.at_start() == true,"");
DLIB_TEST(e.at_start() == true);
for (int j = 0; j < 4; ++j)
{
print_spinner();
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.is_member(5) == false,"");
DLIB_CASSERT(test.is_member(0) == false,"");
DLIB_CASSERT(test.is_member(-999) == false,"");
DLIB_CASSERT(test.is_member(4999) == false,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.is_member(5) == false);
DLIB_TEST(test.is_member(0) == false);
DLIB_TEST(test.is_member(-999) == false);
DLIB_TEST(test.is_member(4999) == false);
int a,b = 0;
a = 8;
test.add(a);
DLIB_CASSERT(test.size() == 1,"");
DLIB_CASSERT(test.is_member(8) == true,"");
DLIB_CASSERT(test.is_member(5) == false,"");
DLIB_CASSERT(test.is_member(0) == false,"");
DLIB_CASSERT(test.is_member(-999) == false,"");
DLIB_CASSERT(test.is_member(4999) == false,"");
DLIB_TEST(test.size() == 1);
DLIB_TEST(test.is_member(8) == true);
DLIB_TEST(test.is_member(5) == false);
DLIB_TEST(test.is_member(0) == false);
DLIB_TEST(test.is_member(-999) == false);
DLIB_TEST(test.is_member(4999) == false);
a = 53;
test.add(a);
DLIB_CASSERT(test.size() == 2,"");
DLIB_CASSERT(test.is_member(53) == true,"");
DLIB_CASSERT(test.is_member(5) == false,"");
DLIB_CASSERT(test.is_member(0) == false,"");
DLIB_CASSERT(test.is_member(-999) == false,"");
DLIB_CASSERT(test.is_member(4999) == false,"");
DLIB_TEST(test.size() == 2);
DLIB_TEST(test.is_member(53) == true);
DLIB_TEST(test.is_member(5) == false);
DLIB_TEST(test.is_member(0) == false);
DLIB_TEST(test.is_member(-999) == false);
DLIB_TEST(test.is_member(4999) == false);
swap(test,test2);
DLIB_CASSERT(test2.is_member(8) == true,"");
DLIB_CASSERT(test2.is_member(5) == false,"");
DLIB_CASSERT(test2.is_member(0) == false,"");
DLIB_CASSERT(test2.is_member(-999) == false,"");
DLIB_CASSERT(test2.is_member(4999) == false,"");
DLIB_CASSERT(test2.size() == 2,"");
DLIB_CASSERT(test2.is_member(53) == true,"");
DLIB_CASSERT(test2.is_member(5) == false,"");
DLIB_CASSERT(test2.is_member(0) == false,"");
DLIB_CASSERT(test2.is_member(-999) == false,"");
DLIB_CASSERT(test2.is_member(4999) == false,"");
DLIB_TEST(test2.is_member(8) == true);
DLIB_TEST(test2.is_member(5) == false);
DLIB_TEST(test2.is_member(0) == false);
DLIB_TEST(test2.is_member(-999) == false);
DLIB_TEST(test2.is_member(4999) == false);
DLIB_TEST(test2.size() == 2);
DLIB_TEST(test2.is_member(53) == true);
DLIB_TEST(test2.is_member(5) == false);
DLIB_TEST(test2.is_member(0) == false);
DLIB_TEST(test2.is_member(-999) == false);
DLIB_TEST(test2.is_member(4999) == false);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.is_member(8) == false,"");
DLIB_CASSERT(test.is_member(5) == false,"");
DLIB_CASSERT(test.is_member(0) == false,"");
DLIB_CASSERT(test.is_member(-999) == false,"");
DLIB_CASSERT(test.is_member(4999) == false,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.is_member(53) == false,"");
DLIB_CASSERT(test.is_member(5) == false,"");
DLIB_CASSERT(test.is_member(0) == false,"");
DLIB_CASSERT(test.is_member(-999) == false,"");
DLIB_CASSERT(test.is_member(4999) == false,"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.is_member(8) == false);
DLIB_TEST(test.is_member(5) == false);
DLIB_TEST(test.is_member(0) == false);
DLIB_TEST(test.is_member(-999) == false);
DLIB_TEST(test.is_member(4999) == false);
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.is_member(53) == false);
DLIB_TEST(test.is_member(5) == false);
DLIB_TEST(test.is_member(0) == false);
DLIB_TEST(test.is_member(-999) == false);
DLIB_TEST(test.is_member(4999) == false);
test.clear();
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.at_start() == false);
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(test.size() == 0);
while (test.size() < 10000)
{
......@@ -139,9 +139,9 @@ namespace
test.add(a);
}
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
test.clear();
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(test.size() == 0);
while (test.size() < 10000)
{
......@@ -150,55 +150,55 @@ namespace
test.add(a);
}
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
int count = 0;
while (test.move_next())
{
DLIB_CASSERT(test.element() == test.element(),"");
DLIB_CASSERT(test.element() == test.element(),"");
DLIB_CASSERT(test.element() == test.element(),"");
DLIB_TEST(test.element() == test.element());
DLIB_TEST(test.element() == test.element());
DLIB_TEST(test.element() == test.element());
++count;
}
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.move_next() == false);
DLIB_CASSERT(count == 10000,"");
DLIB_TEST(count == 10000);
test.swap(test2);
DLIB_CASSERT(test.size() == 2,"");
DLIB_CASSERT(test2.size() == 10000,"");
DLIB_TEST(test.size() == 2);
DLIB_TEST(test2.size() == 10000);
count = 0;
test2.reset();
while (test2.move_next())
{
DLIB_CASSERT(test2.element() == test2.element(),"");
DLIB_CASSERT(test2.element() == test2.element(),"");
DLIB_CASSERT(test2.element() == test2.element(),"");
DLIB_TEST(test2.element() == test2.element());
DLIB_TEST(test2.element() == test2.element());
DLIB_TEST(test2.element() == test2.element());
++count;
}
DLIB_CASSERT(test2.size() == 10000,"");
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_CASSERT(test2.current_element_valid() == false,"");
DLIB_CASSERT(test2.at_start() == false,"");
DLIB_CASSERT(test2.move_next() == false,"");
DLIB_TEST(test2.size() == 10000);
DLIB_TEST(count == 10000);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.move_next() == false);
DLIB_TEST(test2.current_element_valid() == false);
DLIB_TEST(test2.at_start() == false);
DLIB_TEST(test2.move_next() == false);
test2.clear();
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2.at_start() == true);
while (test.size() < 20000)
{
......@@ -207,7 +207,7 @@ namespace
test.add(a);
}
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
{
int* array = new int[test.size()];
......@@ -217,7 +217,7 @@ namespace
// load the state back into test.
ostringstream sout;
serialize(test,sout);
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
istringstream sin(sout.str());
test.clear();
deserialize(test,sin);
......@@ -227,42 +227,42 @@ namespace
count = 0;
while (test.move_next())
{
DLIB_CASSERT(test.element() == test.element(),"");
DLIB_CASSERT(test.element() == test.element(),"");
DLIB_CASSERT(test.element() == test.element(),"");
DLIB_TEST(test.element() == test.element());
DLIB_TEST(test.element() == test.element());
DLIB_TEST(test.element() == test.element());
*tmp = test.element();
++tmp;
++count;
}
DLIB_CASSERT(count == 20000,"");
DLIB_TEST(count == 20000);
tmp = array;
for (int i = 0; i < 20000; ++i)
{
DLIB_CASSERT(test.is_member(*tmp) == true,"");
DLIB_TEST(test.is_member(*tmp) == true);
++tmp;
}
DLIB_CASSERT(test.size() == 20000,"");
DLIB_TEST(test.size() == 20000);
tmp = array;
count = 0;
while (test.size() > 10000)
{
test.remove(*tmp,a);
DLIB_CASSERT(*tmp == a,"");
DLIB_TEST(*tmp == a);
++tmp;
++count;
}
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(count == 10000);
DLIB_TEST(test.size() == 10000);
while (test.move_next())
{
++count;
}
DLIB_CASSERT(count == 20000,"");
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(count == 20000);
DLIB_TEST(test.size() == 10000);
while (test.size() < 20000)
{
......@@ -276,15 +276,15 @@ namespace
count = 0;
while (test2.move_next())
{
DLIB_CASSERT(test2.element() == test2.element(),"");
DLIB_CASSERT(test2.element() == test2.element(),"");
DLIB_CASSERT(test2.element() == test2.element(),"");
DLIB_TEST(test2.element() == test2.element());
DLIB_TEST(test2.element() == test2.element());
DLIB_TEST(test2.element() == test2.element());
++count;
}
DLIB_CASSERT(count == 20000,"");
DLIB_CASSERT(test2.size() == 20000,"");
DLIB_TEST(count == 20000);
DLIB_TEST(test2.size() == 20000);
while (test2.size()>0)
......@@ -292,7 +292,7 @@ namespace
test2.remove_any(b);
}
DLIB_CASSERT(test2.size() == 0,"");
DLIB_TEST(test2.size() == 0);
delete [] array;
}
......@@ -311,7 +311,7 @@ namespace
++count;
if (count == 5000)
break;
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_TEST(test.current_element_valid() == true);
}
test.reset();
......@@ -320,10 +320,10 @@ namespace
while (test.move_next())
{
++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();
......@@ -333,22 +333,22 @@ namespace
{
test.clear();
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(test.size() == 0);
int a = 5;
test.add(a);
a = 7;
test.add(a);
DLIB_CASSERT(test.size() == 2,"");
DLIB_CASSERT(test.is_member(7),"");
DLIB_CASSERT(test.is_member(5),"");
DLIB_TEST(test.size() == 2);
DLIB_TEST(test.is_member(7));
DLIB_TEST(test.is_member(5));
test.destroy(7);
DLIB_CASSERT(test.size() == 1,"");
DLIB_CASSERT(!test.is_member(7),"");
DLIB_CASSERT(test.is_member(5),"");
DLIB_TEST(test.size() == 1);
DLIB_TEST(!test.is_member(7));
DLIB_TEST(test.is_member(5));
test.destroy(5);
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(!test.is_member(7),"");
DLIB_CASSERT(!test.is_member(5),"");
DLIB_TEST(test.size() == 0);
DLIB_TEST(!test.is_member(7));
DLIB_TEST(!test.is_member(5));
}
}
......
......@@ -41,10 +41,10 @@ namespace
{
hash_table test(16);
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_TEST(test.count(3) == 0);
enumerable<map_pair<int,int> >& e = test;
DLIB_CASSERT(e.at_start() == true,"");
DLIB_TEST(e.at_start() == true);
hash_table test2(16);
......@@ -60,44 +60,44 @@ namespace
int a = 4;
b = 5;
test2.add(a,b);
DLIB_CASSERT(test2.size() == 1,"");
DLIB_CASSERT(*test2[4] == 5,"");
DLIB_CASSERT(test2[99] == 0,"");
DLIB_TEST(test2.size() == 1);
DLIB_TEST(*test2[4] == 5);
DLIB_TEST(test2[99] == 0);
DLIB_CASSERT(test2.move_next(),"");
DLIB_CASSERT(test2.element().key() == 4,"");
DLIB_CASSERT(test2.element().value() == 5,"");
DLIB_TEST(test2.move_next());
DLIB_TEST(test2.element().key() == 4);
DLIB_TEST(test2.element().value() == 5);
swap(test,test2);
DLIB_CASSERT(test.size() == 1,"");
DLIB_CASSERT(*test[4] == 5,"");
DLIB_CASSERT(test[99] == 0,"");
DLIB_TEST(test.size() == 1);
DLIB_TEST(*test[4] == 5);
DLIB_TEST(test[99] == 0);
test.swap(test2);
a = 99;
b = 35;
test2.add(a,b);
DLIB_CASSERT(test2.size() == 2,"");
DLIB_CASSERT(*test2[4] == 5,"");
DLIB_CASSERT(*test2[99] == 35,"");
DLIB_CASSERT(test2[99] != 0,"");
DLIB_CASSERT(test2[949] == 0,"");
DLIB_TEST(test2.size() == 2);
DLIB_TEST(*test2[4] == 5);
DLIB_TEST(*test2[99] == 35);
DLIB_TEST(test2[99] != 0);
DLIB_TEST(test2[949] == 0);
test2.destroy(4);
DLIB_CASSERT(test2.size() == 1,"");
DLIB_CASSERT(test2[4] == 0,"");
DLIB_CASSERT(*test2[99] == 35,"");
DLIB_CASSERT(test2[99] != 0,"");
DLIB_CASSERT(test2[949] == 0,"");
DLIB_TEST(test2.size() == 1);
DLIB_TEST(test2[4] == 0);
DLIB_TEST(*test2[99] == 35);
DLIB_TEST(test2[99] != 0);
DLIB_TEST(test2[949] == 0);
test2.destroy(99);
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2[4] == 0,"");
DLIB_CASSERT(test2[99] == 0,"");
DLIB_CASSERT(test2[949] == 0,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2[4] == 0);
DLIB_TEST(test2[99] == 0);
DLIB_TEST(test2[949] == 0);
......@@ -113,15 +113,15 @@ namespace
for (int j = 0; j < 4; ++j)
{
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_TEST(test.count(3) == 0);
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
int a;
......@@ -131,20 +131,20 @@ namespace
int temp = a;
unsigned long count = test.count(a);
test.add(a,b);
DLIB_CASSERT(test.count(temp) == count+1,"");
DLIB_TEST(test.count(temp) == count+1);
}
{
unsigned long count = test.count(3);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
}
......@@ -156,25 +156,25 @@ namespace
a = b = i;
unsigned long count = test.count(a);
test.add(a,b);
DLIB_CASSERT(test.count(i) == count+1,"");
DLIB_TEST(test.count(i) == count+1);
}
DLIB_CASSERT(test.size() == 10000,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == true,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_CASSERT(test.move_next() == true,"");
DLIB_CASSERT(test.move_next() == true,"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_TEST(test.size() == 10000);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == true);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == true);
DLIB_TEST(test.move_next() == true);
DLIB_TEST(test.move_next() == true);
DLIB_TEST(test.current_element_valid() == true);
test.reset();
DLIB_CASSERT(test.size() == 10000,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.size() == 10000);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
if (test.size() > 0)
......@@ -187,23 +187,23 @@ namespace
{
++count;
*tmp = test.element().key();
DLIB_CASSERT(test[*tmp] != 0,"");
DLIB_CASSERT(*tmp == test.element().key(),"");
DLIB_CASSERT(*tmp == test.element().value(),"");
DLIB_CASSERT(*tmp == test.element().key(),"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_TEST(test[*tmp] != 0);
DLIB_TEST(*tmp == test.element().key());
DLIB_TEST(*tmp == test.element().value());
DLIB_TEST(*tmp == test.element().key());
DLIB_TEST(test.current_element_valid() == true);
++tmp;
}
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(count == 10000);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
swap(test,test2);
......@@ -214,11 +214,11 @@ namespace
// load the state back into test2.
ostringstream sout;
serialize(test2,sout);
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_TEST(test2.at_start() == true);
istringstream sin(sout.str());
test2.clear();
deserialize(test2,sin);
DLIB_CASSERT(test2.at_start() == true,"");
DLIB_TEST(test2.at_start() == true);
......@@ -226,16 +226,16 @@ namespace
tmp = array;
for (int i = 0; i < 10000; ++i)
{
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_TEST(*test2[*tmp] == *tmp);
DLIB_TEST(*test2[*tmp] == *tmp);
DLIB_TEST(*test2[*tmp] == *tmp);
++tmp;
}
test2.swap(test);
test.reset();
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
count = 0;
tmp = array;
while (test.size() > 0)
......@@ -246,12 +246,12 @@ namespace
++count;
}
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(count == 10000);
DLIB_TEST(test.size() == 0);
DLIB_CASSERT(count == 10000,"");
DLIB_TEST(count == 10000);
......@@ -270,19 +270,19 @@ namespace
test.add(a,b);
}
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.move_next() == true,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.move_next() == true);
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
for (int i = 0; i < 10000; ++i)
{
test.remove_any(a,b);
}
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.size() == 0);
test.clear();
......@@ -313,14 +313,14 @@ namespace
test.add(a,b);
++d;
++r;
DLIB_CASSERT(test.size() == i+1,"");
DLIB_TEST(test.size() == i+1);
}
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
for (int i = 0; i < 10000; ++i)
{
DLIB_CASSERT(*test[dtmp[i]] == rtmp[i],"");
DLIB_TEST(*test[dtmp[i]] == rtmp[i]);
}
......@@ -360,10 +360,10 @@ namespace
{
hash_table test(13);
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_TEST(test.count(3) == 0);
enumerable<map_pair<int,int> >& e = test;
DLIB_CASSERT(e.at_start() == true,"");
DLIB_TEST(e.at_start() == true);
hash_table test2(16);
......@@ -377,45 +377,45 @@ namespace
int a = 4;
b = 5;
test2.add(a,b);
DLIB_CASSERT(test2.size() == 1,"");
DLIB_CASSERT(*test2[4] == 5,"");
DLIB_CASSERT(test2[99] == 0,"");
DLIB_TEST(test2.size() == 1);
DLIB_TEST(*test2[4] == 5);
DLIB_TEST(test2[99] == 0);
DLIB_CASSERT(test2.move_next(),"");
DLIB_CASSERT(test2.element().key() == 4,"");
DLIB_CASSERT(test2.element().value() == 5,"");
DLIB_TEST(test2.move_next());
DLIB_TEST(test2.element().key() == 4);
DLIB_TEST(test2.element().value() == 5);
swap(test,test2);
DLIB_CASSERT(test.size() == 1,"");
DLIB_CASSERT(*test[4] == 5,"");
DLIB_CASSERT(test[99] == 0,"");
DLIB_TEST(test.size() == 1);
DLIB_TEST(*test[4] == 5);
DLIB_TEST(test[99] == 0);
test.swap(test2);
a = 99;
b = 35;
test2.add(a,b);
DLIB_CASSERT(test2.size() == 2,"");
DLIB_CASSERT(*test2[4] == 5,"");
DLIB_CASSERT(*test2[99] == 35,"");
DLIB_CASSERT(test2[99] != 0,"");
DLIB_CASSERT(test2[949] == 0,"");
DLIB_TEST(test2.size() == 2);
DLIB_TEST(*test2[4] == 5);
DLIB_TEST(*test2[99] == 35);
DLIB_TEST(test2[99] != 0);
DLIB_TEST(test2[949] == 0);
test2.destroy(4);
DLIB_CASSERT(test2.size() == 1,"");
DLIB_CASSERT(test2[4] == 0,"");
DLIB_CASSERT(*test2[99] == 35,"");
DLIB_CASSERT(test2[99] != 0,"");
DLIB_CASSERT(test2[949] == 0,"");
DLIB_TEST(test2.size() == 1);
DLIB_TEST(test2[4] == 0);
DLIB_TEST(*test2[99] == 35);
DLIB_TEST(test2[99] != 0);
DLIB_TEST(test2[949] == 0);
test2.destroy(99);
DLIB_CASSERT(test2.size() == 0,"");
DLIB_CASSERT(test2[4] == 0,"");
DLIB_CASSERT(test2[99] == 0,"");
DLIB_CASSERT(test2[949] == 0,"");
DLIB_TEST(test2.size() == 0);
DLIB_TEST(test2[4] == 0);
DLIB_TEST(test2[99] == 0);
DLIB_TEST(test2[949] == 0);
......@@ -431,15 +431,15 @@ namespace
for (int j = 0; j < 4; ++j)
{
DLIB_CASSERT(test.count(3) == 0,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_TEST(test.count(3) == 0);
DLIB_TEST(test.size() == 0);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.move_next() == false);
int a;
......@@ -449,20 +449,20 @@ namespace
int temp = a;
unsigned long count = test.count(a);
test.add(a,b);
DLIB_CASSERT(test.count(temp) == count+1,"");
DLIB_TEST(test.count(temp) == count+1);
}
{
unsigned long count = test.count(3);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
a = 3; test.add(a,b); ++count;
DLIB_CASSERT(test.count(3) == count,"");
DLIB_TEST(test.count(3) == count);
}
......@@ -474,25 +474,25 @@ namespace
a = b = i;
unsigned long count = test.count(a);
test.add(a,b);
DLIB_CASSERT(test.count(i) == count+1,"");
DLIB_TEST(test.count(i) == count+1);
}
DLIB_CASSERT(test.size() == 10000,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == true,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_CASSERT(test.move_next() == true,"");
DLIB_CASSERT(test.move_next() == true,"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_TEST(test.size() == 10000);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == true);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == true);
DLIB_TEST(test.move_next() == true);
DLIB_TEST(test.move_next() == true);
DLIB_TEST(test.current_element_valid() == true);
test.reset();
DLIB_CASSERT(test.size() == 10000,"");
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(test.size() == 10000);
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.current_element_valid() == false);
if (test.size() > 0)
......@@ -505,39 +505,39 @@ namespace
{
++count;
*tmp = test.element().key();
DLIB_CASSERT(test[*tmp] != 0,"");
DLIB_CASSERT(*tmp == test.element().key(),"");
DLIB_CASSERT(*tmp == test.element().value(),"");
DLIB_CASSERT(*tmp == test.element().key(),"");
DLIB_CASSERT(test.current_element_valid() == true,"");
DLIB_TEST(test[*tmp] != 0);
DLIB_TEST(*tmp == test.element().key());
DLIB_TEST(*tmp == test.element().value());
DLIB_TEST(*tmp == test.element().key());
DLIB_TEST(test.current_element_valid() == true);
++tmp;
}
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_CASSERT(test.at_start() == false,"");
DLIB_CASSERT(test.current_element_valid() == false,"");
DLIB_TEST(count == 10000);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_TEST(test.at_start() == false);
DLIB_TEST(test.current_element_valid() == false);
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
swap(test,test2);
tmp = array;
for (int i = 0; i < 10000; ++i)
{
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_CASSERT(*test2[*tmp] == *tmp,"");
DLIB_TEST(*test2[*tmp] == *tmp);
DLIB_TEST(*test2[*tmp] == *tmp);
DLIB_TEST(*test2[*tmp] == *tmp);
++tmp;
}
test2.swap(test);
test.reset();
DLIB_CASSERT(test.at_start() == true,"");
DLIB_TEST(test.at_start() == true);
count = 0;
tmp = array;
while (test.size() > 0)
......@@ -548,12 +548,12 @@ namespace
++count;
}
DLIB_CASSERT(count == 10000,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(count == 10000);
DLIB_TEST(test.size() == 0);
DLIB_CASSERT(count == 10000,"");
DLIB_TEST(count == 10000);
......@@ -572,19 +572,19 @@ namespace
test.add(a,b);
}
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.move_next() == true,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.move_next() == true);
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
for (int i = 0; i < 10000; ++i)
{
test.remove_any(a,b);
}
DLIB_CASSERT(test.at_start() == true,"");
DLIB_CASSERT(test.move_next() == false,"");
DLIB_CASSERT(test.size() == 0,"");
DLIB_TEST(test.at_start() == true);
DLIB_TEST(test.move_next() == false);
DLIB_TEST(test.size() == 0);
test.clear();
......@@ -614,14 +614,14 @@ namespace
test.add(a,b);
++d;
++r;
DLIB_CASSERT(test.size() == i+1,"");
DLIB_TEST(test.size() == i+1);
}
DLIB_CASSERT(test.size() == 10000,"");
DLIB_TEST(test.size() == 10000);
for (int i = 0; i < 10000; ++i)
{
DLIB_CASSERT(*test[dtmp[i]] == rtmp[i],"");
DLIB_TEST(*test[dtmp[i]] == rtmp[i]);
}
......
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