Skip to content

Commit c9eabf9

Browse files
committed
Extend the test on issue Tencent#1336 to cover all basic types
1 parent 3fc9299 commit c9eabf9

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

test/unittest/prettywritertest.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,32 @@ TEST(PrettyWriter, MoveCtor) {
340340
#endif
341341

342342
TEST(PrettyWriter, Issue_1336) {
343-
char buf[100] = "Hello";
343+
#define T(meth, val, expected) \
344+
{ \
345+
StringBuffer buffer; \
346+
PrettyWriter<StringBuffer> writer(buffer); \
347+
writer.meth(val); \
348+
\
349+
EXPECT_STREQ(expected, buffer.GetString()); \
350+
EXPECT_TRUE(writer.IsComplete()); \
351+
}
352+
353+
T(Bool, false, "false");
354+
T(Bool, true, "true");
355+
T(Int, 0, "0");
356+
T(Uint, 0, "0");
357+
T(Int64, 0, "0");
358+
T(Uint64, 0, "0");
359+
T(Double, 0, "0.0");
360+
T(String, "Hello", "\"Hello\"");
361+
#undef T
344362

345363
StringBuffer buffer;
346364
PrettyWriter<StringBuffer> writer(buffer);
347-
writer.String(buf);
365+
writer.Null();
348366

349-
EXPECT_STREQ("\"Hello\"", buffer.GetString());
350-
EXPECT_TRUE(writer.IsComplete()); \
367+
EXPECT_STREQ("null", buffer.GetString());
368+
EXPECT_TRUE(writer.IsComplete());
351369
}
352370

353371
#ifdef __clang__

0 commit comments

Comments
 (0)