From 3c028685dfdb23ba3a8c28defa857640b9c93ed1 Mon Sep 17 00:00:00 2001 From: miloyip Date: Mon, 13 Apr 2015 14:25:05 +0800 Subject: Add tests for Writer API for RAPIDJSON_HAS_STDSTRING --- test/unittest/prettywritertest.cpp | 11 +++++++++++ test/unittest/writertest.cpp | 9 +++++++++ 2 files changed, 20 insertions(+) (limited to 'test') diff --git a/test/unittest/prettywritertest.cpp b/test/unittest/prettywritertest.cpp index d0abf334..fcb11219 100644 --- a/test/unittest/prettywritertest.cpp +++ b/test/unittest/prettywritertest.cpp @@ -79,3 +79,14 @@ TEST(PrettyWriter, SetIndent) { "}", buffer.GetString()); } + +#if RAPIDJSON_HAS_STDSTRING +TEST(PrettyWriter, String_STDSTRING) { + StringBuffer buffer; + PrettyWriter writer(buffer); + EXPECT_TRUE(writer.StartArray()); + EXPECT_TRUE(writer.String(std::string("Hello\n"))); + EXPECT_TRUE(writer.EndArray()); + EXPECT_STREQ("[\n \"Hello\\n\"\n]", buffer.GetString()); +} +#endif diff --git a/test/unittest/writertest.cpp b/test/unittest/writertest.cpp index 2a0f4842..7b9fa9a2 100644 --- a/test/unittest/writertest.cpp +++ b/test/unittest/writertest.cpp @@ -89,6 +89,15 @@ TEST(Writer, String) { TEST_ROUNDTRIP("[\"Hello\"]"); TEST_ROUNDTRIP("[\"Hello\\u0000World\"]"); TEST_ROUNDTRIP("[\"\\\"\\\\/\\b\\f\\n\\r\\t\"]"); + +#if RAPIDJSON_HAS_STDSTRING + { + StringBuffer buffer; + Writer writer(buffer); + writer.String(std::string("Hello\n")); + EXPECT_STREQ("\"Hello\\n\"", buffer.GetString()); + } +#endif } TEST(Writer, Double) { -- cgit v1.2.3