#define BOOST_TEST_MODULE DLCL_Tests #include <boost/test/unit_test.hpp> #include <boost/test/included/unit_test.hpp> // new to catch output #include <boost/test/tools/output_test_stream.hpp> #include "QueueT.h" #include <vector> // 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;
out_of_range
exception.
BOOST_AUTO_TEST_CASE (Queue_Constructor) { QueueT q; BOOST_TEST(q.IsEmpty()); BOOST_TEST(not q.IsFull()); BOOST_TEST(q.Size() == 0); return; }
output_test_stream output; streambuf * old = cout.rdbuf(output.rdbuf()); // force the error Queue q; q.Front(); // restore cout. cout.rdbuf(old);
BOOST_AUTO_TEST_CASE(Front_Error_Test) { output_test_stream output; streambuf * old = cout.rdbuf(output.rdbuf()); string goodMessage = "Invalid Front on Empty Queue\n"; tring badMessage = "invalid front on empty q\n"; QueueT q; q.Front(); cout.rdbuf(old); BOOST_TEST(not output.is_empty(false)); BOOST_TEST(output.check_length(goodMessage.size(),false)); BOOST_TEST(output.check_length(badMessage.size(),false), "This should fail"); BOOST_TEST(output.is_equal(goodMessage,false)); BOOST_TEST(output.is_equal(badMessage,false)); output.flush(); return; }
call
to throw an exception of exception_type