Skip to content

Commit

Permalink
Remove lambda expression in (pretty)writertest
Browse files Browse the repository at this point in the history
  • Loading branch information
miloyip committed Sep 21, 2016
1 parent f28203c commit 0761ac1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
19 changes: 10 additions & 9 deletions test/unittest/prettywritertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,18 @@ TEST(PrettyWriter, RawValue) {
}

#if RAPIDJSON_HAS_CXX11_RVALUE_REFS

static PrettyWriter<StringBuffer> WriterGen(StringBuffer &target) {
PrettyWriter<StringBuffer> writer(target);
writer.StartObject();
writer.Key("a");
writer.Int(1);
return std::move(writer);
}

TEST(PrettyWriter, MoveCtor) {
StringBuffer buffer;
auto writerGen=[](StringBuffer &target) -> PrettyWriter<StringBuffer> {
PrettyWriter<StringBuffer> writer(target);
writer.StartObject();
writer.Key("a");
writer.Int(1);
return std::move(writer);
};

PrettyWriter<StringBuffer> writer(writerGen(buffer));
PrettyWriter<StringBuffer> writer(WriterGen(buffer));
writer.EndObject();
EXPECT_TRUE(writer.IsComplete());
EXPECT_STREQ(
Expand Down
18 changes: 9 additions & 9 deletions test/unittest/writertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,17 +502,17 @@ TEST(Writer, RawValue) {
}

#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
static Writer<StringBuffer> WriterGen(StringBuffer &target) {
Writer<StringBuffer> writer(target);
writer.StartObject();
writer.Key("a");
writer.Int(1);
return std::move(writer);
}

TEST(Writer, MoveCtor) {
StringBuffer buffer;
auto writerGen=[](StringBuffer &target) -> Writer<StringBuffer> {
Writer<StringBuffer> writer(target);
writer.StartObject();
writer.Key("a");
writer.Int(1);
return std::move(writer);
};

Writer<StringBuffer> writer(writerGen(buffer));
Writer<StringBuffer> writer(WriterGen(buffer));
writer.EndObject();
EXPECT_TRUE(writer.IsComplete());
EXPECT_STREQ("{\"a\":1}", buffer.GetString());
Expand Down

0 comments on commit 0761ac1

Please sign in to comment.