From 9718e58120f6563cc2bcd27dd64e7e2d7f5035d7 Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Wed, 2 Dec 2009 01:29:16 +0000 Subject: [PATCH] Added test for duplicate key --- test/parsertests.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/parsertests.cpp b/test/parsertests.cpp index d30ed02..47b1d8b 100644 --- a/test/parsertests.cpp +++ b/test/parsertests.cpp @@ -689,6 +689,23 @@ namespace Test return true; } + + bool DuplicateKey() + { + std::string input = "{a: 1, b: 2, c: 3, a: 4}"; + std::stringstream stream(input); + YAML::Parser parser(stream); + YAML::Node doc; + parser.GetNextDocument(doc); + + if(doc["a"] != 1) + return false; + if(doc["b"] != 2) + return false; + if(doc["c"] != 3) + return false; + return true; + } } namespace { @@ -951,6 +968,7 @@ namespace Test RunParserTest(&Parser::BlockKeyWithNullValue, "block key with null value", passed, total); RunParserTest(&Parser::Bases, "bases", passed, total); RunParserTest(&Parser::KeyNotFound, "key not found", passed, total); + RunParserTest(&Parser::DuplicateKey, "duplicate key", passed, total); RunEncodingTest(&EncodeToUtf8, false, "UTF-8, no BOM", passed, total); RunEncodingTest(&EncodeToUtf8, true, "UTF-8 with BOM", passed, total);