added debug output to test cases

This commit is contained in:
Niels 2013-12-11 08:40:53 +01:00
parent 81367a9a10
commit 442cc9b6de

View File

@ -6,6 +6,8 @@
#include <sstream> #include <sstream>
void test_null() { void test_null() {
std::cerr << "entering test_null()\n";
/* a null object */ /* a null object */
// construct // construct
@ -72,16 +74,24 @@ void test_null() {
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
assert(ex.what() == std::string("cannot cast null to JSON string")); assert(ex.what() == std::string("cannot cast null to JSON string"));
} }
std::cerr << "leaving test_null()\n";
} }
void test_bool() { void test_bool() {
std::cerr << "entering test_bool()\n";
JSON True = true; JSON True = true;
JSON False = false; JSON False = false;
bool x = True; bool x = True;
std::cerr << "leaving test_bool()\n";
} }
void test_string() { void test_string() {
std::cerr << "entering test_string()\n";
/* a string object */ /* a string object */
// construct // construct
@ -149,9 +159,13 @@ void test_string() {
std::string s2 = a; std::string s2 = a;
assert(*s1 == s2); assert(*s1 == s2);
} }
std::cerr << "leaving test_string()\n";
} }
void test_array() { void test_array() {
std::cerr << "entering test_array()\n";
JSON a; JSON a;
a += JSON(); a += JSON();
a += 1; a += 1;
@ -275,9 +289,13 @@ void test_array() {
assert(array->size() == a.size()); assert(array->size() == a.size());
assert(array->empty() == a.empty()); assert(array->empty() == a.empty());
} }
std::cerr << "leaving test_array()\n";
} }
void test_object() { void test_object() {
std::cerr << "entering test_object()\n";
// check find() // check find()
{ {
JSON o; JSON o;
@ -299,9 +317,13 @@ void test_object() {
i = a.find("foo"); i = a.find("foo");
assert(i == a.end()); assert(i == a.end());
} }
std::cerr << "leaving test_object()\n";
} }
void test_streaming() { void test_streaming() {
std::cerr << "entering test_streaming()\n";
// stream text representation into stream // stream text representation into stream
std::stringstream i; std::stringstream i;
i << "{ \"foo\": true, \"baz\": [1,2,3,4] }"; i << "{ \"foo\": true, \"baz\": [1,2,3,4] }";
@ -347,6 +369,8 @@ void test_streaming() {
JSON j; JSON j;
j << escaped_stream; j << escaped_stream;
} }
std::cerr << "leaving test_streaming()\n";
} }
int main() { int main() {