From 98d58d0b4dbb5575cada7694f5ef60cc247befd0 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sun, 11 Mar 2018 10:47:56 +0100 Subject: [PATCH] failing unittest The failure is related to the assignment to the very same Node "value". If different Nodes are used each time, it works. If no alias is involved, it works as well. --- test/integration/load_node_test.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/integration/load_node_test.cpp b/test/integration/load_node_test.cpp index 02bb8fe..4a78296 100644 --- a/test/integration/load_node_test.cpp +++ b/test/integration/load_node_test.cpp @@ -78,6 +78,22 @@ TEST(LoadNodeTest, IterateMap) { EXPECT_EQ(3, i); } +TEST(LoadNodeTest, AliasMultipleAssign) { + Node doc = Load("{A: &DEFAULT {str: string, int: 42, float: 3.1415}, B: *DEFAULT}"); + + for (YAML::const_iterator it = doc.begin(); it != doc.end(); ++it) { + SCOPED_TRACE("group " + it->first.as()); + Node value; + + value = it->second["str"]; + EXPECT_STREQ(value.as().c_str(), "string"); + value = it->second["float"]; + EXPECT_EQ(value.as(), 3.1415f); + value = it->second["int"]; + EXPECT_EQ(value.as(), 42); + } +} + #ifdef BOOST_FOREACH TEST(LoadNodeTest, ForEach) { Node node = Load("[1, 3, 5, 7]");