Extend the test on issue #1336 to cover all basic types

This commit is contained in:
Lele Gaifax 2018-08-05 09:44:15 +02:00
parent 3fc9299b84
commit c9eabf9e13

View File

@ -340,14 +340,32 @@ TEST(PrettyWriter, MoveCtor) {
#endif
TEST(PrettyWriter, Issue_1336) {
char buf[100] = "Hello";
#define T(meth, val, expected) \
{ \
StringBuffer buffer; \
PrettyWriter<StringBuffer> writer(buffer); \
writer.meth(val); \
\
EXPECT_STREQ(expected, buffer.GetString()); \
EXPECT_TRUE(writer.IsComplete()); \
}
T(Bool, false, "false");
T(Bool, true, "true");
T(Int, 0, "0");
T(Uint, 0, "0");
T(Int64, 0, "0");
T(Uint64, 0, "0");
T(Double, 0, "0.0");
T(String, "Hello", "\"Hello\"");
#undef T
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
writer.String(buf);
writer.Null();
EXPECT_STREQ("\"Hello\"", buffer.GetString());
EXPECT_TRUE(writer.IsComplete()); \
EXPECT_STREQ("null", buffer.GetString());
EXPECT_TRUE(writer.IsComplete());
}
#ifdef __clang__