#define BOOST_TEST_MODULE DLCL_Tests #include #include // new to catch output #include #include "DListT.h" // so we can use the elements of the output_test_stream without // a horrid list of namespaces using boost::test_tools::output_test_stream; using namespace std; BOOST_AUTO_TEST_SUITE( DLCL_Methods_Tests) void BadDataTest(DListT & list) { output_test_stream output; string errorMessage = "Error: Attempt to access Empty List.\n"; // change stdout to be the new output buffer streambuf * old = cout.rdbuf(output.rdbuf()); // force the error string x = list.Data(); // restore cout. cout.rdbuf(old); BOOST_TEST(x == "NO DATA"); BOOST_TEST(output.is_equal(errorMessage,false)); BOOST_TEST(output.check_length(errorMessage.size(), false)); BOOST_TEST(!output.is_empty(false)); return; } BOOST_AUTO_TEST_CASE(DLCL_Constructor_Test) { DListT aList; BOOST_TEST(aList.Size() == 0); BadDataTest(aList); aList.Right(); BadDataTest(aList); aList.Home(); BadDataTest(aList); aList.Left(); BadDataTest(aList); } BOOST_AUTO_TEST_SUITE_END()