From a6e1d4cf74826c0c465f0e01861f8aae3c26e8e7 Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Mon, 12 Sep 2011 12:42:23 -0500 Subject: [PATCH] Added two alias tests --- test/new-api/nodetests.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/new-api/nodetests.cpp b/test/new-api/nodetests.cpp index 60a36d8..3c6a1ac 100644 --- a/test/new-api/nodetests.cpp +++ b/test/new-api/nodetests.cpp @@ -163,6 +163,31 @@ namespace Test YAML_ASSERT((node["squares"].as >() == squares)); return true; } + + TEST SimpleAlias() + { + YAML::Node node; + node["foo"] = "value"; + node["bar"] = node["foo"]; + YAML_ASSERT(node["foo"].as() == "value"); + YAML_ASSERT(node["bar"].as() == "value"); + YAML_ASSERT(node["foo"] == node["bar"]); + YAML_ASSERT(node.size() == 2); + return true; + } + + TEST AliasAsKey() + { + YAML::Node node; + node["foo"] = "value"; + YAML::Node value = node["foo"]; + node[value] = "foo"; + YAML_ASSERT(node["foo"].as() == "value"); + YAML_ASSERT(node[value].as() == "foo"); + YAML_ASSERT(node["value"].as() == "foo"); + YAML_ASSERT(node.size() == 2); + return true; + } } void RunNodeTest(TEST (*test)(), const std::string& name, int& passed, int& total) { @@ -198,6 +223,8 @@ namespace Test RunNodeTest(&Node::StdVector, "std::vector", passed, total); RunNodeTest(&Node::StdList, "std::list", passed, total); RunNodeTest(&Node::StdMap, "std::map", passed, total); + RunNodeTest(&Node::SimpleAlias, "simple alias", passed, total); + RunNodeTest(&Node::AliasAsKey, "alias as key", passed, total); std::cout << "Node tests: " << passed << "/" << total << " passed\n"; return passed == total;