1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include "Common.h"
SCENARIO("std manipulators")
{
GIVEN("logger is initialised")
{
plog::TestAppender testAppender;
plog::Logger<PLOG_DEFAULT_INSTANCE_ID> logger(plog::verbose);
logger.addAppender(&testAppender);
WHEN("std::boolalpha")
{
PLOGI << std::boolalpha << true;
THEN("the result is as expected")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("true"));
}
}
WHEN("std::hex")
{
PLOGI << std::hex << 65534;
THEN("the result is as expected")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("fffe"));
}
}
WHEN("use manipulator for the 1st message")
{
bool var = true;
PLOGI << std::boolalpha << var;
AND_WHEN("log the 2nd message")
{
PLOGI << var;
THEN("manipulators are cleared for the 2nd message")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("1"));
}
}
}
}
}
|