// Let Catch provide main(): #define CATCH_CONFIG_MAIN // #define CATCH_CONFIG_ENABLE_BENCHMARKING #include #include #include TEST_CASE( "Simple test" ) { // setup std::ostringstream oss; Logger::getInstance()->setStream(&oss); // simple usage LOG << "pretty weather" << END; REQUIRE( oss.str() == "pretty weather\n" ); // chaining inserts oss.str(""); const std::string s = "apple(s)"; const int i = 2; LOG << "i have " << i << " " << s << END; REQUIRE( oss.str() == "i have 2 apple(s)\n" ); // output is only written at END oss.str(""); LOG << 1; LOG << 2; REQUIRE( oss.str() == "" ); LOG << END; REQUIRE( oss.str() == "12\n" ); LOG << 3; REQUIRE( oss.str() == "12\n" ); oss.str(""); LOG << END; REQUIRE( oss.str() == "3\n" ); }