mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Add NodeTest EqualRepresentationAfterMoveAssignment (#816)
Add check that a move assigned Node gets the same representation as the moved-from Node had before the move.
This commit is contained in:
@@ -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";
|
||||
|
Reference in New Issue
Block a user