From 3b2156d928af60bdff92801384673e3f24691b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tall=C3=B3di=20Mih=C3=A1ly?= Date: Mon, 19 Sep 2016 21:46:42 +0200 Subject: [PATCH] Tests for Writer, PrettyWriter move constructors --- test/unittest/prettywritertest.cpp | 21 +++++++++++++++++++++ test/unittest/writertest.cpp | 16 ++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/test/unittest/prettywritertest.cpp b/test/unittest/prettywritertest.cpp index a372f7986f..4305f0ef06 100644 --- a/test/unittest/prettywritertest.cpp +++ b/test/unittest/prettywritertest.cpp @@ -201,3 +201,24 @@ TEST(PrettyWriter, RawValue) { "}", buffer.GetString()); } + +TEST(PrettyWriter, MoveCtor) { + StringBuffer buffer; + auto writerGen=[](StringBuffer &buffer) -> PrettyWriter { + PrettyWriter writer(buffer); + writer.StartObject(); + writer.Key("a"); + writer.Int(1); + return std::move(writer); + }; + + PrettyWriter writer(writerGen(buffer)); + writer.EndObject(); + EXPECT_TRUE(writer.IsComplete()); + EXPECT_STREQ( + "{\n" + " \"a\": 1\n" + "}", + buffer.GetString()); +} + diff --git a/test/unittest/writertest.cpp b/test/unittest/writertest.cpp index 29f7626092..805198540f 100644 --- a/test/unittest/writertest.cpp +++ b/test/unittest/writertest.cpp @@ -495,3 +495,19 @@ TEST(Writer, RawValue) { EXPECT_TRUE(writer.IsComplete()); EXPECT_STREQ("{\"a\":1,\"raw\":[\"Hello\\nWorld\", 123.456]}", buffer.GetString()); } + +TEST(Writer, MoveCtor) { + StringBuffer buffer; + auto writerGen=[](StringBuffer &buffer) -> Writer { + Writer writer(buffer); + writer.StartObject(); + writer.Key("a"); + writer.Int(1); + return std::move(writer); + }; + + Writer writer(writerGen(buffer)); + writer.EndObject(); + EXPECT_TRUE(writer.IsComplete()); + EXPECT_STREQ("{\"a\":1}", buffer.GetString()); +}