You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
813 B
45 lines
813 B
// Let Catch provide main():
|
|
#define CATCH_CONFIG_MAIN
|
|
// #define CATCH_CONFIG_ENABLE_BENCHMARKING
|
|
|
|
#include <sstream>
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include <Logger.hpp>
|
|
|
|
|
|
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" );
|
|
}
|
|
|