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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include "Common.h"
#include <vector>
#include <utility>
SCENARIO("handling null char pointers")
{
GIVEN("logger is initialised")
{
plog::TestAppender testAppender;
plog::Logger<PLOG_DEFAULT_INSTANCE_ID> logger(plog::verbose);
logger.addAppender(&testAppender);
WHEN("type is char* and its value is NULL")
{
char* var = NULL;
PLOGI << var;
THEN("the result is as expected")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("(null)"));
}
}
WHEN("type is std::vector<char*> and value of elements is NULL")
{
std::vector<char*> var;
var.push_back(NULL);
var.push_back(NULL);
PLOGI << var;
THEN("the result is as expected")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("[(null), (null)]"));
}
}
WHEN("type is std::pair<char*, char*> and value of elements is NULL")
{
std::pair<char*, char*> var;
PLOGI << var;
THEN("the result is as expected")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("(null):(null)"));
}
}
#if PLOG_ENABLE_WCHAR_INPUT
WHEN("type is wchar_t* and its value is NULL")
{
wchar_t* var = NULL;
PLOGI << var;
THEN("the result is as expected")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("(null)"));
}
}
WHEN("type is std::vector<wchar_t*> and value of elements is NULL")
{
std::vector<wchar_t*> var;
var.push_back(NULL);
var.push_back(NULL);
PLOGI << var;
THEN("the result is as expected")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("[(null), (null)]"));
}
}
WHEN("type is std::pair<wchar_t*, wchar_t*> and value of elements is NULL")
{
std::pair<wchar_t*, wchar_t*> var;
PLOGI << var;
THEN("the result is as expected")
{
CHECK_EQ(testAppender.getMessage(), PLOG_NSTR("(null):(null)"));
}
}
#endif
}
}
|