Unverified Commit 1d8542ad authored by Ted Lyngmo's avatar Ted Lyngmo Committed by GitHub
Browse files

Add NodeTest EqualRepresentationAfterMoveAssignment (#816)

Add check that a move assigned Node gets the same representation as the
moved-from Node had before the move.
parent 6f7ead51
......@@ -9,6 +9,8 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <sstream>
using ::testing::AnyOf;
using ::testing::Eq;
......@@ -135,6 +137,20 @@ TEST(NodeTest, NodeAssignment) {
EXPECT_EQ(node1[3], node2[3]);
}
TEST(NodeTest, EqualRepresentationAfterMoveAssignment) {
Node node1;
Node node2;
std::ostringstream ss1, ss2;
node1["foo"] = "bar";
ss1 << node1;
node2["hello"] = "world";
node2 = std::move(node1);
ss2 << node2;
EXPECT_FALSE(node2["hello"]);
EXPECT_EQ("bar", node2["foo"].as<std::string>());
EXPECT_EQ(ss1.str(), ss2.str());
}
TEST(NodeTest, MapElementRemoval) {
Node node;
node["foo"] = "bar";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment