// ObjectFormat_t.cpp #include "ObjectFormat.hpp" #include #include #include using std::cout; using std::cerr; using std::endl; using std::string; void print() { cout << begin_object; cout << "Class One:" << new_line; cout << "x = 1" << new_line; cout << "y = 2" << new_line; cout << "zobj = "; cout << begin_object; cout << "Class Two:" << new_line; cout << "a1 = 1" << new_line;; cout << "a2 = 2" << new_line;; cout << "a3 = 3" << end_object; cout << new_line; cout << "z = 2" << end_object; cout << new_line; } //********************************************************************** int main( ) { string component = "ObjectFormat"; string ok_prefix = component + " (I): "; string error_prefix = component + " test (E): "; cout << ok_prefix << "---------- Testing component " + component + ". ----------" << endl; // Make sure assert is enabled. bool assert_flag = false; assert ( ( assert_flag = true, assert_flag ) ); if ( ! assert_flag ) { cerr << "Assert is disabled" << endl; return 1; } //******************************************************************** cout << ok_prefix << "Test default." << endl; ObjectFormat::print_format(cout); print(); //******************************************************************** cout << ok_prefix << "Test null." << endl; cout << null_format; ObjectFormat::print_format(cout); print(); //******************************************************************** cout << ok_prefix << "Test indented." << endl; cout << indented_format; ObjectFormat::print_format(cout); print(); //******************************************************************** cout << ok_prefix << "Test bracketed." << endl; cout << bracketed_format; ObjectFormat::print_format(cout); print(); assert( bracketed_format.get_begin_object_string() == "[ " ); assert( bracketed_format.get_end_object_string() == " ]" ); assert( bracketed_format.get_indent_string() == " " ); assert( bracketed_format.get_prefix_string() == "" ); //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }