summaryrefslogtreecommitdiffstats
path: root/yaml-cpp/test
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-08-24 17:52:52 +0300
committerimarom <imarom@cisco.com>2015-08-24 17:52:52 +0300
commit36c6c87fe4380b214f8ff8a45dc0213fa109821c (patch)
treeac4886a9e36fef3d0d7f621ac46678ebb7486015 /yaml-cpp/test
parent7d3be8c612e295820649779335288c197b80ccb2 (diff)
fix compile issues with external libarries
Diffstat (limited to 'yaml-cpp/test')
-rwxr-xr-xyaml-cpp/test/CMakeLists.txt15
-rwxr-xr-xyaml-cpp/test/emittertests.cpp1148
-rwxr-xr-xyaml-cpp/test/emittertests.h13
-rwxr-xr-xyaml-cpp/test/main.cpp7
-rwxr-xr-xyaml-cpp/test/nodetests.h13
-rwxr-xr-xyaml-cpp/test/old-api/parsertests.cpp1237
-rwxr-xr-xyaml-cpp/test/old-api/spectests.cpp1456
-rwxr-xr-xyaml-cpp/test/parsertests.h13
-rwxr-xr-xyaml-cpp/test/specexamples.h850
-rwxr-xr-xyaml-cpp/test/spectests.cpp149
-rwxr-xr-xyaml-cpp/test/spectests.h360
-rwxr-xr-xyaml-cpp/test/tests.cpp30
-rwxr-xr-xyaml-cpp/test/tests.h53
13 files changed, 0 insertions, 5344 deletions
diff --git a/yaml-cpp/test/CMakeLists.txt b/yaml-cpp/test/CMakeLists.txt
deleted file mode 100755
index 241c19ef..00000000
--- a/yaml-cpp/test/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-file(GLOB test_headers [a-z]*.h)
-file(GLOB test_sources [a-z]*.cpp)
-file(GLOB test_old_api_sources old-api/[a-z]*.cpp)
-
-list(APPEND test_sources ${test_old_api_sources})
-
-include_directories(${YAML_CPP_SOURCE_DIR}/test)
-
-add_executable(run-tests
- ${test_sources}
- ${test_headers}
-)
-target_link_libraries(run-tests yaml-cpp)
-
-add_test(yaml-reader-test run-tests)
diff --git a/yaml-cpp/test/emittertests.cpp b/yaml-cpp/test/emittertests.cpp
deleted file mode 100755
index a7fdab67..00000000
--- a/yaml-cpp/test/emittertests.cpp
+++ /dev/null
@@ -1,1148 +0,0 @@
-#include "tests.h"
-#include "yaml-cpp/yaml.h"
-#include <iostream>
-
-namespace Test
-{
- namespace Emitter {
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- // correct emitting
-
- void SimpleScalar(YAML::Emitter& out, std::string& desiredOutput) {
- out << "Hello, World!";
- desiredOutput = "Hello, World!";
- }
-
- void SimpleSeq(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::BeginSeq;
- out << "eggs";
- out << "bread";
- out << "milk";
- out << YAML::EndSeq;
-
- desiredOutput = "- eggs\n- bread\n- milk";
- }
-
- void SimpleFlowSeq(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::Flow;
- out << YAML::BeginSeq;
- out << "Larry";
- out << "Curly";
- out << "Moe";
- out << YAML::EndSeq;
-
- desiredOutput = "[Larry, Curly, Moe]";
- }
-
- void EmptyFlowSeq(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::Flow;
- out << YAML::BeginSeq;
- out << YAML::EndSeq;
-
- desiredOutput = "[]";
- }
-
- void NestedBlockSeq(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::BeginSeq;
- out << "item 1";
- out << YAML::BeginSeq << "subitem 1" << "subitem 2" << YAML::EndSeq;
- out << YAML::EndSeq;
-
- desiredOutput = "- item 1\n-\n - subitem 1\n - subitem 2";
- }
-
- void NestedFlowSeq(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::BeginSeq;
- out << "one";
- out << YAML::Flow << YAML::BeginSeq << "two" << "three" << YAML::EndSeq;
- out << YAML::EndSeq;
-
- desiredOutput = "- one\n- [two, three]";
- }
-
- void SimpleMap(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::BeginMap;
- out << YAML::Key << "name";
- out << YAML::Value << "Ryan Braun";
- out << YAML::Key << "position";
- out << YAML::Value << "3B";
- out << YAML::EndMap;
-
- desiredOutput = "name: Ryan Braun\nposition: 3B";
- }
-
- void SimpleFlowMap(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::Flow;
- out << YAML::BeginMap;
- out << YAML::Key << "shape";
- out << YAML::Value << "square";
- out << YAML::Key << "color";
- out << YAML::Value << "blue";
- out << YAML::EndMap;
-
- desiredOutput = "{shape: square, color: blue}";
- }
-
- void MapAndList(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::BeginMap;
- out << YAML::Key << "name";
- out << YAML::Value << "Barack Obama";
- out << YAML::Key << "children";
- out << YAML::Value << YAML::BeginSeq << "Sasha" << "Malia" << YAML::EndSeq;
- out << YAML::EndMap;
-
- desiredOutput = "name: Barack Obama\nchildren:\n - Sasha\n - Malia";
- }
-
- void ListAndMap(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::BeginSeq;
- out << "item 1";
- out << YAML::BeginMap;
- out << YAML::Key << "pens" << YAML::Value << 8;
- out << YAML::Key << "pencils" << YAML::Value << 14;
- out << YAML::EndMap;
- out << "item 2";
- out << YAML::EndSeq;
-
- desiredOutput = "- item 1\n- pens: 8\n pencils: 14\n- item 2";
- }
-
- void NestedBlockMap(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::BeginMap;
- out << YAML::Key << "name";
- out << YAML::Value << "Fred";
- out << YAML::Key << "grades";
- out << YAML::Value;
- out << YAML::BeginMap;
- out << YAML::Key << "algebra" << YAML::Value << "A";
- out << YAML::Key << "physics" << YAML::Value << "C+";
- out << YAML::Key << "literature" << YAML::Value << "B";
- out << YAML::EndMap;
- out << YAML::EndMap;
-
- desiredOutput = "name: Fred\ngrades:\n algebra: A\n physics: C+\n literature: B";
- }
-
- void NestedFlowMap(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::Flow;
- out << YAML::BeginMap;
- out << YAML::Key << "name";
- out << YAML::Value << "Fred";
- out << YAML::Key << "grades";
- out << YAML::Value;
- out << YAML::BeginMap;
- out << YAML::Key << "algebra" << YAML::Value << "A";
- out << YAML::Key << "physics" << YAML::Value << "C+";
- out << YAML::Key << "literature" << YAML::Value << "B";
- out << YAML::EndMap;
- out << YAML::EndMap;
-
- desiredOutput = "{name: Fred, grades: {algebra: A, physics: C+, literature: B}}";
- }
-
- void MapListMix(YAML::Emitter& out, std::string& desiredOutput) {
- out << YAML::BeginMap;
- out << YAML::Key << "name";
- out << YAML::Value << "Bob";
- out << YAML::Key << "position";
- out << YAML::Value;
- out << YAML::Flow << YAML::BeginSeq << 2 << 4 << YAML::EndSeq;
- out << YAML::Key << "invincible" << YAML::Value << YAML::OnOffBool << false;
- out << YAML::EndMap;
-
- desiredOutput = "name: Bob\nposition: [2, 4]\ninvincible: off";
- }
-
- void SimpleLongKey(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::LongKey;
- out << YAML::BeginMap;
- out << YAML::Key << "height";
- out << YAML::Value << "5'9\"";
- out << YAML::Key << "weight";
- out << YAML::Value << 145;
- out << YAML::EndMap;
-
- desiredOutput = "? height\n: 5'9\"\n? weight\n: 145";
- }
-
- void SingleLongKey(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << "age";
- out << YAML::Value << "24";
- out << YAML::LongKey << YAML::Key << "height";
- out << YAML::Value << "5'9\"";
- out << YAML::Key << "weight";
- out << YAML::Value << 145;
- out << YAML::EndMap;
-
- desiredOutput = "age: 24\n? height\n: 5'9\"\nweight: 145";
- }
-
- void ComplexLongKey(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::LongKey;
- out << YAML::BeginMap;
- out << YAML::Key << YAML::BeginSeq << 1 << 3 << YAML::EndSeq;
- out << YAML::Value << "monster";
- out << YAML::Key << YAML::Flow << YAML::BeginSeq << 2 << 0 << YAML::EndSeq;
- out << YAML::Value << "demon";
- out << YAML::EndMap;
-
- desiredOutput = "?\n - 1\n - 3\n: monster\n? [2, 0]\n: demon";
- }
-
- void AutoLongKey(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << YAML::BeginSeq << 1 << 3 << YAML::EndSeq;
- out << YAML::Value << "monster";
- out << YAML::Key << YAML::Flow << YAML::BeginSeq << 2 << 0 << YAML::EndSeq;
- out << YAML::Value << "demon";
- out << YAML::Key << "the origin";
- out << YAML::Value << "angel";
- out << YAML::EndMap;
-
- desiredOutput = "?\n - 1\n - 3\n: monster\n? [2, 0]\n: demon\nthe origin: angel";
- }
-
- void ScalarFormat(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << "simple scalar";
- out << YAML::SingleQuoted << "explicit single-quoted scalar";
- out << YAML::DoubleQuoted << "explicit double-quoted scalar";
- out << "auto-detected\ndouble-quoted scalar";
- out << "a non-\"auto-detected\" double-quoted scalar";
- out << YAML::Literal << "literal scalar\nthat may span\nmany, many\nlines and have \"whatever\" crazy\tsymbols that we like";
- out << YAML::EndSeq;
-
- desiredOutput = "- simple scalar\n- 'explicit single-quoted scalar'\n- \"explicit double-quoted scalar\"\n- \"auto-detected\\x0adouble-quoted scalar\"\n- a non-\"auto-detected\" double-quoted scalar\n- |\n literal scalar\n that may span\n many, many\n lines and have \"whatever\" crazy\tsymbols that we like";
- }
-
- void AutoLongKeyScalar(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << YAML::Literal << "multi-line\nscalar";
- out << YAML::Value << "and its value";
- out << YAML::EndMap;
-
- desiredOutput = "? |\n multi-line\n scalar\n: and its value";
- }
-
- void LongKeyFlowMap(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow;
- out << YAML::BeginMap;
- out << YAML::Key << "simple key";
- out << YAML::Value << "and value";
- out << YAML::LongKey << YAML::Key << "long key";
- out << YAML::Value << "and its value";
- out << YAML::EndMap;
-
- desiredOutput = "{simple key: and value, ? long key: and its value}";
- }
-
- void BlockMapAsKey(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key;
- out << YAML::BeginMap;
- out << YAML::Key << "key" << YAML::Value << "value";
- out << YAML::Key << "next key" << YAML::Value << "next value";
- out << YAML::EndMap;
- out << YAML::Value;
- out << "total value";
- out << YAML::EndMap;
-
- desiredOutput = "?\n key: value\n next key: next value\n: total value";
- }
-
- void AliasAndAnchor(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::Anchor("fred");
- out << YAML::BeginMap;
- out << YAML::Key << "name" << YAML::Value << "Fred";
- out << YAML::Key << "age" << YAML::Value << 42;
- out << YAML::EndMap;
- out << YAML::Alias("fred");
- out << YAML::EndSeq;
-
- desiredOutput = "- &fred\n name: Fred\n age: 42\n- *fred";
- }
-
- void AliasAndAnchorWithNull(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::Anchor("fred") << YAML::Null;
- out << YAML::Alias("fred");
- out << YAML::EndSeq;
-
- desiredOutput = "- &fred ~\n- *fred";
- }
-
- void AliasAndAnchorInFlow(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginSeq;
- out << YAML::Anchor("fred");
- out << YAML::BeginMap;
- out << YAML::Key << "name" << YAML::Value << "Fred";
- out << YAML::Key << "age" << YAML::Value << 42;
- out << YAML::EndMap;
- out << YAML::Alias("fred");
- out << YAML::EndSeq;
-
- desiredOutput = "[&fred {name: Fred, age: 42}, *fred]";
- }
-
- void SimpleVerbatimTag(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::VerbatimTag("!foo") << "bar";
-
- desiredOutput = "!<!foo> bar";
- }
-
- void VerbatimTagInBlockSeq(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::VerbatimTag("!foo") << "bar";
- out << "baz";
- out << YAML::EndSeq;
-
- desiredOutput = "- !<!foo> bar\n- baz";
- }
-
- void VerbatimTagInFlowSeq(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginSeq;
- out << YAML::VerbatimTag("!foo") << "bar";
- out << "baz";
- out << YAML::EndSeq;
-
- desiredOutput = "[!<!foo> bar, baz]";
- }
-
- void VerbatimTagInFlowSeqWithNull(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginSeq;
- out << YAML::VerbatimTag("!foo") << YAML::Null;
- out << "baz";
- out << YAML::EndSeq;
-
- desiredOutput = "[!<!foo> ~, baz]";
- }
-
- void VerbatimTagInBlockMap(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << YAML::VerbatimTag("!foo") << "bar";
- out << YAML::Value << YAML::VerbatimTag("!waz") << "baz";
- out << YAML::EndMap;
-
- desiredOutput = "!<!foo> bar: !<!waz> baz";
- }
-
- void VerbatimTagInFlowMap(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginMap;
- out << YAML::Key << YAML::VerbatimTag("!foo") << "bar";
- out << YAML::Value << "baz";
- out << YAML::EndMap;
-
- desiredOutput = "{!<!foo> bar: baz}";
- }
-
- void VerbatimTagInFlowMapWithNull(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginMap;
- out << YAML::Key << YAML::VerbatimTag("!foo") << YAML::Null;
- out << YAML::Value << "baz";
- out << YAML::EndMap;
-
- desiredOutput = "{!<!foo> ~: baz}";
- }
-
- void VerbatimTagWithEmptySeq(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::VerbatimTag("!foo") << YAML::BeginSeq << YAML::EndSeq;
-
- desiredOutput = "!<!foo>\n[]";
- }
-
- void VerbatimTagWithEmptyMap(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::VerbatimTag("!bar") << YAML::BeginMap << YAML::EndMap;
-
- desiredOutput = "!<!bar>\n{}";
- }
-
- void VerbatimTagWithEmptySeqAndMap(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::VerbatimTag("!foo") << YAML::BeginSeq << YAML::EndSeq;
- out << YAML::VerbatimTag("!bar") << YAML::BeginMap << YAML::EndMap;
- out << YAML::EndSeq;
-
- desiredOutput = "- !<!foo>\n []\n- !<!bar>\n {}";
- }
-
- void ByKindTagWithScalar(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::DoubleQuoted << "12";
- out << "12";
- out << YAML::TagByKind << "12";
- out << YAML::EndSeq;
-
- desiredOutput = "- \"12\"\n- 12\n- ! 12";
- }
-
- void LocalTagWithScalar(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::LocalTag("foo") << "bar";
-
- desiredOutput = "!foo bar";
- }
-
- void BadLocalTag(YAML::Emitter& out, std::string& desiredError)
- {
- out << YAML::LocalTag("e!far") << "bar";
-
- desiredError = "invalid tag";
- }
-
- void ComplexDoc(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << "receipt";
- out << YAML::Value << "Oz-Ware Purchase Invoice";
- out << YAML::Key << "date";
- out << YAML::Value << "2007-08-06";
- out << YAML::Key << "customer";
- out << YAML::Value;
- out << YAML::BeginMap;
- out << YAML::Key << "given";
- out << YAML::Value << "Dorothy";
- out << YAML::Key << "family";
- out << YAML::Value << "Gale";
- out << YAML::EndMap;
- out << YAML::Key << "items";
- out << YAML::Value;
- out << YAML::BeginSeq;
- out << YAML::BeginMap;
- out << YAML::Key << "part_no";
- out << YAML::Value << "A4786";
- out << YAML::Key << "descrip";
- out << YAML::Value << "Water Bucket (Filled)";
- out << YAML::Key << "price";
- out << YAML::Value << 1.47;
- out << YAML::Key << "quantity";
- out << YAML::Value << 4;
- out << YAML::EndMap;
- out << YAML::BeginMap;
- out << YAML::Key << "part_no";
- out << YAML::Value << "E1628";
- out << YAML::Key << "descrip";
- out << YAML::Value << "High Heeled \"Ruby\" Slippers";
- out << YAML::Key << "price";
- out << YAML::Value << 100.27;
- out << YAML::Key << "quantity";
- out << YAML::Value << 1;
- out << YAML::EndMap;
- out << YAML::EndSeq;
- out << YAML::Key << "bill-to";
- out << YAML::Value << YAML::Anchor("id001");
- out << YAML::BeginMap;
- out << YAML::Key << "street";
- out << YAML::Value << YAML::Literal << "123 Tornado Alley\nSuite 16";
- out << YAML::Key << "city";
- out << YAML::Value << "East Westville";
- out << YAML::Key << "state";
- out << YAML::Value << "KS";
- out << YAML::EndMap;
- out << YAML::Key << "ship-to";
- out << YAML::Value << YAML::Alias("id001");
- out << YAML::EndMap;
-
- desiredOutput = "receipt: Oz-Ware Purchase Invoice\ndate: 2007-08-06\ncustomer:\n given: Dorothy\n family: Gale\nitems:\n - part_no: A4786\n descrip: Water Bucket (Filled)\n price: 1.47\n quantity: 4\n - part_no: E1628\n descrip: High Heeled \"Ruby\" Slippers\n price: 100.27\n quantity: 1\nbill-to: &id001\n street: |\n 123 Tornado Alley\n Suite 16\n city: East Westville\n state: KS\nship-to: *id001";
- }
-
- void STLContainers(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- std::vector <int> primes;
- primes.push_back(2);
- primes.push_back(3);
- primes.push_back(5);
- primes.push_back(7);
- primes.push_back(11);
- primes.push_back(13);
- out << YAML::Flow << primes;
- std::map <std::string, int> ages;
- ages["Daniel"] = 26;
- ages["Jesse"] = 24;
- out << ages;
- out << YAML::EndSeq;
-
- desiredOutput = "- [2, 3, 5, 7, 11, 13]\n- Daniel: 26\n Jesse: 24";
- }
-
- void SimpleComment(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << "method";
- out << YAML::Value << "least squares" << YAML::Comment("should we change this method?");
- out << YAML::EndMap;
-
- desiredOutput = "method: least squares # should we change this method?";
- }
-
- void MultiLineComment(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << "item 1" << YAML::Comment("really really long\ncomment that couldn't possibly\nfit on one line");
- out << "item 2";
- out << YAML::EndSeq;
-
- desiredOutput = "- item 1 # really really long\n # comment that couldn't possibly\n # fit on one line\n- item 2";
- }
-
- void ComplexComments(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::LongKey << YAML::Key << "long key" << YAML::Comment("long key");
- out << YAML::Value << "value";
- out << YAML::EndMap;
-
- desiredOutput = "? long key # long key\n: value";
- }
-
- void InitialComment(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Comment("A comment describing the purpose of the file.");
- out << YAML::BeginMap << YAML::Key << "key" << YAML::Value << "value" << YAML::EndMap;
-
- desiredOutput = "# A comment describing the purpose of the file.\nkey: value";
- }
-
- void InitialCommentWithDocIndicator(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginDoc << YAML::Comment("A comment describing the purpose of the file.");
- out << YAML::BeginMap << YAML::Key << "key" << YAML::Value << "value" << YAML::EndMap;
-
- desiredOutput = "---\n# A comment describing the purpose of the file.\nkey: value";
- }
-
- void CommentInFlowSeq(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginSeq << "foo" << YAML::Comment("foo!") << "bar" << YAML::EndSeq;
-
- desiredOutput = "[foo # foo!\n, bar]";
- }
-
- void CommentInFlowMap(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginMap;
- out << YAML::Key << "foo" << YAML::Value << "foo value";
- out << YAML::Key << "bar" << YAML::Value << "bar value" << YAML::Comment("bar!");
- out << YAML::Key << "baz" << YAML::Value << "baz value" << YAML::Comment("baz!");
- out << YAML::EndMap;
-
- desiredOutput = "{foo: foo value, bar: bar value # bar!\n, baz: baz value # baz!\n}";
- }
-
- void Indentation(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Indent(4);
- out << YAML::BeginSeq;
- out << YAML::BeginMap;
- out << YAML::Key << "key 1" << YAML::Value << "value 1";
- out << YAML::Key << "key 2" << YAML::Value << YAML::BeginSeq << "a" << "b" << "c" << YAML::EndSeq;
- out << YAML::EndMap;
- out << YAML::EndSeq;
-
- desiredOutput = "- key 1: value 1\n key 2:\n - a\n - b\n - c";
- }
-
- void SimpleGlobalSettings(YAML::Emitter& out, std::string& desiredOutput)
- {
- out.SetIndent(4);
- out.SetMapFormat(YAML::LongKey);
-
- out << YAML::BeginSeq;
- out << YAML::BeginMap;
- out << YAML::Key << "key 1" << YAML::Value << "value 1";
- out << YAML::Key << "key 2" << YAML::Value << YAML::Flow << YAML::BeginSeq << "a" << "b" << "c" << YAML::EndSeq;
- out << YAML::EndMap;
- out << YAML::EndSeq;
-
- desiredOutput = "- ? key 1\n : value 1\n ? key 2\n : [a, b, c]";
- }
-
- void ComplexGlobalSettings(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::Block;
- out << YAML::BeginMap;
- out << YAML::Key << "key 1" << YAML::Value << "value 1";
- out << YAML::Key << "key 2" << YAML::Value;
- out.SetSeqFormat(YAML::Flow);
- out << YAML::BeginSeq << "a" << "b" << "c" << YAML::EndSeq;
- out << YAML::EndMap;
- out << YAML::BeginMap;
- out << YAML::Key << YAML::BeginSeq << 1 << 2 << YAML::EndSeq;
- out << YAML::Value << YAML::BeginMap << YAML::Key << "a" << YAML::Value << "b" << YAML::EndMap;
- out << YAML::EndMap;
- out << YAML::EndSeq;
-
- desiredOutput = "- key 1: value 1\n key 2: [a, b, c]\n- ? [1, 2]\n :\n a: b";
- }
-
- void Null(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::Null;
- out << YAML::BeginMap;
- out << YAML::Key << "null value" << YAML::Value << YAML::Null;
- out << YAML::Key << YAML::Null << YAML::Value << "null key";
- out << YAML::EndMap;
- out << YAML::EndSeq;
-
- desiredOutput = "- ~\n- null value: ~\n ~: null key";
- }
-
- void EscapedUnicode(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::EscapeNonAscii << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
-
- desiredOutput = "\"$ \\xa2 \\u20ac \\U00024b62\"";
- }
-
- void Unicode(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
- desiredOutput = "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
- }
-
- void DoubleQuotedUnicode(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::DoubleQuoted << "\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2";
- desiredOutput = "\"\x24 \xC2\xA2 \xE2\x82\xAC \xF0\xA4\xAD\xA2\"";
- }
-
- struct Foo {
- Foo(): x(0) {}
- Foo(int x_, const std::string& bar_): x(x_), bar(bar_) {}
-
- int x;
- std::string bar;
- };
-
- YAML::Emitter& operator << (YAML::Emitter& out, const Foo& foo) {
- out << YAML::BeginMap;
- out << YAML::Key << "x" << YAML::Value << foo.x;
- out << YAML::Key << "bar" << YAML::Value << foo.bar;
- out << YAML::EndMap;
- return out;
- }
-
- void UserType(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << Foo(5, "hello");
- out << Foo(3, "goodbye");
- out << YAML::EndSeq;
-
- desiredOutput = "- x: 5\n bar: hello\n- x: 3\n bar: goodbye";
- }
-
- void UserTypeInContainer(YAML::Emitter& out, std::string& desiredOutput)
- {
- std::vector<Foo> fv;
- fv.push_back(Foo(5, "hello"));
- fv.push_back(Foo(3, "goodbye"));
- out << fv;
-
- desiredOutput = "- x: 5\n bar: hello\n- x: 3\n bar: goodbye";
- }
-
- template <typename T>
- YAML::Emitter& operator << (YAML::Emitter& out, const T *v) {
- if(v)
- out << *v;
- else
- out << YAML::Null;
- return out;
- }
-
- void PointerToInt(YAML::Emitter& out, std::string& desiredOutput)
- {
- int foo = 5;
- int *bar = &foo;
- int *baz = 0;
- out << YAML::BeginSeq;
- out << bar << baz;
- out << YAML::EndSeq;
-
- desiredOutput = "- 5\n- ~";
- }
-
- void PointerToUserType(YAML::Emitter& out, std::string& desiredOutput)
- {
- Foo foo(5, "hello");
- Foo *bar = &foo;
- Foo *baz = 0;
- out << YAML::BeginSeq;
- out << bar << baz;
- out << YAML::EndSeq;
-
- desiredOutput = "- x: 5\n bar: hello\n- ~";
- }
-
- void NewlineAtEnd(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << "Hello" << YAML::Newline << YAML::Newline;
- desiredOutput = "Hello\n\n";
- }
-
- void NewlineInBlockSequence(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << "a" << YAML::Newline << "b" << "c" << YAML::Newline << "d";
- out << YAML::EndSeq;
- desiredOutput = "- a\n\n- b\n- c\n\n- d";
- }
-
- void NewlineInFlowSequence(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginSeq;
- out << "a" << YAML::Newline << "b" << "c" << YAML::Newline << "d";
- out << YAML::EndSeq;
- desiredOutput = "[a\n, b, c\n, d]";
- }
-
- void NewlineInBlockMap(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << "a" << YAML::Value << "foo" << YAML::Newline;
- out << YAML::Key << "b" << YAML::Newline << YAML::Value << "bar";
- out << YAML::LongKey << YAML::Key << "c" << YAML::Newline << YAML::Value << "car";
- out << YAML::EndMap;
- desiredOutput = "a: foo\n\nb: bar\n? c\n\n: car";
- }
-
- void NewlineInFlowMap(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginMap;
- out << YAML::Key << "a" << YAML::Value << "foo" << YAML::Newline;
- out << YAML::Key << "b" << YAML::Value << "bar";
- out << YAML::EndMap;
- desiredOutput = "{a: foo\n, b: bar}";
- }
-
- void LotsOfNewlines(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << "a" << YAML::Newline;
- out << YAML::BeginSeq;
- out << "b" << "c" << YAML::Newline;
- out << YAML::EndSeq;
- out << YAML::Newline;
- out << YAML::BeginMap;
- out << YAML::Newline << YAML::Key << "d" << YAML::Value << YAML::Newline << "e";
- out << YAML::LongKey << YAML::Key << "f" << YAML::Newline << YAML::Value << "foo";
- out << YAML::EndMap;
- out << YAML::EndSeq;
- desiredOutput = "- a\n\n-\n - b\n - c\n\n\n-\n d: e\n ? f\n\n : foo";
- }
-
- void Binary(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Binary(reinterpret_cast<const unsigned char*>("Hello, World!"), 13);
- desiredOutput = "!!binary \"SGVsbG8sIFdvcmxkIQ==\"";
- }
-
- void LongBinary(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Binary(reinterpret_cast<const unsigned char*>("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n"), 270);
- desiredOutput = "!!binary \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\"";
- }
-
- void EmptyBinary(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Binary(reinterpret_cast<const unsigned char *>(""), 0);
- desiredOutput = "!!binary \"\"";
- }
-
- void ColonAtEndOfScalar(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << "a:";
- desiredOutput = "\"a:\"";
- }
-
- void ColonAsScalar(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << "apple" << YAML::Value << ":";
- out << YAML::Key << "banana" << YAML::Value << ":";
- out << YAML::EndMap;
- desiredOutput = "apple: \":\"\nbanana: \":\"";
- }
-
- void ColonAtEndOfScalarInFlow(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginMap << YAML::Key << "C:" << YAML::Value << "C:" << YAML::EndMap;
- desiredOutput = "{\"C:\": \"C:\"}";
- }
-
- void BoolFormatting(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::TrueFalseBool << YAML::UpperCase << true;
- out << YAML::TrueFalseBool << YAML::CamelCase << true;
- out << YAML::TrueFalseBool << YAML::LowerCase << true;
- out << YAML::TrueFalseBool << YAML::UpperCase << false;
- out << YAML::TrueFalseBool << YAML::CamelCase << false;
- out << YAML::TrueFalseBool << YAML::LowerCase << false;
- out << YAML::YesNoBool << YAML::UpperCase << true;
- out << YAML::YesNoBool << YAML::CamelCase << true;
- out << YAML::YesNoBool << YAML::LowerCase << true;
- out << YAML::YesNoBool << YAML::UpperCase << false;
- out << YAML::YesNoBool << YAML::CamelCase << false;
- out << YAML::YesNoBool << YAML::LowerCase << false;
- out << YAML::OnOffBool << YAML::UpperCase << true;
- out << YAML::OnOffBool << YAML::CamelCase << true;
- out << YAML::OnOffBool << YAML::LowerCase << true;
- out << YAML::OnOffBool << YAML::UpperCase << false;
- out << YAML::OnOffBool << YAML::CamelCase << false;
- out << YAML::OnOffBool << YAML::LowerCase << false;
- out << YAML::ShortBool << YAML::UpperCase << true;
- out << YAML::ShortBool << YAML::CamelCase << true;
- out << YAML::ShortBool << YAML::LowerCase << true;
- out << YAML::ShortBool << YAML::UpperCase << false;
- out << YAML::ShortBool << YAML::CamelCase << false;
- out << YAML::ShortBool << YAML::LowerCase << false;
- out << YAML::EndSeq;
- desiredOutput =
- "- TRUE\n- True\n- true\n- FALSE\n- False\n- false\n"
- "- YES\n- Yes\n- yes\n- NO\n- No\n- no\n"
- "- ON\n- On\n- on\n- OFF\n- Off\n- off\n"
- "- Y\n- Y\n- y\n- N\n- N\n- n";
- }
-
- void DocStartAndEnd(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginDoc;
- out << YAML::BeginSeq << 1 << 2 << 3 << YAML::EndSeq;
- out << YAML::BeginDoc;
- out << "Hi there!";
- out << YAML::EndDoc;
- out << YAML::EndDoc;
- out << YAML::EndDoc;
- out << YAML::BeginDoc;
- out << YAML::VerbatimTag("foo") << "bar";
- desiredOutput = "---\n- 1\n- 2\n- 3\n---\nHi there!\n...\n...\n...\n---\n!<foo> bar";
- }
-
- void ImplicitDocStart(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << "Hi";
- out << "Bye";
- out << "Oops";
- desiredOutput = "Hi\n---\nBye\n---\nOops";
- }
-
- void EmptyString(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << "key" << YAML::Value << "";
- out << YAML::EndMap;
- desiredOutput = "key: \"\"";
- }
-
- void SingleChar(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << 'a';
- out << ':';
- out << (char)0x10;
- out << '\n';
- out << ' ';
- out << '\t';
- out << YAML::EndSeq;
- desiredOutput = "- a\n- \":\"\n- \"\\x10\"\n- \"\\n\"\n- \" \"\n- \"\\t\"";
- }
-
- void DefaultPrecision(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << 1.234f;
- out << 3.14159265358979;
- out << YAML::EndSeq;
- desiredOutput = "- 1.234\n- 3.14159265358979";
- }
-
- void SetPrecision(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginSeq;
- out << YAML::FloatPrecision(3) << 1.234f;
- out << YAML::DoublePrecision(6) << 3.14159265358979;
- out << YAML::EndSeq;
- desiredOutput = "- 1.23\n- 3.14159";
- }
-
- void DashInBlockContext(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::BeginMap;
- out << YAML::Key << "key" << YAML::Value << "-";
- out << YAML::EndMap;
- desiredOutput = "key: \"-\"";
- }
-
- void HexAndOct(YAML::Emitter& out, std::string& desiredOutput)
- {
- out << YAML::Flow << YAML::BeginSeq;
- out << 31;
- out << YAML::Hex << 31;
- out << YAML::Oct << 31;
- out << YAML::EndSeq;
- desiredOutput = "[31, 0x1f, 037]";
- }
-
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- // incorrect emitting
-
- void ExtraEndSeq(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::UNEXPECTED_END_SEQ;
-
- out << YAML::BeginSeq;
- out << "Hello";
- out << "World";
- out << YAML::EndSeq;
- out << YAML::EndSeq;
- }
-
- void ExtraEndMap(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::UNEXPECTED_END_MAP;
-
- out << YAML::BeginMap;
- out << YAML::Key << "Hello" << YAML::Value << "World";
- out << YAML::EndMap;
- out << YAML::EndMap;
- }
-
- void BadSingleQuoted(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::SINGLE_QUOTED_CHAR;
-
- out << YAML::SingleQuoted << "Hello\nWorld";
- }
-
- void InvalidAnchor(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::INVALID_ANCHOR;
-
- out << YAML::BeginSeq;
- out << YAML::Anchor("new\nline") << "Test";
- out << YAML::EndSeq;
- }
-
- void InvalidAlias(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::INVALID_ALIAS;
-
- out << YAML::BeginSeq;
- out << YAML::Alias("new\nline");
- out << YAML::EndSeq;
- }
-
- void MissingKey(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::EXPECTED_KEY_TOKEN;
-
- out << YAML::BeginMap;
- out << YAML::Key << "key" << YAML::Value << "value";
- out << "missing key" << YAML::Value << "value";
- out << YAML::EndMap;
- }
-
- void MissingValue(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::EXPECTED_VALUE_TOKEN;
-
- out << YAML::BeginMap;
- out << YAML::Key << "key" << "value";
- out << YAML::EndMap;
- }
-
- void UnexpectedKey(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::UNEXPECTED_KEY_TOKEN;
-
- out << YAML::BeginSeq;
- out << YAML::Key << "hi";
- out << YAML::EndSeq;
- }
-
- void UnexpectedValue(YAML::Emitter& out, std::string& desiredError)
- {
- desiredError = YAML::ErrorMsg::UNEXPECTED_VALUE_TOKEN;
-
- out << YAML::BeginSeq;
- out << YAML::Value << "hi";
- out << YAML::EndSeq;
- }
- }
-
- namespace {
- void RunEmitterTest(void (*test)(YAML::Emitter&, std::string&), const std::string& name, int& passed, int& total) {
- YAML::Emitter out;
- std::string desiredOutput;
- test(out, desiredOutput);
- std::string output = out.c_str();
- std::string lastError = out.GetLastError();
-
- if(output == desiredOutput) {
- try {
- std::stringstream stream(output);
- YAML::Parser parser;
- YAML::Node node;
- parser.GetNextDocument(node);
- passed++;
- } catch(const YAML::Exception& e) {
- std::cout << "Emitter test failed: " << name << "\n";
- std::cout << "Parsing output error: " << e.what() << "\n";
- }
- } else {
- std::cout << "Emitter test failed: " << name << "\n";
- std::cout << "Output:\n";
- std::cout << output << "<<<\n";
- std::cout << "Desired output:\n";
- std::cout << desiredOutput << "<<<\n";
- if(!out.good())
- std::cout << "Emitter error: " << lastError << "\n";
- }
- total++;
- }
-
- void RunEmitterErrorTest(void (*test)(YAML::Emitter&, std::string&), const std::string& name, int& passed, int& total) {
- YAML::Emitter out;
- std::string desiredError;
- test(out, desiredError);
- std::string lastError = out.GetLastError();
- if(!out.good() && lastError == desiredError) {
- passed++;
- } else {
- std::cout << "Emitter test failed: " << name << "\n";
- if(out.good())
- std::cout << "No error detected\n";
- else
- std::cout << "Detected error: " << lastError << "\n";
- std::cout << "Expected error: " << desiredError << "\n";
- }
- total++;
- }
- }
-
- bool RunEmitterTests()
- {
- int passed = 0;
- int total = 0;
- RunEmitterTest(&Emitter::SimpleScalar, "simple scalar", passed, total);
- RunEmitterTest(&Emitter::SimpleSeq, "simple seq", passed, total);
- RunEmitterTest(&Emitter::SimpleFlowSeq, "simple flow seq", passed, total);
- RunEmitterTest(&Emitter::EmptyFlowSeq, "empty flow seq", passed, total);
- RunEmitterTest(&Emitter::NestedBlockSeq, "nested block seq", passed, total);
- RunEmitterTest(&Emitter::NestedFlowSeq, "nested flow seq", passed, total);
- RunEmitterTest(&Emitter::SimpleMap, "simple map", passed, total);
- RunEmitterTest(&Emitter::SimpleFlowMap, "simple flow map", passed, total);
- RunEmitterTest(&Emitter::MapAndList, "map and list", passed, total);
- RunEmitterTest(&Emitter::ListAndMap, "list and map", passed, total);
- RunEmitterTest(&Emitter::NestedBlockMap, "nested block map", passed, total);
- RunEmitterTest(&Emitter::NestedFlowMap, "nested flow map", passed, total);
- RunEmitterTest(&Emitter::MapListMix, "map list mix", passed, total);
- RunEmitterTest(&Emitter::SimpleLongKey, "simple long key", passed, total);
- RunEmitterTest(&Emitter::SingleLongKey, "single long key", passed, total);
- RunEmitterTest(&Emitter::ComplexLongKey, "complex long key", passed, total);
- RunEmitterTest(&Emitter::AutoLongKey, "auto long key", passed, total);
- RunEmitterTest(&Emitter::ScalarFormat, "scalar format", passed, total);
- RunEmitterTest(&Emitter::AutoLongKeyScalar, "auto long key scalar", passed, total);
- RunEmitterTest(&Emitter::LongKeyFlowMap, "long key flow map", passed, total);
- RunEmitterTest(&Emitter::BlockMapAsKey, "block map as key", passed, total);
- RunEmitterTest(&Emitter::AliasAndAnchor, "alias and anchor", passed, total);
- RunEmitterTest(&Emitter::AliasAndAnchorWithNull, "alias and anchor with null", passed, total);
- RunEmitterTest(&Emitter::AliasAndAnchorInFlow, "alias and anchor in flow", passed, total);
- RunEmitterTest(&Emitter::SimpleVerbatimTag, "simple verbatim tag", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagInBlockSeq, "verbatim tag in block seq", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagInFlowSeq, "verbatim tag in flow seq", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagInFlowSeqWithNull, "verbatim tag in flow seq with null", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagInBlockMap, "verbatim tag in block map", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagInFlowMap, "verbatim tag in flow map", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagInFlowMapWithNull, "verbatim tag in flow map with null", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagWithEmptySeq, "verbatim tag with empty seq", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagWithEmptyMap, "verbatim tag with empty map", passed, total);
- RunEmitterTest(&Emitter::VerbatimTagWithEmptySeqAndMap, "verbatim tag with empty seq and map", passed, total);
- RunEmitterTest(&Emitter::ByKindTagWithScalar, "by-kind tag with scalar", passed, total);
- RunEmitterTest(&Emitter::LocalTagWithScalar, "local tag with scalar", passed, total);
- RunEmitterTest(&Emitter::ComplexDoc, "complex doc", passed, total);
- RunEmitterTest(&Emitter::STLContainers, "STL containers", passed, total);
- RunEmitterTest(&Emitter::SimpleComment, "simple comment", passed, total);
- RunEmitterTest(&Emitter::MultiLineComment, "multi-line comment", passed, total);
- RunEmitterTest(&Emitter::ComplexComments, "complex comments", passed, total);
- RunEmitterTest(&Emitter::InitialComment, "initial comment", passed, total);
- RunEmitterTest(&Emitter::InitialCommentWithDocIndicator, "initial comment with doc indicator", passed, total);
- RunEmitterTest(&Emitter::CommentInFlowSeq, "comment in flow seq", passed, total);
- RunEmitterTest(&Emitter::CommentInFlowMap, "comment in flow map", passed, total);
- RunEmitterTest(&Emitter::Indentation, "indentation", passed, total);
- RunEmitterTest(&Emitter::SimpleGlobalSettings, "simple global settings", passed, total);
- RunEmitterTest(&Emitter::ComplexGlobalSettings, "complex global settings", passed, total);
- RunEmitterTest(&Emitter::Null, "null", passed, total);
- RunEmitterTest(&Emitter::EscapedUnicode, "escaped unicode", passed, total);
- RunEmitterTest(&Emitter::Unicode, "unicode", passed, total);
- RunEmitterTest(&Emitter::DoubleQuotedUnicode, "double quoted unicode", passed, total);
- RunEmitterTest(&Emitter::UserType, "user type", passed, total);
- RunEmitterTest(&Emitter::UserTypeInContainer, "user type in container", passed, total);
- RunEmitterTest(&Emitter::PointerToInt, "pointer to int", passed, total);
- RunEmitterTest(&Emitter::PointerToUserType, "pointer to user type", passed, total);
- RunEmitterTest(&Emitter::NewlineAtEnd, "newline at end", passed, total);
- RunEmitterTest(&Emitter::NewlineInBlockSequence, "newline in block sequence", passed, total);
- RunEmitterTest(&Emitter::NewlineInFlowSequence, "newline in flow sequence", passed, total);
- RunEmitterTest(&Emitter::NewlineInBlockMap, "newline in block map", passed, total);
- RunEmitterTest(&Emitter::NewlineInFlowMap, "newline in flow map", passed, total);
- RunEmitterTest(&Emitter::LotsOfNewlines, "lots of newlines", passed, total);
- RunEmitterTest(&Emitter::Binary, "binary", passed, total);
- RunEmitterTest(&Emitter::LongBinary, "long binary", passed, total);
- RunEmitterTest(&Emitter::EmptyBinary, "empty binary", passed, total);
- RunEmitterTest(&Emitter::ColonAtEndOfScalar, "colon at end of scalar", passed, total);
- RunEmitterTest(&Emitter::ColonAsScalar, "colon as scalar", passed, total);
- RunEmitterTest(&Emitter::ColonAtEndOfScalarInFlow, "colon at end of scalar in flow", passed, total);
- RunEmitterTest(&Emitter::BoolFormatting, "bool formatting", passed, total);
- RunEmitterTest(&Emitter::DocStartAndEnd, "doc start and end", passed, total);
- RunEmitterTest(&Emitter::ImplicitDocStart, "implicit doc start", passed, total);
- RunEmitterTest(&Emitter::EmptyString, "empty string", passed, total);
- RunEmitterTest(&Emitter::SingleChar, "single char", passed, total);
- RunEmitterTest(&Emitter::DefaultPrecision, "default precision", passed, total);
- RunEmitterTest(&Emitter::SetPrecision, "set precision", passed, total);
- RunEmitterTest(&Emitter::DashInBlockContext, "dash in block context", passed, total);
- RunEmitterTest(&Emitter::HexAndOct, "hex and oct", passed, total);
-
- RunEmitterErrorTest(&Emitter::ExtraEndSeq, "extra EndSeq", passed, total);
- RunEmitterErrorTest(&Emitter::ExtraEndMap, "extra EndMap", passed, total);
- RunEmitterErrorTest(&Emitter::BadSingleQuoted, "bad single quoted string", passed, total);
- RunEmitterErrorTest(&Emitter::InvalidAnchor, "invalid anchor", passed, total);
- RunEmitterErrorTest(&Emitter::InvalidAlias, "invalid alias", passed, total);
- RunEmitterErrorTest(&Emitter::MissingKey, "missing key", passed, total);
- RunEmitterErrorTest(&Emitter::MissingValue, "missing value", passed, total);
- RunEmitterErrorTest(&Emitter::UnexpectedKey, "unexpected key", passed, total);
- RunEmitterErrorTest(&Emitter::UnexpectedValue, "unexpected value", passed, total);
- RunEmitterErrorTest(&Emitter::BadLocalTag, "bad local tag", passed, total);
-
- std::cout << "Emitter tests: " << passed << "/" << total << " passed\n";
- return passed == total;
- }
-}
-
diff --git a/yaml-cpp/test/emittertests.h b/yaml-cpp/test/emittertests.h
deleted file mode 100755
index e7c6ac50..00000000
--- a/yaml-cpp/test/emittertests.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-#define EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
-#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
-#pragma once
-#endif
-
-namespace Test {
- bool RunEmitterTests();
-}
-
-#endif // EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
diff --git a/yaml-cpp/test/main.cpp b/yaml-cpp/test/main.cpp
deleted file mode 100755
index 64c69f10..00000000
--- a/yaml-cpp/test/main.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "tests.h"
-
-int main()
-{
- Test::RunAll();
- return 0;
-}
diff --git a/yaml-cpp/test/nodetests.h b/yaml-cpp/test/nodetests.h
deleted file mode 100755
index 733e782e..00000000
--- a/yaml-cpp/test/nodetests.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-#define NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
-#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
-#pragma once
-#endif
-
-namespace Test {
- bool RunNodeTests();
-}
-
-#endif // NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A6666
-
diff --git a/yaml-cpp/test/old-api/parsertests.cpp b/yaml-cpp/test/old-api/parsertests.cpp
deleted file mode 100755
index de7f1238..00000000
--- a/yaml-cpp/test/old-api/parsertests.cpp
+++ /dev/null
@@ -1,1237 +0,0 @@
-#include "tests.h"
-#include "yaml-cpp/yaml.h"
-#include <sstream>
-#include <algorithm>
-#include <iostream>
-
-namespace Test
-{
- namespace Parser {
- void SimpleScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar = "Hello, World!";
- desiredOutput = "Hello, World!";
- }
-
- void MultiLineScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar =
- "normal scalar, but\n"
- "over several lines";
- desiredOutput = "normal scalar, but over several lines";
- }
-
- void LiteralScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar =
- "|\n"
- " literal scalar - so we can draw ASCII:\n"
- " \n"
- " - -\n"
- " | - |\n"
- " -----\n";
- desiredOutput =
- "literal scalar - so we can draw ASCII:\n"
- "\n"
- " - -\n"
- " | - |\n"
- " -----\n";
- }
-
- void FoldedScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar =
- ">\n"
- " and a folded scalar... so we\n"
- " can just keep writing various\n"
- " things. And if we want to keep indentation:\n"
- " \n"
- " we just indent a little\n"
- " see, this stays indented";
- desiredOutput =
- "and a folded scalar... so we"
- " can just keep writing various"
- " things. And if we want to keep indentation:\n"
- "\n"
- " we just indent a little\n"
- " see, this stays indented";
- }
-
- void ChompedFoldedScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar =
- ">-\n"
- " Here's a folded scalar\n"
- " that gets chomped.";
- desiredOutput =
- "Here's a folded scalar"
- " that gets chomped.";
- }
-
- void ChompedLiteralScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar =
- "|-\n"
- " Here's a literal scalar\n"
- " that gets chomped.";
- desiredOutput =
- "Here's a literal scalar\n"
- "that gets chomped.";
- }
-
- void FoldedScalarWithIndent(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar =
- ">2\n"
- " Here's a folded scalar\n"
- " that starts with some indentation.";
- desiredOutput =
- " Here's a folded scalar\n"
- "that starts with some indentation.";
- }
-
- void ColonScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar = "::vector";
- desiredOutput = "::vector";
- }
-
- void QuotedScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar = "\": - ()\"";
- desiredOutput = ": - ()";
- }
-
- void CommaScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar = "Up, up, and away!";
- desiredOutput = "Up, up, and away!";
- }
-
- void DashScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar = "-123";
- desiredOutput = "-123";
- }
-
- void URLScalar(std::string& inputScalar, std::string& desiredOutput)
- {
- inputScalar = "http://example.com/foo#bar";
- desiredOutput = "http://example.com/foo#bar";
- }
-
- bool SimpleSeq()
- {
- std::string input =
- "- eggs\n"
- "- bread\n"
- "- milk";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- if(doc[0].to<std::string>() != "eggs")
- return false;
- if(doc[1].to<std::string>() != "bread")
- return false;
- if(doc[2].to<std::string>() != "milk")
- return false;
-
- return true;
- }
-
- bool SimpleMap()
- {
- std::string input =
- "name: Prince Fielder\n"
- "position: 1B\n"
- "bats: L";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc["name"] >> output;
- if(output != "Prince Fielder")
- return false;
- doc["position"] >> output;
- if(output != "1B")
- return false;
- doc["bats"] >> output;
- if(output != "L")
- return false;
-
- return true;
- }
-
- bool FlowSeq()
- {
- std::string input = "[ 2 , 3, 5 , 7, 11]";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- int output;
- doc[0] >> output;
- if(output != 2)
- return false;
- doc[1] >> output;
- if(output != 3)
- return false;
- doc[2] >> output;
- if(output != 5)
- return false;
- doc[3] >> output;
- if(output != 7)
- return false;
- doc[4] >> output;
- if(output != 11)
- return false;
-
- return true;
- }
-
- bool FlowMap()
- {
- std::string input = "{hr: 65, avg: 0.278}";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc["hr"] >> output;
- if(output != "65")
- return false;
- doc["avg"] >> output;
- if(output != "0.278")
- return false;
-
- return true;
- }
-
- bool FlowMapWithOmittedKey()
- {
- std::string input = "{: omitted key}";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc[YAML::Null] >> output;
- if(output != "omitted key")
- return false;
-
- return true;
- }
-
- bool FlowMapWithOmittedValue()
- {
- std::string input = "{a: b, c:, d:}";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc["a"] >> output;
- if(output != "b")
- return false;
- if(!IsNull(doc["c"]))
- return false;
- if(!IsNull(doc["d"]))
- return false;
-
- return true;
- }
-
- bool FlowMapWithSoloEntry()
- {
- std::string input = "{a: b, c, d: e}";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc["a"] >> output;
- if(output != "b")
- return false;
- if(!IsNull(doc["c"]))
- return false;
- doc["d"] >> output;
- if(output != "e")
- return false;
-
- return true;
- }
-
- bool FlowMapEndingWithSoloEntry()
- {
- std::string input = "{a: b, c}";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc["a"] >> output;
- if(output != "b")
- return false;
- if(!IsNull(doc["c"]))
- return false;
-
- return true;
- }
-
- bool QuotedSimpleKeys()
- {
- std::string KeyValue[3] = { "\"double\": double\n", "'single': single\n", "plain: plain\n" };
-
- int perm[3] = { 0, 1, 2 };
- do {
- std::string input = KeyValue[perm[0]] + KeyValue[perm[1]] + KeyValue[perm[2]];
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc["double"] >> output;
- if(output != "double")
- return false;
- doc["single"] >> output;
- if(output != "single")
- return false;
- doc["plain"] >> output;
- if(output != "plain")
- return false;
- } while(std::next_permutation(perm, perm + 3));
-
- return true;
- }
-
- bool CompressedMapAndSeq()
- {
- std::string input = "key:\n- one\n- two";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- const YAML::Node& seq = doc["key"];
- if(seq.size() != 2)
- return false;
-
- std::string output;
- seq[0] >> output;
- if(output != "one")
- return false;
- seq[1] >> output;
- if(output != "two")
- return false;
-
- return true;
- }
-
- bool NullBlockSeqEntry()
- {
- std::string input = "- hello\n-\n- world";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc[0] >> output;
- if(output != "hello")
- return false;
- if(!IsNull(doc[1]))
- return false;
- doc[2] >> output;
- if(output != "world")
- return false;
-
- return true;
- }
-
- bool NullBlockMapKey()
- {
- std::string input = ": empty key";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc[YAML::Null] >> output;
- if(output != "empty key")
- return false;
-
- return true;
- }
-
- bool NullBlockMapValue()
- {
- std::string input = "empty value:";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- if(!IsNull(doc["empty value"]))
- return false;
-
- return true;
- }
-
- bool SimpleAlias()
- {
- std::string input = "- &alias test\n- *alias";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc[0] >> output;
- if(output != "test")
- return false;
-
- doc[1] >> output;
- if(output != "test")
- return false;
-
- if(doc.size() != 2)
- return false;
-
- return true;
- }
-
- bool AliasWithNull()
- {
- std::string input = "- &alias\n- *alias";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- if(!IsNull(doc[0]))
- return false;
-
- if(!IsNull(doc[1]))
- return false;
-
- if(doc.size() != 2)
- return false;
-
- return true;
- }
-
- bool AnchorInSimpleKey()
- {
- std::string input = "- &a b: c\n- *a";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- if(doc.size() != 2)
- return false;
-
- std::string output;
- doc[0]["b"] >> output;
- if(output != "c")
- return false;
-
- doc[1] >> output;
- if(output != "b")
- return false;
-
- return true;
- }
-
- bool AliasAsSimpleKey()
- {
- std::string input = "- &a b\n- *a : c";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- if(doc.size() != 2)
- return false;
-
- std::string output;
- doc[0] >> output;
- if(output != "b")
- return false;
-
- doc[1]["b"] >> output;
- if(output != "c")
- return false;
-
- return true;
- }
-
- bool ExplicitDoc()
- {
- std::string input = "---\n- one\n- two";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- if(doc.size() != 2)
- return false;
-
- std::string output;
- doc[0] >> output;
- if(output != "one")
- return false;
- doc[1] >> output;
- if(output != "two")
- return false;
-
- return true;
- }
-
- bool MultipleDocs()
- {
- std::string input = "---\nname: doc1\n---\nname: doc2";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::string output;
- doc["name"] >> output;
- if(output != "doc1")
- return false;
-
- if(!parser)
- return false;
-
- parser.GetNextDocument(doc);
- doc["name"] >> output;
- if(output != "doc2")
- return false;
-
- return true;
- }
-
- bool ExplicitEndDoc()
- {
- std::string input = "- one\n- two\n...\n...";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- if(doc.size() != 2)
- return false;
-
- std::string output;
- doc[0] >> output;
- if(output != "one")
- return false;
- doc[1] >> output;
- if(output != "two")
- return false;
-
- return true;
- }
-
- bool MultipleDocsWithSomeExplicitIndicators()
- {
- std::string input =
- "- one\n- two\n...\n"
- "---\nkey: value\n...\n...\n"
- "- three\n- four\n"
- "---\nkey: value";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- std::string output;
-
- parser.GetNextDocument(doc);
- if(doc.size() != 2)
- return false;
- doc[0] >> output;
- if(output != "one")
- return false;
- doc[1] >> output;
- if(output != "two")
- return false;
-
- parser.GetNextDocument(doc);
- doc["key"] >> output;
- if(output != "value")
- return false;
-
- parser.GetNextDocument(doc);
- if(doc.size() != 2)
- return false;
- doc[0] >> output;
- if(output != "three")
- return false;
- doc[1] >> output;
- if(output != "four")
- return false;
-
- parser.GetNextDocument(doc);
- doc["key"] >> output;
- if(output != "value")
- return false;
-
- return true;
- }
-
- bool BlockKeyWithNullValue()
- {
- std::string input =
- "key:\n"
- "just a key: value";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
-
- parser.GetNextDocument(doc);
- if(doc.size() != 2)
- return false;
- if(!IsNull(doc["key"]))
- return false;
- if(doc["just a key"].to<std::string>() != "value")
- return false;
-
- return true;
- }
-
- bool Bases()
- {
- std::string input =
- "- 15\n"
- "- 0x10\n"
- "- 030\n"
- "- 0xffffffff\n";
-
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
-
- parser.GetNextDocument(doc);
- if(doc.size() != 4)
- return false;
- if(doc[0].to<int>() != 15)
- return false;
- if(doc[1].to<int>() != 0x10)
- return false;
- if(doc[2].to<int>() != 030)
- return false;
- if(doc[3].to<unsigned>() != 0xffffffff)
- return false;
- return true;
- }
-
- bool KeyNotFound()
- {
- std::string input = "key: value";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- try {
- doc["bad key"];
- } catch(const YAML::Exception& e) {
- if(e.msg != std::string(YAML::ErrorMsg::KEY_NOT_FOUND) + ": bad key")
- throw;
- }
-
- try {
- doc[5];
- } catch(const YAML::Exception& e) {
- if(e.msg != std::string(YAML::ErrorMsg::KEY_NOT_FOUND) + ": 5")
- throw;
- }
-
- try {
- doc[2.5];
- } catch(const YAML::Exception& e) {
- if(e.msg != std::string(YAML::ErrorMsg::KEY_NOT_FOUND) + ": 2.5")
- throw;
- }
-
- 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"].to<int>() != 4)
- return false;
- if(doc["b"].to<int>() != 2)
- return false;
- if(doc["c"].to<int>() != 3)
- return false;
- return true;
- }
-
- void PrepareNodeForTagExam(YAML::Node& doc, const std::string& input)
- {
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- parser.GetNextDocument(doc);
- }
-
- struct TagMismatch: public std::exception {
- TagMismatch(const std::string& actualTag, const std::string& expectedTag) {
- std::stringstream output;
- output << "Tag has value \"" << actualTag << "\" but \"" << expectedTag << "\" was expected";
- what_ = output.str();
- }
- virtual ~TagMismatch() throw() {}
- virtual const char *what() const throw() { return what_.c_str(); }
-
- private:
- std::string what_;
- };
-
- bool ExpectedTagValue(YAML::Node& node, const char* tag)
- {
- if(node.Tag() == tag)
- return true;
-
- throw TagMismatch(node.Tag(), tag);
- }
-
- bool DefaultPlainScalarTag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- 12");
-
- return ExpectedTagValue(node, "?");
- }
-
- bool DefaultSingleQuotedScalarTag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- '12'");
-
- return ExpectedTagValue(node, "!");
- }
-
- bool ExplicitNonSpecificPlainScalarTag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- ! 12");
-
- return ExpectedTagValue(node, "!");
- }
-
- bool BasicLocalTag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- !foo 12");
-
- return ExpectedTagValue(node, "!foo");
- }
-
- bool VerbatimLocalTag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- !<!foo> 12");
-
- return ExpectedTagValue(node, "!foo");
- }
-
- bool StandardShortcutTag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- !!int 12");
-
- return ExpectedTagValue(node, "tag:yaml.org,2002:int");
- }
-
- bool VerbatimURITag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- !<tag:yaml.org,2002:int> 12");
-
- return ExpectedTagValue(node, "tag:yaml.org,2002:int");
- }
-
- bool DefaultSequenceTag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- [12]");
-
- return ExpectedTagValue(node, "?");
- }
-
- bool ExplicitNonSpecificSequenceTag()
- {
- YAML::Node node;
- PrepareNodeForTagExam(node, "--- ! [12]");
-
- return ExpectedTagValue(node, "!");
- }
-
- bool Infinity()
- {
- std::string input =
- "- .inf\n"
- "- .Inf\n"
- "- .INF\n"
- "- +.inf\n"
- "- +.Inf\n"
- "- +.INF\n"
- "- -.inf\n"
- "- -.Inf\n"
- "- -.INF\n";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- for(unsigned i=0;i<doc.size();i++)
- if(doc[i].to<double>() != (i < 6 ? +1 : -1) * std::numeric_limits<double>::infinity())
- return false;
- for(unsigned i=0;i<doc.size();i++)
- if(doc[i].to<long double>() != (i < 6 ? +1 : -1) * std::numeric_limits<long double>::infinity())
- return false;
- for(unsigned i=0;i<doc.size();i++)
- if(doc[i].to<float>() != (i < 6 ? +1 : -1) * std::numeric_limits<float>::infinity())
- return false;
- return true;
- }
-
- bool NaN()
- {
- std::string input =
- "- .nan\n"
- "- .NaN\n"
- "- .NAN\n";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- for(unsigned i=0;i<doc.size();i++) {
- double d;
- doc[i] >> d;
- if(d == d)
- return false;
- }
- for(unsigned i=0;i<doc.size();i++) {
- long double d;
- doc[i] >> d;
- if(d == d)
- return false;
- }
- for(unsigned i=0;i<doc.size();i++) {
- float d;
- doc[i] >> d;
- if(d == d)
- return false;
- }
- return true;
- }
-
- bool NonConstKey()
- {
- std::string input = "{a: 1}";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- std::vector<char> key(2);
- key[0] = 'a';
- key[1] = '\0';
- if(doc[&key[0]].to<int>() != 1)
- return false;
- return true;
- }
-
- bool SingleChar()
- {
- std::string input = "5";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- return doc.to<int>() == 5;
- }
-
- bool QuotedNewline()
- {
- std::string input = "foo: \"\\n\"";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- return doc["foo"].to<std::string>() == "\n";
- }
-
- bool DoubleAsInt()
- {
- std::string input = "1.5";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- try {
- doc.to<int>();
- } catch(const YAML::InvalidScalar& e) {
- return true;
- }
-
- return false;
- }
-
- bool Binary()
- {
- std::string input = "[!!binary \"SGVsbG8sIFdvcmxkIQ==\", !!binary \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\"]";
- std::stringstream stream(input);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- if(doc[0].to<YAML::Binary>() != YAML::Binary(reinterpret_cast<const unsigned char*>("Hello, World!"), 13))
- return false;
- if(doc[1].to<YAML::Binary>() != YAML::Binary(reinterpret_cast<const unsigned char*>("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n"), 270))
- return false;
- return true;
- }
- }
-
- namespace {
- void RunScalarParserTest(void (*test)(std::string&, std::string&), const std::string& name, int& passed, int& total) {
- std::string error;
- std::string inputScalar, desiredOutput;
- std::string output;
- bool ok = true;
- try {
- test(inputScalar, desiredOutput);
- std::stringstream stream(inputScalar);
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
- doc >> output;
- } catch(const YAML::Exception& e) {
- ok = false;
- error = e.what();
- }
- if(ok && output == desiredOutput) {
- passed++;
- } else {
- std::cout << "Parser test failed: " << name << "\n";
- if(error != "")
- std::cout << "Caught exception: " << error << "\n";
- else {
- std::cout << "Output:\n" << output << "<<<\n";
- std::cout << "Desired output:\n" << desiredOutput << "<<<\n";
- }
- }
- total++;
- }
-
- void RunParserTest(bool (*test)(), const std::string& name, int& passed, int& total) {
- std::string error;
- bool ok = true;
- try {
- ok = test();
- } catch(const YAML::Exception& e) {
- ok = false;
- error = e.what();
- } catch(const Parser::TagMismatch& e) {
- ok = false;
- error = e.what();
- }
- if(ok) {
- passed++;
- } else {
- std::cout << "Parser test failed: " << name << "\n";
- if(error != "")
- std::cout << " Caught exception: " << error << "\n";
- }
- total++;
- }
-
- typedef void (*EncodingFn)(std::ostream&, int);
-
- inline char Byte(int ch)
- {
- return static_cast<char>(static_cast<unsigned char>(static_cast<unsigned int>(ch)));
- }
-
- void EncodeToUtf8(std::ostream& stream, int ch)
- {
- if (ch <= 0x7F)
- {
- stream << Byte(ch);
- }
- else if (ch <= 0x7FF)
- {
- stream << Byte(0xC0 | (ch >> 6));
- stream << Byte(0x80 | (ch & 0x3F));
- }
- else if (ch <= 0xFFFF)
- {
- stream << Byte(0xE0 | (ch >> 12));
- stream << Byte(0x80 | ((ch >> 6) & 0x3F));
- stream << Byte(0x80 | (ch & 0x3F));
- }
- else if (ch <= 0x1FFFFF)
- {
- stream << Byte(0xF0 | (ch >> 18));
- stream << Byte(0x80 | ((ch >> 12) & 0x3F));
- stream << Byte(0x80 | ((ch >> 6) & 0x3F));
- stream << Byte(0x80 | (ch & 0x3F));
- }
- }
-
- bool SplitUtf16HighChar(std::ostream& stream, EncodingFn encoding, int ch)
- {
- int biasedValue = ch - 0x10000;
- if (biasedValue < 0)
- {
- return false;
- }
- int high = 0xD800 | (biasedValue >> 10);
- int low = 0xDC00 | (biasedValue & 0x3FF);
- encoding(stream, high);
- encoding(stream, low);
- return true;
- }
-
- void EncodeToUtf16LE(std::ostream& stream, int ch)
- {
- if (!SplitUtf16HighChar(stream, &EncodeToUtf16LE, ch))
- {
- stream << Byte(ch & 0xFF) << Byte(ch >> 8);
- }
- }
-
- void EncodeToUtf16BE(std::ostream& stream, int ch)
- {
- if (!SplitUtf16HighChar(stream, &EncodeToUtf16BE, ch))
- {
- stream << Byte(ch >> 8) << Byte(ch & 0xFF);
- }
- }
-
- void EncodeToUtf32LE(std::ostream& stream, int ch)
- {
- stream << Byte(ch & 0xFF) << Byte((ch >> 8) & 0xFF)
- << Byte((ch >> 16) & 0xFF) << Byte((ch >> 24) & 0xFF);
- }
-
- void EncodeToUtf32BE(std::ostream& stream, int ch)
- {
- stream << Byte((ch >> 24) & 0xFF) << Byte((ch >> 16) & 0xFF)
- << Byte((ch >> 8) & 0xFF) << Byte(ch & 0xFF);
- }
-
- class EncodingTester
- {
- public:
- EncodingTester(EncodingFn encoding, bool declareEncoding)
- {
- if (declareEncoding)
- {
- encoding(m_yaml, 0xFEFF);
- }
-
- AddEntry(encoding, 0x0021, 0x007E); // Basic Latin
- AddEntry(encoding, 0x00A1, 0x00FF); // Latin-1 Supplement
- AddEntry(encoding, 0x0660, 0x06FF); // Arabic (largest contiguous block)
-
- // CJK unified ideographs (multiple lines)
- AddEntry(encoding, 0x4E00, 0x4EFF);
- AddEntry(encoding, 0x4F00, 0x4FFF);
- AddEntry(encoding, 0x5000, 0x51FF); // 512 character line
- AddEntry(encoding, 0x5200, 0x54FF); // 768 character line
- AddEntry(encoding, 0x5500, 0x58FF); // 1024 character line
-
- AddEntry(encoding, 0x103A0, 0x103C3); // Old Persian
-
- m_yaml.seekg(0, std::ios::beg);
- }
-
- std::istream& stream() {return m_yaml;}
- const std::vector<std::string>& entries() {return m_entries;}
-
- private:
- std::stringstream m_yaml;
- std::vector<std::string> m_entries;
-
- void AddEntry(EncodingFn encoding, int startCh, int endCh)
- {
- encoding(m_yaml, '-');
- encoding(m_yaml, ' ');
- encoding(m_yaml, '|');
- encoding(m_yaml, '\n');
- encoding(m_yaml, ' ');
- encoding(m_yaml, ' ');
-
- std::stringstream entry;
- for (int ch = startCh; ch <= endCh; ++ch)
- {
- encoding(m_yaml, ch);
- EncodeToUtf8(entry, ch);
- }
- encoding(m_yaml, '\n');
-
- m_entries.push_back(entry.str());
- }
- };
-
- void RunEncodingTest(EncodingFn encoding, bool declareEncoding, const std::string& name, int& passed, int& total)
- {
- EncodingTester tester(encoding, declareEncoding);
- std::string error;
- bool ok = true;
- try {
- YAML::Parser parser(tester.stream());
- YAML::Node doc;
- parser.GetNextDocument(doc);
-
- YAML::Iterator itNode = doc.begin();
- std::vector<std::string>::const_iterator itEntry = tester.entries().begin();
- for (; (itNode != doc.end()) && (itEntry != tester.entries().end()); ++itNode, ++itEntry)
- {
- std::string stScalarValue;
- if (!itNode->GetScalar(stScalarValue) && (stScalarValue == *itEntry))
- {
- break;
- }
- }
-
- if ((itNode != doc.end()) || (itEntry != tester.entries().end()))
- {
- ok = false;
- }
- } catch(const YAML::Exception& e) {
- ok = false;
- error = e.msg;
- }
- if(ok) {
- passed++;
- } else {
- std::cout << "Parser test failed: " << name << "\n";
- if(error != "")
- std::cout << " Caught exception: " << error << "\n";
- }
- total++;
- }
- }
-
- bool RunParserTests()
- {
- int passed = 0;
- int total = 0;
- RunScalarParserTest(&Parser::SimpleScalar, "simple scalar", passed, total);
- RunScalarParserTest(&Parser::MultiLineScalar, "multi-line scalar", passed, total);
- RunScalarParserTest(&Parser::LiteralScalar, "literal scalar", passed, total);
- RunScalarParserTest(&Parser::FoldedScalar, "folded scalar", passed, total);
- RunScalarParserTest(&Parser::ChompedFoldedScalar, "chomped folded scalar", passed, total);
- RunScalarParserTest(&Parser::ChompedLiteralScalar, "chomped literal scalar", passed, total);
- RunScalarParserTest(&Parser::FoldedScalarWithIndent, "folded scalar with indent", passed, total);
- RunScalarParserTest(&Parser::ColonScalar, "colon scalar", passed, total);
- RunScalarParserTest(&Parser::QuotedScalar, "quoted scalar", passed, total);
- RunScalarParserTest(&Parser::CommaScalar, "comma scalar", passed, total);
- RunScalarParserTest(&Parser::DashScalar, "dash scalar", passed, total);
- RunScalarParserTest(&Parser::URLScalar, "url scalar", passed, total);
-
- RunParserTest(&Parser::SimpleSeq, "simple seq", passed, total);
- RunParserTest(&Parser::SimpleMap, "simple map", passed, total);
- RunParserTest(&Parser::FlowSeq, "flow seq", passed, total);
- RunParserTest(&Parser::FlowMap, "flow map", passed, total);
- RunParserTest(&Parser::FlowMapWithOmittedKey, "flow map with omitted key", passed, total);
- RunParserTest(&Parser::FlowMapWithOmittedValue, "flow map with omitted value", passed, total);
- RunParserTest(&Parser::FlowMapWithSoloEntry, "flow map with solo entry", passed, total);
- RunParserTest(&Parser::FlowMapEndingWithSoloEntry, "flow map ending with solo entry", passed, total);
- RunParserTest(&Parser::QuotedSimpleKeys, "quoted simple keys", passed, total);
- RunParserTest(&Parser::CompressedMapAndSeq, "compressed map and seq", passed, total);
- RunParserTest(&Parser::NullBlockSeqEntry, "null block seq entry", passed, total);
- RunParserTest(&Parser::NullBlockMapKey, "null block map key", passed, total);
- RunParserTest(&Parser::NullBlockMapValue, "null block map value", passed, total);
- RunParserTest(&Parser::SimpleAlias, "simple alias", passed, total);
- RunParserTest(&Parser::AliasWithNull, "alias with null", passed, total);
- RunParserTest(&Parser::AnchorInSimpleKey, "anchor in simple key", passed, total);
- RunParserTest(&Parser::AliasAsSimpleKey, "alias as simple key", passed, total);
- RunParserTest(&Parser::ExplicitDoc, "explicit doc", passed, total);
- RunParserTest(&Parser::MultipleDocs, "multiple docs", passed, total);
- RunParserTest(&Parser::ExplicitEndDoc, "explicit end doc", passed, total);
- RunParserTest(&Parser::MultipleDocsWithSomeExplicitIndicators, "multiple docs with some explicit indicators", passed, total);
- 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);
- RunParserTest(&Parser::DefaultPlainScalarTag, "default plain scalar tag", passed, total);
- RunParserTest(&Parser::DefaultSingleQuotedScalarTag, "default single-quoted scalar tag", passed, total);
- RunParserTest(&Parser::ExplicitNonSpecificPlainScalarTag, "explicit, non-specific plain scalar tag", passed, total);
- RunParserTest(&Parser::BasicLocalTag, "basic local tag", passed, total);
- RunParserTest(&Parser::VerbatimLocalTag, "verbatim local tag", passed, total);
- RunParserTest(&Parser::StandardShortcutTag, "standard shortcut tag", passed, total);
- RunParserTest(&Parser::VerbatimURITag, "verbatim URI tag", passed, total);
- RunParserTest(&Parser::DefaultPlainScalarTag, "default plain scalar tag", passed, total);
- RunParserTest(&Parser::DefaultSequenceTag, "default sequence tag", passed, total);
- RunParserTest(&Parser::ExplicitNonSpecificSequenceTag, "explicit, non-specific sequence tag", passed, total);
- RunParserTest(&Parser::Infinity, "infinity", passed, total);
- RunParserTest(&Parser::NaN, "NaN", passed, total);
- RunParserTest(&Parser::NonConstKey, "non const key", passed, total);
- RunParserTest(&Parser::SingleChar, "single char", passed, total);
- RunParserTest(&Parser::QuotedNewline, "quoted newline", passed, total);
- RunParserTest(&Parser::DoubleAsInt, "double as int", passed, total);
- RunParserTest(&Parser::Binary, "binary", passed, total);
-
- RunEncodingTest(&EncodeToUtf8, false, "UTF-8, no BOM", passed, total);
- RunEncodingTest(&EncodeToUtf8, true, "UTF-8 with BOM", passed, total);
- RunEncodingTest(&EncodeToUtf16LE, false, "UTF-16LE, no BOM", passed, total);
- RunEncodingTest(&EncodeToUtf16LE, true, "UTF-16LE with BOM", passed, total);
- RunEncodingTest(&EncodeToUtf16BE, false, "UTF-16BE, no BOM", passed, total);
- RunEncodingTest(&EncodeToUtf16BE, true, "UTF-16BE with BOM", passed, total);
- RunEncodingTest(&EncodeToUtf32LE, false, "UTF-32LE, no BOM", passed, total);
- RunEncodingTest(&EncodeToUtf32LE, true, "UTF-32LE with BOM", passed, total);
- RunEncodingTest(&EncodeToUtf32BE, false, "UTF-32BE, no BOM", passed, total);
- RunEncodingTest(&EncodeToUtf32BE, true, "UTF-32BE with BOM", passed, total);
-
- std::cout << "Parser tests: " << passed << "/" << total << " passed\n";
- return passed == total;
- }
-}
-
diff --git a/yaml-cpp/test/old-api/spectests.cpp b/yaml-cpp/test/old-api/spectests.cpp
deleted file mode 100755
index fb5505be..00000000
--- a/yaml-cpp/test/old-api/spectests.cpp
+++ /dev/null
@@ -1,1456 +0,0 @@
-#include "spectests.h"
-#include "specexamples.h"
-#include "yaml-cpp/yaml.h"
-#include <fstream>
-#include <sstream>
-#include <vector>
-#include <iostream>
-
-#define YAML_ASSERT(cond) do { if(!(cond)) return " Assert failed: " #cond; } while(false)
-#define PARSE(doc, input) \
- std::stringstream stream(input);\
- YAML::Parser parser(stream);\
- YAML::Node doc;\
- parser.GetNextDocument(doc)
-#define PARSE_NEXT(doc) parser.GetNextDocument(doc)
-
-namespace Test {
- namespace Spec {
- // 2.1
- TEST SeqScalars() {
- PARSE(doc, ex2_1);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].to<std::string>() == "Mark McGwire");
- YAML_ASSERT(doc[1].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc[2].to<std::string>() == "Ken Griffey");
- return true;
- }
-
- // 2.2
- TEST MappingScalarsToScalars() {
- PARSE(doc, ex2_2);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["hr"].to<std::string>() == "65");
- YAML_ASSERT(doc["avg"].to<std::string>() == "0.278");
- YAML_ASSERT(doc["rbi"].to<std::string>() == "147");
- return true;
- }
-
- // 2.3
- TEST MappingScalarsToSequences() {
- PARSE(doc, ex2_3);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["american"].size() == 3);
- YAML_ASSERT(doc["american"][0].to<std::string>() == "Boston Red Sox");
- YAML_ASSERT(doc["american"][1].to<std::string>() == "Detroit Tigers");
- YAML_ASSERT(doc["american"][2].to<std::string>() == "New York Yankees");
- YAML_ASSERT(doc["national"].size() == 3);
- YAML_ASSERT(doc["national"][0].to<std::string>() == "New York Mets");
- YAML_ASSERT(doc["national"][1].to<std::string>() == "Chicago Cubs");
- YAML_ASSERT(doc["national"][2].to<std::string>() == "Atlanta Braves");
- return true;
- }
-
- // 2.4
- TEST SequenceOfMappings()
- {
- PARSE(doc, ex2_4);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc[0].size() == 3);
- YAML_ASSERT(doc[0]["name"].to<std::string>() == "Mark McGwire");
- YAML_ASSERT(doc[0]["hr"].to<std::string>() == "65");
- YAML_ASSERT(doc[0]["avg"].to<std::string>() == "0.278");
- YAML_ASSERT(doc[1].size() == 3);
- YAML_ASSERT(doc[1]["name"].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc[1]["hr"].to<std::string>() == "63");
- YAML_ASSERT(doc[1]["avg"].to<std::string>() == "0.288");
- return true;
- }
-
- // 2.5
- TEST SequenceOfSequences()
- {
- PARSE(doc, ex2_5);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].size() == 3);
- YAML_ASSERT(doc[0][0].to<std::string>() == "name");
- YAML_ASSERT(doc[0][1].to<std::string>() == "hr");
- YAML_ASSERT(doc[0][2].to<std::string>() == "avg");
- YAML_ASSERT(doc[1].size() == 3);
- YAML_ASSERT(doc[1][0].to<std::string>() == "Mark McGwire");
- YAML_ASSERT(doc[1][1].to<std::string>() == "65");
- YAML_ASSERT(doc[1][2].to<std::string>() == "0.278");
- YAML_ASSERT(doc[2].size() == 3);
- YAML_ASSERT(doc[2][0].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc[2][1].to<std::string>() == "63");
- YAML_ASSERT(doc[2][2].to<std::string>() == "0.288");
- return true;
- }
-
- // 2.6
- TEST MappingOfMappings()
- {
- PARSE(doc, ex2_6);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["Mark McGwire"].size() == 2);
- YAML_ASSERT(doc["Mark McGwire"]["hr"].to<std::string>() == "65");
- YAML_ASSERT(doc["Mark McGwire"]["avg"].to<std::string>() == "0.278");
- YAML_ASSERT(doc["Sammy Sosa"].size() == 2);
- YAML_ASSERT(doc["Sammy Sosa"]["hr"].to<std::string>() == "63");
- YAML_ASSERT(doc["Sammy Sosa"]["avg"].to<std::string>() == "0.288");
- return true;
- }
-
- // 2.7
- TEST TwoDocumentsInAStream()
- {
- PARSE(doc, ex2_7);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].to<std::string>() == "Mark McGwire");
- YAML_ASSERT(doc[1].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc[2].to<std::string>() == "Ken Griffey");
-
- PARSE_NEXT(doc);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc[0].to<std::string>() == "Chicago Cubs");
- YAML_ASSERT(doc[1].to<std::string>() == "St Louis Cardinals");
- return true;
- }
-
- // 2.8
- TEST PlayByPlayFeed()
- {
- PARSE(doc, ex2_8);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["time"].to<std::string>() == "20:03:20");
- YAML_ASSERT(doc["player"].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc["action"].to<std::string>() == "strike (miss)");
-
- PARSE_NEXT(doc);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["time"].to<std::string>() == "20:03:47");
- YAML_ASSERT(doc["player"].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc["action"].to<std::string>() == "grand slam");
- return true;
- }
-
- // 2.9
- TEST SingleDocumentWithTwoComments()
- {
- PARSE(doc, ex2_9);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["hr"].size() == 2);
- YAML_ASSERT(doc["hr"][0].to<std::string>() == "Mark McGwire");
- YAML_ASSERT(doc["hr"][1].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc["rbi"].size() == 2);
- YAML_ASSERT(doc["rbi"][0].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc["rbi"][1].to<std::string>() == "Ken Griffey");
- return true;
- }
-
- // 2.10
- TEST SimpleAnchor()
- {
- PARSE(doc, ex2_10);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["hr"].size() == 2);
- YAML_ASSERT(doc["hr"][0].to<std::string>() == "Mark McGwire");
- YAML_ASSERT(doc["hr"][1].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc["rbi"].size() == 2);
- YAML_ASSERT(doc["rbi"][0].to<std::string>() == "Sammy Sosa");
- YAML_ASSERT(doc["rbi"][1].to<std::string>() == "Ken Griffey");
- return true;
- }
-
- struct Pair {
- Pair() {}
- Pair(const std::string& f, const std::string& s): first(f), second(s) {}
- std::string first, second;
- };
-
- bool operator == (const Pair& p, const Pair& q) {
- return p.first == q.first && p.second == q.second;
- }
-
- void operator >> (const YAML::Node& node, Pair& p) {
- node[0] >> p.first;
- node[1] >> p.second;
- }
-
- // 2.11
- TEST MappingBetweenSequences()
- {
- PARSE(doc, ex2_11);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")].size() == 1);
- YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")][0].to<std::string>() == "2001-07-23");
- YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")].size() == 3);
- YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][0].to<std::string>() == "2001-07-02");
- YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][1].to<std::string>() == "2001-08-12");
- YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][2].to<std::string>() == "2001-08-14");
- return true;
- }
-
- // 2.12
- TEST CompactNestedMapping()
- {
- PARSE(doc, ex2_12);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].size() == 2);
- YAML_ASSERT(doc[0]["item"].to<std::string>() == "Super Hoop");
- YAML_ASSERT(doc[0]["quantity"].to<int>() == 1);
- YAML_ASSERT(doc[1].size() == 2);
- YAML_ASSERT(doc[1]["item"].to<std::string>() == "Basketball");
- YAML_ASSERT(doc[1]["quantity"].to<int>() == 4);
- YAML_ASSERT(doc[2].size() == 2);
- YAML_ASSERT(doc[2]["item"].to<std::string>() == "Big Shoes");
- YAML_ASSERT(doc[2]["quantity"].to<int>() == 1);
- return true;
- }
-
- // 2.13
- TEST InLiteralsNewlinesArePreserved()
- {
- PARSE(doc, ex2_13);
- YAML_ASSERT(doc.to<std::string>() ==
- "\\//||\\/||\n"
- "// || ||__");
- return true;
- }
-
- // 2.14
- TEST InFoldedScalarsNewlinesBecomeSpaces()
- {
- PARSE(doc, ex2_14);
- YAML_ASSERT(doc.to<std::string>() == "Mark McGwire's year was crippled by a knee injury.");
- return true;
- }
-
- // 2.15
- TEST FoldedNewlinesArePreservedForMoreIndentedAndBlankLines()
- {
- PARSE(doc, ex2_15);
- YAML_ASSERT(doc.to<std::string>() ==
- "Sammy Sosa completed another fine season with great stats.\n\n"
- " 63 Home Runs\n"
- " 0.288 Batting Average\n\n"
- "What a year!");
- return true;
- }
-
- // 2.16
- TEST IndentationDeterminesScope()
- {
- PARSE(doc, ex2_16);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["name"].to<std::string>() == "Mark McGwire");
- YAML_ASSERT(doc["accomplishment"].to<std::string>() == "Mark set a major league home run record in 1998.\n");
- YAML_ASSERT(doc["stats"].to<std::string>() == "65 Home Runs\n0.278 Batting Average\n");
- return true;
- }
-
- // 2.17
- TEST QuotedScalars()
- {
- PARSE(doc, ex2_17);
- YAML_ASSERT(doc.size() == 6);
- YAML_ASSERT(doc["unicode"].to<std::string>() == "Sosa did fine.\xe2\x98\xba");
- YAML_ASSERT(doc["control"].to<std::string>() == "\b1998\t1999\t2000\n");
- YAML_ASSERT(doc["hex esc"].to<std::string>() == "\x0d\x0a is \r\n");
- YAML_ASSERT(doc["single"].to<std::string>() == "\"Howdy!\" he cried.");
- YAML_ASSERT(doc["quoted"].to<std::string>() == " # Not a 'comment'.");
- YAML_ASSERT(doc["tie-fighter"].to<std::string>() == "|\\-*-/|");
- return true;
- }
-
- // 2.18
- TEST MultiLineFlowScalars()
- {
- PARSE(doc, ex2_18);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["plain"].to<std::string>() == "This unquoted scalar spans many lines.");
- YAML_ASSERT(doc["quoted"].to<std::string>() == "So does this quoted scalar.\n");
- return true;
- }
-
- // TODO: 2.19 - 2.22 schema tags
-
- // 2.23
- TEST VariousExplicitTags()
- {
- PARSE(doc, ex2_23);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["not-date"].Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(doc["not-date"].to<std::string>() == "2002-04-28");
- YAML_ASSERT(doc["picture"].Tag() == "tag:yaml.org,2002:binary");
- YAML_ASSERT(doc["picture"].to<std::string>() ==
- "R0lGODlhDAAMAIQAAP//9/X\n"
- "17unp5WZmZgAAAOfn515eXv\n"
- "Pz7Y6OjuDg4J+fn5OTk6enp\n"
- "56enmleECcgggoBADs=\n"
- );
- YAML_ASSERT(doc["application specific tag"].Tag() == "!something");
- YAML_ASSERT(doc["application specific tag"].to<std::string>() ==
- "The semantics of the tag\n"
- "above may be different for\n"
- "different documents."
- );
- return true;
- }
-
- // 2.24
- TEST GlobalTags()
- {
- PARSE(doc, ex2_24);
- YAML_ASSERT(doc.Tag() == "tag:clarkevans.com,2002:shape");
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].Tag() == "tag:clarkevans.com,2002:circle");
- YAML_ASSERT(doc[0].size() == 2);
- YAML_ASSERT(doc[0]["center"].size() == 2);
- YAML_ASSERT(doc[0]["center"]["x"].to<int>() == 73);
- YAML_ASSERT(doc[0]["center"]["y"].to<int>() == 129);
- YAML_ASSERT(doc[0]["radius"].to<int>() == 7);
- YAML_ASSERT(doc[1].Tag() == "tag:clarkevans.com,2002:line");
- YAML_ASSERT(doc[1].size() == 2);
- YAML_ASSERT(doc[1]["start"].size() == 2);
- YAML_ASSERT(doc[1]["start"]["x"].to<int>() == 73);
- YAML_ASSERT(doc[1]["start"]["y"].to<int>() == 129);
- YAML_ASSERT(doc[1]["finish"].size() == 2);
- YAML_ASSERT(doc[1]["finish"]["x"].to<int>() == 89);
- YAML_ASSERT(doc[1]["finish"]["y"].to<int>() == 102);
- YAML_ASSERT(doc[2].Tag() == "tag:clarkevans.com,2002:label");
- YAML_ASSERT(doc[2].size() == 3);
- YAML_ASSERT(doc[2]["start"].size() == 2);
- YAML_ASSERT(doc[2]["start"]["x"].to<int>() == 73);
- YAML_ASSERT(doc[2]["start"]["y"].to<int>() == 129);
- YAML_ASSERT(doc[2]["color"].to<std::string>() == "0xFFEEBB");
- YAML_ASSERT(doc[2]["text"].to<std::string>() == "Pretty vector drawing.");
- return true;
- }
-
- // 2.25
- TEST UnorderedSets()
- {
- PARSE(doc, ex2_25);
- YAML_ASSERT(doc.Tag() == "tag:yaml.org,2002:set");
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(IsNull(doc["Mark McGwire"]));
- YAML_ASSERT(IsNull(doc["Sammy Sosa"]));
- YAML_ASSERT(IsNull(doc["Ken Griffey"]));
- return true;
- }
-
- // 2.26
- TEST OrderedMappings()
- {
- PARSE(doc, ex2_26);
- YAML_ASSERT(doc.Tag() == "tag:yaml.org,2002:omap");
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].size() == 1);
- YAML_ASSERT(doc[0]["Mark McGwire"].to<int>() == 65);
- YAML_ASSERT(doc[1].size() == 1);
- YAML_ASSERT(doc[1]["Sammy Sosa"].to<int>() == 63);
- YAML_ASSERT(doc[2].size() == 1);
- YAML_ASSERT(doc[2]["Ken Griffey"].to<int>() == 58);
- return true;
- }
-
- // 2.27
- TEST Invoice()
- {
- PARSE(doc, ex2_27);
- YAML_ASSERT(doc.Tag() == "tag:clarkevans.com,2002:invoice");
- YAML_ASSERT(doc.size() == 8);
- YAML_ASSERT(doc["invoice"].to<int>() == 34843);
- YAML_ASSERT(doc["date"].to<std::string>() == "2001-01-23");
- YAML_ASSERT(doc["bill-to"].size() == 3);
- YAML_ASSERT(doc["bill-to"]["given"].to<std::string>() == "Chris");
- YAML_ASSERT(doc["bill-to"]["family"].to<std::string>() == "Dumars");
- YAML_ASSERT(doc["bill-to"]["address"].size() == 4);
- YAML_ASSERT(doc["bill-to"]["address"]["lines"].to<std::string>() == "458 Walkman Dr.\nSuite #292\n");
- YAML_ASSERT(doc["bill-to"]["address"]["city"].to<std::string>() == "Royal Oak");
- YAML_ASSERT(doc["bill-to"]["address"]["state"].to<std::string>() == "MI");
- YAML_ASSERT(doc["bill-to"]["address"]["postal"].to<std::string>() == "48046");
- YAML_ASSERT(doc["ship-to"].size() == 3);
- YAML_ASSERT(doc["ship-to"]["given"].to<std::string>() == "Chris");
- YAML_ASSERT(doc["ship-to"]["family"].to<std::string>() == "Dumars");
- YAML_ASSERT(doc["ship-to"]["address"].size() == 4);
- YAML_ASSERT(doc["ship-to"]["address"]["lines"].to<std::string>() == "458 Walkman Dr.\nSuite #292\n");
- YAML_ASSERT(doc["ship-to"]["address"]["city"].to<std::string>() == "Royal Oak");
- YAML_ASSERT(doc["ship-to"]["address"]["state"].to<std::string>() == "MI");
- YAML_ASSERT(doc["ship-to"]["address"]["postal"].to<std::string>() == "48046");
- YAML_ASSERT(doc["product"].size() == 2);
- YAML_ASSERT(doc["product"][0].size() == 4);
- YAML_ASSERT(doc["product"][0]["sku"].to<std::string>() == "BL394D");
- YAML_ASSERT(doc["product"][0]["quantity"].to<int>() == 4);
- YAML_ASSERT(doc["product"][0]["description"].to<std::string>() == "Basketball");
- YAML_ASSERT(doc["product"][0]["price"].to<std::string>() == "450.00");
- YAML_ASSERT(doc["product"][1].size() == 4);
- YAML_ASSERT(doc["product"][1]["sku"].to<std::string>() == "BL4438H");
- YAML_ASSERT(doc["product"][1]["quantity"].to<int>() == 1);
- YAML_ASSERT(doc["product"][1]["description"].to<std::string>() == "Super Hoop");
- YAML_ASSERT(doc["product"][1]["price"].to<std::string>() == "2392.00");
- YAML_ASSERT(doc["tax"].to<std::string>() == "251.42");
- YAML_ASSERT(doc["total"].to<std::string>() == "4443.52");
- YAML_ASSERT(doc["comments"].to<std::string>() == "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.");
- return true;
- }
-
- // 2.28
- TEST LogFile()
- {
- PARSE(doc, ex2_28);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["Time"].to<std::string>() == "2001-11-23 15:01:42 -5");
- YAML_ASSERT(doc["User"].to<std::string>() == "ed");
- YAML_ASSERT(doc["Warning"].to<std::string>() == "This is an error message for the log file");
-
- PARSE_NEXT(doc);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["Time"].to<std::string>() == "2001-11-23 15:02:31 -5");
- YAML_ASSERT(doc["User"].to<std::string>() == "ed");
- YAML_ASSERT(doc["Warning"].to<std::string>() == "A slightly different error message.");
-
- PARSE_NEXT(doc);
- YAML_ASSERT(doc.size() == 4);
- YAML_ASSERT(doc["Date"].to<std::string>() == "2001-11-23 15:03:17 -5");
- YAML_ASSERT(doc["User"].to<std::string>() == "ed");
- YAML_ASSERT(doc["Fatal"].to<std::string>() == "Unknown variable \"bar\"");
- YAML_ASSERT(doc["Stack"].size() == 2);
- YAML_ASSERT(doc["Stack"][0].size() == 3);
- YAML_ASSERT(doc["Stack"][0]["file"].to<std::string>() == "TopClass.py");
- YAML_ASSERT(doc["Stack"][0]["line"].to<std::string>() == "23");
- YAML_ASSERT(doc["Stack"][0]["code"].to<std::string>() == "x = MoreObject(\"345\\n\")\n");
- YAML_ASSERT(doc["Stack"][1].size() == 3);
- YAML_ASSERT(doc["Stack"][1]["file"].to<std::string>() == "MoreClass.py");
- YAML_ASSERT(doc["Stack"][1]["line"].to<std::string>() == "58");
- YAML_ASSERT(doc["Stack"][1]["code"].to<std::string>() == "foo = bar");
- return true;
- }
-
- // TODO: 5.1 - 5.2 BOM
-
- // 5.3
- TEST BlockStructureIndicators()
- {
- PARSE(doc, ex5_3);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["sequence"].size() == 2);
- YAML_ASSERT(doc["sequence"][0].to<std::string>() == "one");
- YAML_ASSERT(doc["sequence"][1].to<std::string>() == "two");
- YAML_ASSERT(doc["mapping"].size() == 2);
- YAML_ASSERT(doc["mapping"]["sky"].to<std::string>() == "blue");
- YAML_ASSERT(doc["mapping"]["sea"].to<std::string>() == "green");
- return true;
- }
-
- // 5.4
- TEST FlowStructureIndicators()
- {
- PARSE(doc, ex5_4);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["sequence"].size() == 2);
- YAML_ASSERT(doc["sequence"][0].to<std::string>() == "one");
- YAML_ASSERT(doc["sequence"][1].to<std::string>() == "two");
- YAML_ASSERT(doc["mapping"].size() == 2);
- YAML_ASSERT(doc["mapping"]["sky"].to<std::string>() == "blue");
- YAML_ASSERT(doc["mapping"]["sea"].to<std::string>() == "green");
- return true;
- }
-
- // 5.5
- TEST CommentIndicator()
- {
- PARSE(doc, ex5_5);
- YAML_ASSERT(doc.size() == 0);
- return true;
- }
-
- // 5.6
- TEST NodePropertyIndicators()
- {
- PARSE(doc, ex5_6);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["anchored"].to<std::string>() == "value"); // TODO: assert tag
- YAML_ASSERT(doc["alias"].to<std::string>() == "value");
- return true;
- }
-
- // 5.7
- TEST BlockScalarIndicators()
- {
- PARSE(doc, ex5_7);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["literal"].to<std::string>() == "some\ntext\n");
- YAML_ASSERT(doc["folded"].to<std::string>() == "some text\n");
- return true;
- }
-
- // 5.8
- TEST QuotedScalarIndicators()
- {
- PARSE(doc, ex5_8);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["single"].to<std::string>() == "text");
- YAML_ASSERT(doc["double"].to<std::string>() == "text");
- return true;
- }
-
- // TODO: 5.9 directive
- // TODO: 5.10 reserved indicator
-
- // 5.11
- TEST LineBreakCharacters()
- {
- PARSE(doc, ex5_11);
- YAML_ASSERT(doc.to<std::string>() == "Line break (no glyph)\nLine break (glyphed)\n");
- return true;
- }
-
- // 5.12
- TEST TabsAndSpaces()
- {
- PARSE(doc, ex5_12);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["quoted"].to<std::string>() == "Quoted\t");
- YAML_ASSERT(doc["block"].to<std::string>() ==
- "void main() {\n"
- "\tprintf(\"Hello, world!\\n\");\n"
- "}");
- return true;
- }
-
- // 5.13
- TEST EscapedCharacters()
- {
- PARSE(doc, ex5_13);
- YAML_ASSERT(doc.to<std::string>() == "Fun with \x5C \x22 \x07 \x08 \x1B \x0C \x0A \x0D \x09 \x0B " + std::string("\x00", 1) + " \x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9 A A A");
- return true;
- }
-
- // 5.14
- TEST InvalidEscapedCharacters()
- {
- std::stringstream stream(ex5_14);
- try {
- YAML::Parser parser(stream);
- YAML::Node doc;
- parser.GetNextDocument(doc);
- } catch(const YAML::ParserException& e) {
- YAML_ASSERT(e.msg == std::string(YAML::ErrorMsg::INVALID_ESCAPE) + "c");
- return true;
- }
-
- return false;
- }
-
- // 6.1
- TEST IndentationSpaces()
- {
- PARSE(doc, ex6_1);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["Not indented"].size() == 2);
- YAML_ASSERT(doc["Not indented"]["By one space"].to<std::string>() == "By four\n spaces\n");
- YAML_ASSERT(doc["Not indented"]["Flow style"].size() == 3);
- YAML_ASSERT(doc["Not indented"]["Flow style"][0].to<std::string>() == "By two");
- YAML_ASSERT(doc["Not indented"]["Flow style"][1].to<std::string>() == "Also by two");
- YAML_ASSERT(doc["Not indented"]["Flow style"][2].to<std::string>() == "Still by two");
- return true;
- }
-
- // 6.2
- TEST IndentationIndicators()
- {
- PARSE(doc, ex6_2);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["a"].size() == 2);
- YAML_ASSERT(doc["a"][0].to<std::string>() == "b");
- YAML_ASSERT(doc["a"][1].size() == 2);
- YAML_ASSERT(doc["a"][1][0].to<std::string>() == "c");
- YAML_ASSERT(doc["a"][1][1].to<std::string>() == "d");
- return true;
- }
-
- // 6.3
- TEST SeparationSpaces()
- {
- PARSE(doc, ex6_3);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc[0].size() == 1);
- YAML_ASSERT(doc[0]["foo"].to<std::string>() == "bar");
- YAML_ASSERT(doc[1].size() == 2);
- YAML_ASSERT(doc[1][0].to<std::string>() == "baz");
- YAML_ASSERT(doc[1][1].to<std::string>() == "baz");
- return true;
- }
-
- // 6.4
- TEST LinePrefixes()
- {
- PARSE(doc, ex6_4);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["plain"].to<std::string>() == "text lines");
- YAML_ASSERT(doc["quoted"].to<std::string>() == "text lines");
- YAML_ASSERT(doc["block"].to<std::string>() == "text\n \tlines\n");
- return true;
- }
-
- // 6.5
- TEST EmptyLines()
- {
- PARSE(doc, ex6_5);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["Folding"].to<std::string>() == "Empty line\nas a line feed");
- YAML_ASSERT(doc["Chomping"].to<std::string>() == "Clipped empty lines\n");
- return true;
- }
-
- // 6.6
- TEST LineFolding()
- {
- PARSE(doc, ex6_6);
- YAML_ASSERT(doc.to<std::string>() == "trimmed\n\n\nas space");
- return true;
- }
-
- // 6.7
- TEST BlockFolding()
- {
- PARSE(doc, ex6_7);
- YAML_ASSERT(doc.to<std::string>() == "foo \n\n\t bar\n\nbaz\n");
- return true;
- }
-
- // 6.8
- TEST FlowFolding()
- {
- PARSE(doc, ex6_8);
- YAML_ASSERT(doc.to<std::string>() == " foo\nbar\nbaz ");
- return true;
- }
-
- // 6.9
- TEST SeparatedComment()
- {
- PARSE(doc, ex6_9);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["key"].to<std::string>() == "value");
- return true;
- }
-
- // 6.10
- TEST CommentLines()
- {
- PARSE(doc, ex6_10);
- YAML_ASSERT(doc.size() == 0);
- return true;
- }
-
- // 6.11
- TEST MultiLineComments()
- {
- PARSE(doc, ex6_11);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["key"].to<std::string>() == "value");
- return true;
- }
-
- struct StringMap {
- typedef std::map<std::string, std::string> Map;
- Map _;
- };
-
- bool operator == (const StringMap& m, const StringMap& n) {
- return m._ == n._;
- }
-
- void operator >> (const YAML::Node& node, StringMap& m) {
- m._.clear();
- for(YAML::Iterator it=node.begin();it!=node.end();++it) {
- std::string key = it.first().to<std::string>();
- std::string value = it.second().to<std::string>();
- m._[key] = value;
- }
- }
-
-
- // 6.12
- TEST SeparationSpacesII()
- {
- PARSE(doc, ex6_12);
- std::map<std::string, std::string> key;
- key["first"] = "Sammy";
- key["last"] = "Sosa";
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc[key].size() == 2);
- YAML_ASSERT(doc[key]["hr"].to<int>() == 65);
- YAML_ASSERT(doc[key]["avg"].to<std::string>() == "0.278");
- return true;
- }
-
- // 6.13
- TEST ReservedDirectives()
- {
- PARSE(doc, ex6_13);
- return true;
- }
-
- // 6.14
- TEST YAMLDirective()
- {
- PARSE(doc, ex6_14);
- return true;
- }
-
- // 6.15
- TEST InvalidRepeatedYAMLDirective()
- {
- try {
- PARSE(doc, ex6_15);
- } catch(const YAML::ParserException& e) {
- if(e.msg == YAML::ErrorMsg::REPEATED_YAML_DIRECTIVE)
- return true;
-
- throw;
- }
-
- return " No exception was thrown";
- }
-
- // 6.16
- TEST TagDirective()
- {
- PARSE(doc, ex6_16);
- YAML_ASSERT(doc.Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(doc.to<std::string>() == "foo");
- return true;
- }
-
- // 6.17
- TEST InvalidRepeatedTagDirective()
- {
- try {
- PARSE(doc, ex6_17);
- } catch(const YAML::ParserException& e) {
- if(e.msg == YAML::ErrorMsg::REPEATED_TAG_DIRECTIVE)
- return true;
-
- throw;
- }
-
- return " No exception was thrown";
- }
-
- // 6.18
- TEST PrimaryTagHandle()
- {
- PARSE(doc, ex6_18);
- YAML_ASSERT(doc.Tag() == "!foo");
- YAML_ASSERT(doc.to<std::string>() == "bar");
-
- PARSE_NEXT(doc);
- YAML_ASSERT(doc.Tag() == "tag:example.com,2000:app/foo");
- YAML_ASSERT(doc.to<std::string>() == "bar");
- return true;
- }
-
- // 6.19
- TEST SecondaryTagHandle()
- {
- PARSE(doc, ex6_19);
- YAML_ASSERT(doc.Tag() == "tag:example.com,2000:app/int");
- YAML_ASSERT(doc.to<std::string>() == "1 - 3");
- return true;
- }
-
- // 6.20
- TEST TagHandles()
- {
- PARSE(doc, ex6_20);
- YAML_ASSERT(doc.Tag() == "tag:example.com,2000:app/foo");
- YAML_ASSERT(doc.to<std::string>() == "bar");
- return true;
- }
-
- // 6.21
- TEST LocalTagPrefix()
- {
- PARSE(doc, ex6_21);
- YAML_ASSERT(doc.Tag() == "!my-light");
- YAML_ASSERT(doc.to<std::string>() == "fluorescent");
-
- PARSE_NEXT(doc);
- YAML_ASSERT(doc.Tag() == "!my-light");
- YAML_ASSERT(doc.to<std::string>() == "green");
- return true;
- }
-
- // 6.22
- TEST GlobalTagPrefix()
- {
- PARSE(doc, ex6_22);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc[0].Tag() == "tag:example.com,2000:app/foo");
- YAML_ASSERT(doc[0].to<std::string>() == "bar");
- return true;
- }
-
- // 6.23
- TEST NodeProperties()
- {
- PARSE(doc, ex6_23);
- YAML_ASSERT(doc.size() == 2);
- for(YAML::Iterator it=doc.begin();it!=doc.end();++it) {
- if(it.first().to<std::string>() == "foo") {
- YAML_ASSERT(it.first().Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(it.second().Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(it.second().to<std::string>() == "bar");
- } else if(it.first().to<std::string>() == "baz") {
- YAML_ASSERT(it.second().to<std::string>() == "foo");
- } else
- return " unknown key";
- }
-
- return true;
- }
-
- // 6.24
- TEST VerbatimTags()
- {
- PARSE(doc, ex6_24);
- YAML_ASSERT(doc.size() == 1);
- for(YAML::Iterator it=doc.begin();it!=doc.end();++it) {
- YAML_ASSERT(it.first().Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(it.first().to<std::string>() == "foo");
- YAML_ASSERT(it.second().Tag() == "!bar");
- YAML_ASSERT(it.second().to<std::string>() == "baz");
- }
- return true;
- }
-
- // 6.25
- TEST InvalidVerbatimTags()
- {
- PARSE(doc, ex6_25);
- return " not implemented yet"; // TODO: check tags (but we probably will say these are valid, I think)
- }
-
- // 6.26
- TEST TagShorthands()
- {
- PARSE(doc, ex6_26);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].Tag() == "!local");
- YAML_ASSERT(doc[0].to<std::string>() == "foo");
- YAML_ASSERT(doc[1].Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(doc[1].to<std::string>() == "bar");
- YAML_ASSERT(doc[2].Tag() == "tag:example.com,2000:app/tag%21");
- YAML_ASSERT(doc[2].to<std::string>() == "baz");
- return true;
- }
-
- // 6.27
- TEST InvalidTagShorthands()
- {
- bool threw = false;
- try {
- PARSE(doc, ex6_27a);
- } catch(const YAML::ParserException& e) {
- threw = true;
- if(e.msg != YAML::ErrorMsg::TAG_WITH_NO_SUFFIX)
- throw;
- }
-
- if(!threw)
- return " No exception was thrown for a tag with no suffix";
-
- PARSE(doc, ex6_27b); // TODO: should we reject this one (since !h! is not declared)?
- return " not implemented yet";
- }
-
- // 6.28
- TEST NonSpecificTags()
- {
- PARSE(doc, ex6_28);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].to<std::string>() == "12"); // TODO: check tags. How?
- YAML_ASSERT(doc[1].to<int>() == 12);
- YAML_ASSERT(doc[2].to<std::string>() == "12");
- return true;
- }
-
- // 6.29
- TEST NodeAnchors()
- {
- PARSE(doc, ex6_29);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["First occurrence"].to<std::string>() == "Value");
- YAML_ASSERT(doc["Second occurrence"].to<std::string>() == "Value");
- return true;
- }
-
- // 7.1
- TEST AliasNodes()
- {
- PARSE(doc, ex7_1);
- YAML_ASSERT(doc.size() == 4);
- YAML_ASSERT(doc["First occurrence"].to<std::string>() == "Foo");
- YAML_ASSERT(doc["Second occurrence"].to<std::string>() == "Foo");
- YAML_ASSERT(doc["Override anchor"].to<std::string>() == "Bar");
- YAML_ASSERT(doc["Reuse anchor"].to<std::string>() == "Bar");
- return true;
- }
-
- // 7.2
- TEST EmptyNodes()
- {
- PARSE(doc, ex7_2);
- YAML_ASSERT(doc.size() == 2);
- for(YAML::Iterator it=doc.begin();it!=doc.end();++it) {
- if(it.first().to<std::string>() == "foo") {
- YAML_ASSERT(it.second().Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(it.second().to<std::string>() == "");
- } else if(it.first().to<std::string>() == "") {
- YAML_ASSERT(it.first().Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(it.second().to<std::string>() == "bar");
- } else
- return " unexpected key";
- }
- return true;
- }
-
- // 7.3
- TEST CompletelyEmptyNodes()
- {
- PARSE(doc, ex7_3);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(IsNull(doc["foo"]));
- YAML_ASSERT(doc[YAML::Null].to<std::string>() == "bar");
- return true;
- }
-
- // 7.4
- TEST DoubleQuotedImplicitKeys()
- {
- PARSE(doc, ex7_4);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["implicit block key"].size() == 1);
- YAML_ASSERT(doc["implicit block key"][0].size() == 1);
- YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"].to<std::string>() == "value");
- return true;
- }
-
- // 7.5
- TEST DoubleQuotedLineBreaks()
- {
- PARSE(doc, ex7_5);
- YAML_ASSERT(doc.to<std::string>() == "folded to a space,\nto a line feed, or \t \tnon-content");
- return true;
- }
-
- // 7.6
- TEST DoubleQuotedLines()
- {
- PARSE(doc, ex7_6);
- YAML_ASSERT(doc.to<std::string>() == " 1st non-empty\n2nd non-empty 3rd non-empty ");
- return true;
- }
-
- // 7.7
- TEST SingleQuotedCharacters()
- {
- PARSE(doc, ex7_7);
- YAML_ASSERT(doc.to<std::string>() == "here's to \"quotes\"");
- return true;
- }
-
- // 7.8
- TEST SingleQuotedImplicitKeys()
- {
- PARSE(doc, ex7_8);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["implicit block key"].size() == 1);
- YAML_ASSERT(doc["implicit block key"][0].size() == 1);
- YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"].to<std::string>() == "value");
- return true;
- }
-
- // 7.9
- TEST SingleQuotedLines()
- {
- PARSE(doc, ex7_9);
- YAML_ASSERT(doc.to<std::string>() == " 1st non-empty\n2nd non-empty 3rd non-empty ");
- return true;
- }
-
- // 7.10
- TEST PlainCharacters()
- {
- PARSE(doc, ex7_10);
- YAML_ASSERT(doc.size() == 6);
- YAML_ASSERT(doc[0].to<std::string>() == "::vector");
- YAML_ASSERT(doc[1].to<std::string>() == ": - ()");
- YAML_ASSERT(doc[2].to<std::string>() == "Up, up, and away!");
- YAML_ASSERT(doc[3].to<int>() == -123);
- YAML_ASSERT(doc[4].to<std::string>() == "http://example.com/foo#bar");
- YAML_ASSERT(doc[5].size() == 5);
- YAML_ASSERT(doc[5][0].to<std::string>() == "::vector");
- YAML_ASSERT(doc[5][1].to<std::string>() == ": - ()");
- YAML_ASSERT(doc[5][2].to<std::string>() == "Up, up, and away!");
- YAML_ASSERT(doc[5][3].to<int>() == -123);
- YAML_ASSERT(doc[5][4].to<std::string>() == "http://example.com/foo#bar");
- return true;
- }
-
- // 7.11
- TEST PlainImplicitKeys()
- {
- PARSE(doc, ex7_11);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["implicit block key"].size() == 1);
- YAML_ASSERT(doc["implicit block key"][0].size() == 1);
- YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"].to<std::string>() == "value");
- return true;
- }
-
- // 7.12
- TEST PlainLines()
- {
- PARSE(doc, ex7_12);
- YAML_ASSERT(doc.to<std::string>() == "1st non-empty\n2nd non-empty 3rd non-empty");
- return true;
- }
-
- // 7.13
- TEST FlowSequence()
- {
- PARSE(doc, ex7_13);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc[0].size() == 2);
- YAML_ASSERT(doc[0][0].to<std::string>() == "one");
- YAML_ASSERT(doc[0][1].to<std::string>() == "two");
- YAML_ASSERT(doc[1].size() == 2);
- YAML_ASSERT(doc[1][0].to<std::string>() == "three");
- YAML_ASSERT(doc[1][1].to<std::string>() == "four");
- return true;
- }
-
- // 7.14
- TEST FlowSequenceEntries()
- {
- PARSE(doc, ex7_14);
- YAML_ASSERT(doc.size() == 5);
- YAML_ASSERT(doc[0].to<std::string>() == "double quoted");
- YAML_ASSERT(doc[1].to<std::string>() == "single quoted");
- YAML_ASSERT(doc[2].to<std::string>() == "plain text");
- YAML_ASSERT(doc[3].size() == 1);
- YAML_ASSERT(doc[3][0].to<std::string>() == "nested");
- YAML_ASSERT(doc[4].size() == 1);
- YAML_ASSERT(doc[4]["single"].to<std::string>() == "pair");
- return true;
- }
-
- // 7.15
- TEST FlowMappings()
- {
- PARSE(doc, ex7_15);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc[0].size() == 2);
- YAML_ASSERT(doc[0]["one"].to<std::string>() == "two");
- YAML_ASSERT(doc[0]["three"].to<std::string>() == "four");
- YAML_ASSERT(doc[1].size() == 2);
- YAML_ASSERT(doc[1]["five"].to<std::string>() == "six");
- YAML_ASSERT(doc[1]["seven"].to<std::string>() == "eight");
- return true;
- }
-
- // 7.16
- TEST FlowMappingEntries()
- {
- PARSE(doc, ex7_16);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["explicit"].to<std::string>() == "entry");
- YAML_ASSERT(doc["implicit"].to<std::string>() == "entry");
- YAML_ASSERT(IsNull(doc[YAML::Null]));
- return true;
- }
-
- // 7.17
- TEST FlowMappingSeparateValues()
- {
- PARSE(doc, ex7_17);
- YAML_ASSERT(doc.size() == 4);
- YAML_ASSERT(doc["unquoted"].to<std::string>() == "separate");
- YAML_ASSERT(IsNull(doc["http://foo.com"]));
- YAML_ASSERT(IsNull(doc["omitted value"]));
- YAML_ASSERT(doc[YAML::Null].to<std::string>() == "omitted key");
- return true;
- }
-
- // 7.18
- TEST FlowMappingAdjacentValues()
- {
- PARSE(doc, ex7_18);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["adjacent"].to<std::string>() == "value");
- YAML_ASSERT(doc["readable"].to<std::string>() == "value");
- YAML_ASSERT(IsNull(doc["empty"]));
- return true;
- }
-
- // 7.19
- TEST SinglePairFlowMappings()
- {
- PARSE(doc, ex7_19);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc[0].size() == 1);
- YAML_ASSERT(doc[0]["foo"].to<std::string>() == "bar");
- return true;
- }
-
- // 7.20
- TEST SinglePairExplicitEntry()
- {
- PARSE(doc, ex7_20);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc[0].size() == 1);
- YAML_ASSERT(doc[0]["foo bar"].to<std::string>() == "baz");
- return true;
- }
-
- // 7.21
- TEST SinglePairImplicitEntries()
- {
- PARSE(doc, ex7_21);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].size() == 1);
- YAML_ASSERT(doc[0][0].size() == 1);
- YAML_ASSERT(doc[0][0]["YAML"].to<std::string>() == "separate");
- YAML_ASSERT(doc[1].size() == 1);
- YAML_ASSERT(doc[1][0].size() == 1);
- YAML_ASSERT(doc[1][0][YAML::Null].to<std::string>() == "empty key entry");
- YAML_ASSERT(doc[2].size() == 1);
- YAML_ASSERT(doc[2][0].size() == 1);
- StringMap key;
- key._["JSON"] = "like";
- YAML_ASSERT(doc[2][0][key].to<std::string>() == "adjacent");
- return true;
- }
-
- // 7.22
- TEST InvalidImplicitKeys()
- {
- try {
- PARSE(doc, ex7_22);
- } catch(const YAML::Exception& e) {
- if(e.msg == YAML::ErrorMsg::END_OF_SEQ_FLOW)
- return true;
-
- throw;
- }
- return " no exception thrown";
- }
-
- // 7.23
- TEST FlowContent()
- {
- PARSE(doc, ex7_23);
- YAML_ASSERT(doc.size() == 5);
- YAML_ASSERT(doc[0].size() == 2);
- YAML_ASSERT(doc[0][0].to<std::string>() == "a");
- YAML_ASSERT(doc[0][1].to<std::string>() == "b");
- YAML_ASSERT(doc[1].size() == 1);
- YAML_ASSERT(doc[1]["a"].to<std::string>() == "b");
- YAML_ASSERT(doc[2].to<std::string>() == "a");
- YAML_ASSERT(doc[3].to<char>() == 'b');
- YAML_ASSERT(doc[4].to<std::string>() == "c");
- return true;
- }
-
- // 7.24
- TEST FlowNodes()
- {
- PARSE(doc, ex7_24);
- YAML_ASSERT(doc.size() == 5);
- YAML_ASSERT(doc[0].Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(doc[0].to<std::string>() == "a");
- YAML_ASSERT(doc[1].to<char>() == 'b');
- YAML_ASSERT(doc[2].to<std::string>() == "c");
- YAML_ASSERT(doc[3].to<std::string>() == "c");
- YAML_ASSERT(doc[4].Tag() == "tag:yaml.org,2002:str");
- YAML_ASSERT(doc[4].to<std::string>() == "");
- return true;
- }
-
- // 8.1
- TEST BlockScalarHeader()
- {
- PARSE(doc, ex8_1);
- YAML_ASSERT(doc.size() == 4);
- YAML_ASSERT(doc[0].to<std::string>() == "literal\n");
- YAML_ASSERT(doc[1].to<std::string>() == " folded\n");
- YAML_ASSERT(doc[2].to<std::string>() == "keep\n\n");
- YAML_ASSERT(doc[3].to<std::string>() == " strip");
- return true;
- }
-
- // 8.2
- TEST BlockIndentationHeader()
- {
- PARSE(doc, ex8_2);
- YAML_ASSERT(doc.size() == 4);
- YAML_ASSERT(doc[0].to<std::string>() == "detected\n");
- YAML_ASSERT(doc[1].to<std::string>() == "\n\n# detected\n");
- YAML_ASSERT(doc[2].to<std::string>() == " explicit\n");
- YAML_ASSERT(doc[3].to<std::string>() == "\t\ndetected\n");
- return true;
- }
-
- // 8.3
- TEST InvalidBlockScalarIndentationIndicators()
- {
- {
- bool threw = false;
- try {
- PARSE(doc, ex8_3a);
- } catch(const YAML::Exception& e) {
- if(e.msg != YAML::ErrorMsg::END_OF_SEQ)
- throw;
-
- threw = true;
- }
-
- if(!threw)
- return " no exception thrown for less indented auto-detecting indentation for a literal block scalar";
- }
-
- {
- bool threw = false;
- try {
- PARSE(doc, ex8_3b);
- } catch(const YAML::Exception& e) {
- if(e.msg != YAML::ErrorMsg::END_OF_SEQ)
- throw;
-
- threw = true;
- }
-
- if(!threw)
- return " no exception thrown for less indented auto-detecting indentation for a folded block scalar";
- }
-
- {
- bool threw = false;
- try {
- PARSE(doc, ex8_3c);
- } catch(const YAML::Exception& e) {
- if(e.msg != YAML::ErrorMsg::END_OF_SEQ)
- throw;
-
- threw = true;
- }
-
- if(!threw)
- return " no exception thrown for less indented explicit indentation for a literal block scalar";
- }
-
- return true;
- }
-
- // 8.4
- TEST ChompingFinalLineBreak()
- {
- PARSE(doc, ex8_4);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["strip"].to<std::string>() == "text");
- YAML_ASSERT(doc["clip"].to<std::string>() == "text\n");
- YAML_ASSERT(doc["keep"].to<std::string>() == "text\n");
- return true;
- }
-
- // 8.5
- TEST ChompingTrailingLines()
- {
- PARSE(doc, ex8_5);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["strip"].to<std::string>() == "# text");
- YAML_ASSERT(doc["clip"].to<std::string>() == "# text\n");
- YAML_ASSERT(doc["keep"].to<std::string>() == "# text\n"); // Note: I believe this is a bug in the YAML spec - it should be "# text\n\n"
- return true;
- }
-
- // 8.6
- TEST EmptyScalarChomping()
- {
- PARSE(doc, ex8_6);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["strip"].to<std::string>() == "");
- YAML_ASSERT(doc["clip"].to<std::string>() == "");
- YAML_ASSERT(doc["keep"].to<std::string>() == "\n");
- return true;
- }
-
- // 8.7
- TEST LiteralScalar()
- {
- PARSE(doc, ex8_7);
- YAML_ASSERT(doc.to<std::string>() == "literal\n\ttext\n");
- return true;
- }
-
- // 8.8
- TEST LiteralContent()
- {
- PARSE(doc, ex8_8);
- YAML_ASSERT(doc.to<std::string>() == "\n\nliteral\n \n\ntext\n");
- return true;
- }
-
- // 8.9
- TEST FoldedScalar()
- {
- PARSE(doc, ex8_9);
- YAML_ASSERT(doc.to<std::string>() == "folded text\n");
- return true;
- }
-
- // 8.10
- TEST FoldedLines()
- {
- PARSE(doc, ex8_10);
- YAML_ASSERT(doc.to<std::string>() == "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n");
- return true;
- }
-
- // 8.11
- TEST MoreIndentedLines()
- {
- return true; // same as 8.10
- }
-
- // 8.12
- TEST EmptySeparationLines()
- {
- return true; // same as 8.10
- }
-
- // 8.13
- TEST FinalEmptyLines()
- {
- return true; // same as 8.10
- }
-
- // 8.14
- TEST BlockSequence()
- {
- PARSE(doc, ex8_14);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["block sequence"].size() == 2);
- YAML_ASSERT(doc["block sequence"][0].to<std::string>() == "one");
- YAML_ASSERT(doc["block sequence"][1].size() == 1);
- YAML_ASSERT(doc["block sequence"][1]["two"].to<std::string>() == "three");
- return true;
- }
-
- // 8.15
- TEST BlockSequenceEntryTypes()
- {
- PARSE(doc, ex8_15);
- YAML_ASSERT(doc.size() == 4);
- YAML_ASSERT(YAML::IsNull(doc[0]));
- YAML_ASSERT(doc[1].to<std::string>() == "block node\n");
- YAML_ASSERT(doc[2].size() == 2);
- YAML_ASSERT(doc[2][0].to<std::string>() == "one");
- YAML_ASSERT(doc[2][1].to<std::string>() == "two");
- YAML_ASSERT(doc[3].size() == 1);
- YAML_ASSERT(doc[3]["one"].to<std::string>() == "two");
- return true;
- }
-
- // 8.16
- TEST BlockMappings()
- {
- PARSE(doc, ex8_16);
- YAML_ASSERT(doc.size() == 1);
- YAML_ASSERT(doc["block mapping"].size() == 1);
- YAML_ASSERT(doc["block mapping"]["key"].to<std::string>() == "value");
- return true;
- }
-
- // 8.17
- TEST ExplicitBlockMappingEntries()
- {
- PARSE(doc, ex8_17);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(IsNull(doc["explicit key"]));
- YAML_ASSERT(doc["block key\n"].size() == 2);
- YAML_ASSERT(doc["block key\n"][0].to<std::string>() == "one");
- YAML_ASSERT(doc["block key\n"][1].to<std::string>() == "two");
- return true;
- }
-
- // 8.18
- TEST ImplicitBlockMappingEntries()
- {
- PARSE(doc, ex8_18);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc["plain key"].to<std::string>() == "in-line value");
- YAML_ASSERT(IsNull(doc[YAML::Null]));
- YAML_ASSERT(doc["quoted key"].size() == 1);
- YAML_ASSERT(doc["quoted key"][0].to<std::string>() == "entry");
- return true;
- }
-
- // 8.19
- TEST CompactBlockMappings()
- {
- PARSE(doc, ex8_19);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc[0].size() == 1);
- YAML_ASSERT(doc[0]["sun"].to<std::string>() == "yellow");
- YAML_ASSERT(doc[1].size() == 1);
- std::map<std::string, std::string> key;
- key["earth"] = "blue";
- YAML_ASSERT(doc[1][key].size() == 1);
- YAML_ASSERT(doc[1][key]["moon"].to<std::string>() == "white");
- return true;
- }
-
- // 8.20
- TEST BlockNodeTypes()
- {
- PARSE(doc, ex8_20);
- YAML_ASSERT(doc.size() == 3);
- YAML_ASSERT(doc[0].to<std::string>() == "flow in block");
- YAML_ASSERT(doc[1].to<std::string>() == "Block scalar\n");
- YAML_ASSERT(doc[2].size() == 1);
- YAML_ASSERT(doc[2]["foo"].to<std::string>() == "bar");
- return true;
- }
-
- // 8.21
- TEST BlockScalarNodes()
- {
- PARSE(doc, ex8_21);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["literal"].to<std::string>() == "value"); // Note: I believe this is a bug in the YAML spec - it should be "value\n"
- YAML_ASSERT(doc["folded"].to<std::string>() == "value");
- YAML_ASSERT(doc["folded"].Tag() == "!foo");
- return true;
- }
-
- // 8.22
- TEST BlockCollectionNodes()
- {
- PARSE(doc, ex8_22);
- YAML_ASSERT(doc.size() == 2);
- YAML_ASSERT(doc["sequence"].size() == 2);
- YAML_ASSERT(doc["sequence"][0].to<std::string>() == "entry");
- YAML_ASSERT(doc["sequence"][1].size() == 1);
- YAML_ASSERT(doc["sequence"][1][0].to<std::string>() == "nested");
- YAML_ASSERT(doc["mapping"].size() == 1);
- YAML_ASSERT(doc["mapping"]["foo"].to<std::string>() == "bar");
- return true;
- }
- }
-}
diff --git a/yaml-cpp/test/parsertests.h b/yaml-cpp/test/parsertests.h
deleted file mode 100755
index f3de1b8c..00000000
--- a/yaml-cpp/test/parsertests.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-#define PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
-#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
-#pragma once
-#endif
-
-namespace Test {
- bool RunParserTests();
-}
-
-#endif // PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
diff --git a/yaml-cpp/test/specexamples.h b/yaml-cpp/test/specexamples.h
deleted file mode 100755
index 4688bdcf..00000000
--- a/yaml-cpp/test/specexamples.h
+++ /dev/null
@@ -1,850 +0,0 @@
-namespace Test {
- namespace Spec {
- const char *ex2_1 =
- "- Mark McGwire\n"
- "- Sammy Sosa\n"
- "- Ken Griffey";
-
- const char *ex2_2 =
- "hr: 65 # Home runs\n"
- "avg: 0.278 # Batting average\n"
- "rbi: 147 # Runs Batted In";
-
- const char *ex2_3 =
- "american:\n"
- "- Boston Red Sox\n"
- "- Detroit Tigers\n"
- "- New York Yankees\n"
- "national:\n"
- "- New York Mets\n"
- "- Chicago Cubs\n"
- "- Atlanta Braves";
-
- const char *ex2_4 =
- "-\n"
- " name: Mark McGwire\n"
- " hr: 65\n"
- " avg: 0.278\n"
- "-\n"
- " name: Sammy Sosa\n"
- " hr: 63\n"
- " avg: 0.288";
-
- const char *ex2_5 =
- "- [name , hr, avg ]\n"
- "- [Mark McGwire, 65, 0.278]\n"
- "- [Sammy Sosa , 63, 0.288]";
-
- const char *ex2_6 =
- "Mark McGwire: {hr: 65, avg: 0.278}\n"
- "Sammy Sosa: {\n"
- " hr: 63,\n"
- " avg: 0.288\n"
- " }";
-
- const char *ex2_7 =
- "# Ranking of 1998 home runs\n"
- "---\n"
- "- Mark McGwire\n"
- "- Sammy Sosa\n"
- "- Ken Griffey\n"
- "\n"
- "# Team ranking\n"
- "---\n"
- "- Chicago Cubs\n"
- "- St Louis Cardinals";
-
- const char *ex2_8 =
- "---\n"
- "time: 20:03:20\n"
- "player: Sammy Sosa\n"
- "action: strike (miss)\n"
- "...\n"
- "---\n"
- "time: 20:03:47\n"
- "player: Sammy Sosa\n"
- "action: grand slam\n"
- "...";
-
- const char *ex2_9 =
- "---\n"
- "hr: # 1998 hr ranking\n"
- " - Mark McGwire\n"
- " - Sammy Sosa\n"
- "rbi:\n"
- " # 1998 rbi ranking\n"
- " - Sammy Sosa\n"
- " - Ken Griffey";
-
- const char *ex2_10 =
- "---\n"
- "hr:\n"
- " - Mark McGwire\n"
- " # Following node labeled SS\n"
- " - &SS Sammy Sosa\n"
- "rbi:\n"
- " - *SS # Subsequent occurrence\n"
- " - Ken Griffey";
-
- const char *ex2_11 =
- "? - Detroit Tigers\n"
- " - Chicago cubs\n"
- ":\n"
- " - 2001-07-23\n"
- "\n"
- "? [ New York Yankees,\n"
- " Atlanta Braves ]\n"
- ": [ 2001-07-02, 2001-08-12,\n"
- " 2001-08-14 ]";
-
- const char *ex2_12 =
- "---\n"
- "# Products purchased\n"
- "- item : Super Hoop\n"
- " quantity: 1\n"
- "- item : Basketball\n"
- " quantity: 4\n"
- "- item : Big Shoes\n"
- " quantity: 1";
-
- const char *ex2_13 =
- "# ASCII Art\n"
- "--- |\n"
- " \\//||\\/||\n"
- " // || ||__";
-
- const char *ex2_14 =
- "--- >\n"
- " Mark McGwire's\n"
- " year was crippled\n"
- " by a knee injury.";
-
- const char *ex2_15 =
- ">\n"
- " Sammy Sosa completed another\n"
- " fine season with great stats.\n"
- " \n"
- " 63 Home Runs\n"
- " 0.288 Batting Average\n"
- " \n"
- " What a year!";
-
- const char *ex2_16 =
- "name: Mark McGwire\n"
- "accomplishment: >\n"
- " Mark set a major league\n"
- " home run record in 1998.\n"
- "stats: |\n"
- " 65 Home Runs\n"
- " 0.278 Batting Average\n";
-
- const char *ex2_17 =
- "unicode: \"Sosa did fine.\\u263A\"\n"
- "control: \"\\b1998\\t1999\\t2000\\n\"\n"
- "hex esc: \"\\x0d\\x0a is \\r\\n\"\n"
- "\n"
- "single: '\"Howdy!\" he cried.'\n"
- "quoted: ' # Not a ''comment''.'\n"
- "tie-fighter: '|\\-*-/|'";
-
- const char *ex2_18 =
- "plain:\n"
- " This unquoted scalar\n"
- " spans many lines.\n"
- "\n"
- "quoted: \"So does this\n"
- " quoted scalar.\\n\"";
-
- // TODO: 2.19 - 2.22 schema tags
-
- const char *ex2_23 =
- "---\n"
- "not-date: !!str 2002-04-28\n"
- "\n"
- "picture: !!binary |\n"
- " R0lGODlhDAAMAIQAAP//9/X\n"
- " 17unp5WZmZgAAAOfn515eXv\n"
- " Pz7Y6OjuDg4J+fn5OTk6enp\n"
- " 56enmleECcgggoBADs=\n"
- "\n"
- "application specific tag: !something |\n"
- " The semantics of the tag\n"
- " above may be different for\n"
- " different documents.";
-
- const char *ex2_24 =
- "%TAG ! tag:clarkevans.com,2002:\n"
- "--- !shape\n"
- " # Use the ! handle for presenting\n"
- " # tag:clarkevans.com,2002:circle\n"
- "- !circle\n"
- " center: &ORIGIN {x: 73, y: 129}\n"
- " radius: 7\n"
- "- !line\n"
- " start: *ORIGIN\n"
- " finish: { x: 89, y: 102 }\n"
- "- !label\n"
- " start: *ORIGIN\n"
- " color: 0xFFEEBB\n"
- " text: Pretty vector drawing.";
-
- const char *ex2_25 =
- "# Sets are represented as a\n"
- "# Mapping where each key is\n"
- "# associated with a null value\n"
- "--- !!set\n"
- "? Mark McGwire\n"
- "? Sammy Sosa\n"
- "? Ken Griffey";
-
- const char *ex2_26 =
- "# Ordered maps are represented as\n"
- "# A sequence of mappings, with\n"
- "# each mapping having one key\n"
- "--- !!omap\n"
- "- Mark McGwire: 65\n"
- "- Sammy Sosa: 63\n"
- "- Ken Griffey: 58";
-
- const char *ex2_27 =
- "--- !<tag:clarkevans.com,2002:invoice>\n"
- "invoice: 34843\n"
- "date : 2001-01-23\n"
- "bill-to: &id001\n"
- " given : Chris\n"
- " family : Dumars\n"
- " address:\n"
- " lines: |\n"
- " 458 Walkman Dr.\n"
- " Suite #292\n"
- " city : Royal Oak\n"
- " state : MI\n"
- " postal : 48046\n"
- "ship-to: *id001\n"
- "product:\n"
- " - sku : BL394D\n"
- " quantity : 4\n"
- " description : Basketball\n"
- " price : 450.00\n"
- " - sku : BL4438H\n"
- " quantity : 1\n"
- " description : Super Hoop\n"
- " price : 2392.00\n"
- "tax : 251.42\n"
- "total: 4443.52\n"
- "comments:\n"
- " Late afternoon is best.\n"
- " Backup contact is Nancy\n"
- " Billsmer @ 338-4338.";
-
- const char *ex2_28 =
- "---\n"
- "Time: 2001-11-23 15:01:42 -5\n"
- "User: ed\n"
- "Warning:\n"
- " This is an error message\n"
- " for the log file\n"
- "---\n"
- "Time: 2001-11-23 15:02:31 -5\n"
- "User: ed\n"
- "Warning:\n"
- " A slightly different error\n"
- " message.\n"
- "---\n"
- "Date: 2001-11-23 15:03:17 -5\n"
- "User: ed\n"
- "Fatal:\n"
- " Unknown variable \"bar\"\n"
- "Stack:\n"
- " - file: TopClass.py\n"
- " line: 23\n"
- " code: |\n"
- " x = MoreObject(\"345\\n\")\n"
- " - file: MoreClass.py\n"
- " line: 58\n"
- " code: |-\n"
- " foo = bar";
-
- // TODO: 5.1 - 5.2 BOM
-
- const char *ex5_3 =
- "sequence:\n"
- "- one\n"
- "- two\n"
- "mapping:\n"
- " ? sky\n"
- " : blue\n"
- " sea : green";
-
- const char *ex5_4 =
- "sequence: [ one, two, ]\n"
- "mapping: { sky: blue, sea: green }";
-
- const char *ex5_5 =
- "# Comment only.";
-
- const char *ex5_6 =
- "anchored: !local &anchor value\n"
- "alias: *anchor";
-
- const char *ex5_7 =
- "literal: |\n"
- " some\n"
- " text\n"
- "folded: >\n"
- " some\n"
- " text\n";
-
- const char *ex5_8 =
- "single: 'text'\n"
- "double: \"text\"";
-
- // TODO: 5.9 directive
- // TODO: 5.10 reserved indicator
-
- const char *ex5_11 =
- "|\n"
- " Line break (no glyph)\n"
- " Line break (glyphed)\n";
-
- const char *ex5_12 =
- "# Tabs and spaces\n"
- "quoted: \"Quoted\t\"\n"
- "block: |\n"
- " void main() {\n"
- " \tprintf(\"Hello, world!\\n\");\n"
- " }";
-
- const char *ex5_13 =
- "\"Fun with \\\\\n"
- "\\\" \\a \\b \\e \\f \\\n"
- "\\n \\r \\t \\v \\0 \\\n"
- "\\ \\_ \\N \\L \\P \\\n"
- "\\x41 \\u0041 \\U00000041\"";
-
- const char *ex5_14 =
- "Bad escapes:\n"
- " \"\\c\n"
- " \\xq-\"";
-
- const char *ex6_1 =
- " # Leading comment line spaces are\n"
- " # neither content nor indentation.\n"
- " \n"
- "Not indented:\n"
- " By one space: |\n"
- " By four\n"
- " spaces\n"
- " Flow style: [ # Leading spaces\n"
- " By two, # in flow style\n"
- " Also by two, # are neither\n"
- " \tStill by two # content nor\n"
- " ] # indentation.";
-
- const char *ex6_2 =
- "? a\n"
- ": -\tb\n"
- " - -\tc\n"
- " - d";
-
- const char *ex6_3 =
- "- foo:\t bar\n"
- "- - baz\n"
- " -\tbaz";
-
- const char *ex6_4 =
- "plain: text\n"
- " lines\n"
- "quoted: \"text\n"
- " \tlines\"\n"
- "block: |\n"
- " text\n"
- " \tlines\n";
-
- const char *ex6_5 =
- "Folding:\n"
- " \"Empty line\n"
- " \t\n"
- " as a line feed\"\n"
- "Chomping: |\n"
- " Clipped empty lines\n"
- " ";
-
- const char *ex6_6 =
- ">-\n"
- " trimmed\n"
- " \n"
- " \n"
- "\n"
- " as\n"
- " space";
-
- const char *ex6_7 =
- ">\n"
- " foo \n"
- " \n"
- " \t bar\n"
- "\n"
- " baz\n";
-
- const char *ex6_8 =
- "\"\n"
- " foo \n"
- " \n"
- " \t bar\n"
- "\n"
- " baz\n"
- "\"";
-
- const char *ex6_9 =
- "key: # Comment\n"
- " value";
-
- const char *ex6_10 =
- " # Comment\n"
- " \n"
- "\n";
-
- const char *ex6_11 =
- "key: # Comment\n"
- " # lines\n"
- " value\n"
- "\n";
-
- const char *ex6_12 =
- "{ first: Sammy, last: Sosa }:\n"
- "# Statistics:\n"
- " hr: # Home runs\n"
- " 65\n"
- " avg: # Average\n"
- " 0.278";
-
- const char *ex6_13 =
- "%FOO bar baz # Should be ignored\n"
- " # with a warning.\n"
- "--- \"foo\"";
-
- const char *ex6_14 =
- "%YAML 1.3 # Attempt parsing\n"
- " # with a warning\n"
- "---\n"
- "\"foo\"";
-
- const char *ex6_15 =
- "%YAML 1.2\n"
- "%YAML 1.1\n"
- "foo";
-
- const char *ex6_16 =
- "%TAG !yaml! tag:yaml.org,2002:\n"
- "---\n"
- "!yaml!str \"foo\"";
-
- const char *ex6_17 =
- "%TAG ! !foo\n"
- "%TAG ! !foo\n"
- "bar";
-
- const char *ex6_18 =
- "# Private\n"
- "!foo \"bar\"\n"
- "...\n"
- "# Global\n"
- "%TAG ! tag:example.com,2000:app/\n"
- "---\n"
- "!foo \"bar\"";
-
- const char *ex6_19 =
- "%TAG !! tag:example.com,2000:app/\n"
- "---\n"
- "!!int 1 - 3 # Interval, not integer";
-
- const char *ex6_20 =
- "%TAG !e! tag:example.com,2000:app/\n"
- "---\n"
- "!e!foo \"bar\"";
-
- const char *ex6_21 =
- "%TAG !m! !my-\n"
- "--- # Bulb here\n"
- "!m!light fluorescent\n"
- "...\n"
- "%TAG !m! !my-\n"
- "--- # Color here\n"
- "!m!light green";
-
- const char *ex6_22 =
- "%TAG !e! tag:example.com,2000:app/\n"
- "---\n"
- "- !e!foo \"bar\"";
-
- const char *ex6_23 =
- "!!str &a1 \"foo\":\n"
- " !!str bar\n"
- "&a2 baz : *a1";
-
- const char *ex6_24 =
- "!<tag:yaml.org,2002:str> foo :\n"
- " !<!bar> baz";
-
- const char *ex6_25 =
- "- !<!> foo\n"
- "- !<$:?> bar\n";
-
- const char *ex6_26 =
- "%TAG !e! tag:example.com,2000:app/\n"
- "---\n"
- "- !local foo\n"
- "- !!str bar\n"
- "- !e!tag%21 baz\n";
-
- const char *ex6_27a =
- "%TAG !e! tag:example,2000:app/\n"
- "---\n"
- "- !e! foo";
-
- const char *ex6_27b =
- "%TAG !e! tag:example,2000:app/\n"
- "---\n"
- "- !h!bar baz";
-
- const char *ex6_28 =
- "# Assuming conventional resolution:\n"
- "- \"12\"\n"
- "- 12\n"
- "- ! 12";
-
- const char *ex6_29 =
- "First occurrence: &anchor Value\n"
- "Second occurrence: *anchor";
-
- const char *ex7_1 =
- "First occurrence: &anchor Foo\n"
- "Second occurrence: *anchor\n"
- "Override anchor: &anchor Bar\n"
- "Reuse anchor: *anchor";
-
- const char *ex7_2 =
- "{\n"
- " foo : !!str,\n"
- " !!str : bar,\n"
- "}";
-
- const char *ex7_3 =
- "{\n"
- " ? foo :,\n"
- " : bar,\n"
- "}\n";
-
- const char *ex7_4 =
- "\"implicit block key\" : [\n"
- " \"implicit flow key\" : value,\n"
- " ]";
-
- const char *ex7_5 =
- "\"folded \n"
- "to a space,\t\n"
- " \n"
- "to a line feed, or \t\\\n"
- " \\ \tnon-content\"";
-
- const char *ex7_6 =
- "\" 1st non-empty\n"
- "\n"
- " 2nd non-empty \n"
- "\t3rd non-empty \"";
-
- const char *ex7_7 =
- " 'here''s to \"quotes\"'";
-
- const char *ex7_8 =
- "'implicit block key' : [\n"
- " 'implicit flow key' : value,\n"
- " ]";
-
- const char *ex7_9 =
- "' 1st non-empty\n"
- "\n"
- " 2nd non-empty \n"
- "\t3rd non-empty '";
-
- const char *ex7_10 =
- "# Outside flow collection:\n"
- "- ::vector\n"
- "- \": - ()\"\n"
- "- Up, up, and away!\n"
- "- -123\n"
- "- http://example.com/foo#bar\n"
- "# Inside flow collection:\n"
- "- [ ::vector,\n"
- " \": - ()\",\n"
- " \"Up, up, and away!\",\n"
- " -123,\n"
- " http://example.com/foo#bar ]";
-
- const char *ex7_11 =
- "implicit block key : [\n"
- " implicit flow key : value,\n"
- " ]";
-
- const char *ex7_12 =
- "1st non-empty\n"
- "\n"
- " 2nd non-empty \n"
- "\t3rd non-empty";
-
- const char *ex7_13 =
- "- [ one, two, ]\n"
- "- [three ,four]";
-
- const char *ex7_14 =
- "[\n"
- "\"double\n"
- " quoted\", 'single\n"
- " quoted',\n"
- "plain\n"
- " text, [ nested ],\n"
- "single: pair,\n"
- "]";
-
- const char *ex7_15 =
- "- { one : two , three: four , }\n"
- "- {five: six,seven : eight}";
-
- const char *ex7_16 =
- "{\n"
- "? explicit: entry,\n"
- "implicit: entry,\n"
- "?\n"
- "}";
-
- const char *ex7_17 =
- "{\n"
- "unquoted : \"separate\",\n"
- "http://foo.com,\n"
- "omitted value:,\n"
- ": omitted key,\n"
- "}";
-
- const char *ex7_18 =
- "{\n"
- "\"adjacent\":value,\n"
- "\"readable\":value,\n"
- "\"empty\":\n"
- "}";
-
- const char *ex7_19 =
- "[\n"
- "foo: bar\n"
- "]";
-
- const char *ex7_20 =
- "[\n"
- "? foo\n"
- " bar : baz\n"
- "]";
-
- const char *ex7_21 =
- "- [ YAML : separate ]\n"
- "- [ : empty key entry ]\n"
- "- [ {JSON: like}:adjacent ]";
-
- const char *ex7_22 =
- "[ foo\n"
- " bar: invalid,"; // Note: we don't check (on purpose) the >1K chars for an implicit key
-
- const char *ex7_23 =
- "- [ a, b ]\n"
- "- { a: b }\n"
- "- \"a\"\n"
- "- 'b'\n"
- "- c";
-
- const char *ex7_24 =
- "- !!str \"a\"\n"
- "- 'b'\n"
- "- &anchor \"c\"\n"
- "- *anchor\n"
- "- !!str";
-
- const char *ex8_1 =
- "- | # Empty header\n"
- " literal\n"
- "- >1 # Indentation indicator\n"
- " folded\n"
- "- |+ # Chomping indicator\n"
- " keep\n"
- "\n"
- "- >1- # Both indicators\n"
- " strip\n";
-
- const char *ex8_2 =
- "- |\n"
- " detected\n"
- "- >\n"
- " \n"
- " \n"
- " # detected\n"
- "- |1\n"
- " explicit\n"
- "- >\n"
- " \t\n"
- " detected\n";
-
- const char *ex8_3a =
- "- |\n"
- " \n"
- " text";
-
- const char *ex8_3b =
- "- >\n"
- " text\n"
- " text";
-
- const char *ex8_3c =
- "- |2\n"
- " text";
-
- const char *ex8_4 =
- "strip: |-\n"
- " text\n"
- "clip: |\n"
- " text\n"
- "keep: |+\n"
- " text\n";
-
- const char *ex8_5 =
- " # Strip\n"
- " # Comments:\n"
- "strip: |-\n"
- " # text\n"
- " \n"
- " # Clip\n"
- " # comments:\n"
- "\n"
- "clip: |\n"
- " # text\n"
- " \n"
- " # Keep\n"
- " # comments:\n"
- "\n"
- "keep: |+\n"
- " # text\n"
- "\n"
- " # Trail\n"
- " # Comments\n";
-
- const char *ex8_6 =
- "strip: >-\n"
- "\n"
- "clip: >\n"
- "\n"
- "keep: |+\n"
- "\n";
-
- const char *ex8_7 =
- "|\n"
- " literal\n"
- " \ttext\n"
- "\n";
-
- const char *ex8_8 =
- "|\n"
- " \n"
- " \n"
- " literal\n"
- " \n"
- " \n"
- " text\n"
- "\n"
- " # Comment\n";
-
- const char *ex8_9 =
- ">\n"
- " folded\n"
- " text\n"
- "\n";
-
- const char *ex8_10 =
- ">\n"
- "\n"
- " folded\n"
- " line\n"
- "\n"
- " next\n"
- " line\n"
- " * bullet\n"
- "\n"
- " * list\n"
- " * lines\n"
- "\n"
- " last\n"
- " line\n"
- "\n"
- "# Comment\n";
-
- const char *ex8_11 = ex8_10;
- const char *ex8_12 = ex8_10;
- const char *ex8_13 = ex8_10;
-
- const char *ex8_14 =
- "block sequence:\n"
- " - one\n"
- " - two : three\n";
-
- const char *ex8_15 =
- "- # Empty\n"
- "- |\n"
- " block node\n"
- "- - one # Compact\n"
- " - two # sequence\n"
- "- one: two # Compact mapping\n";
-
- const char *ex8_16 =
- "block mapping:\n"
- " key: value\n";
-
- const char *ex8_17 =
- "? explicit key # Empty value\n"
- "? |\n"
- " block key\n"
- ": - one # Explicit compact\n"
- " - two # block value\n";
-
- const char *ex8_18 =
- "plain key: in-line value\n"
- ": # Both empty\n"
- "\"quoted key\":\n"
- "- entry\n";
-
- const char *ex8_19 =
- "- sun: yellow\n"
- "- ? earth: blue\n"
- " : moon: white\n";
-
- const char *ex8_20 =
- "-\n"
- " \"flow in block\"\n"
- "- >\n"
- " Block scalar\n"
- "- !!map # Block collection\n"
- " foo : bar\n";
-
- const char *ex8_21 =
- "literal: |2\n"
- " value\n"
- "folded:\n"
- " !foo\n"
- " >1\n"
- " value\n";
-
- const char *ex8_22 =
- "sequence: !!seq\n"
- "- entry\n"
- "- !!seq\n"
- " - nested\n"
- "mapping: !!map\n"
- " foo: bar\n";
- }
-}
-
diff --git a/yaml-cpp/test/spectests.cpp b/yaml-cpp/test/spectests.cpp
deleted file mode 100755
index bffc5062..00000000
--- a/yaml-cpp/test/spectests.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-#include "spectests.h"
-#include "yaml-cpp/yaml.h"
-#include <iostream>
-
-namespace Test
-{
- namespace {
- void RunSpecTest(TEST (*test)(), const std::string& index, const std::string& name, int& passed, int& total) {
- TEST ret;
- try {
- ret = test();
- } catch(const YAML::Exception& e) {
- ret.ok = false;
- ret.error = std::string(" Exception caught: ") + e.what();
- }
-
- if(!ret.ok) {
- std::cout << "Spec test " << index << " failed: " << name << "\n";
- std::cout << ret.error << "\n";
- }
-
- if(ret.ok)
- passed++;
- total++;
- }
- }
-
- bool RunSpecTests()
- {
- int passed = 0;
- int total = 0;
- RunSpecTest(&Spec::SeqScalars, "2.1", "Sequence of Scalars", passed, total);
- RunSpecTest(&Spec::MappingScalarsToScalars, "2.2", "Mapping Scalars to Scalars", passed, total);
- RunSpecTest(&Spec::MappingScalarsToSequences, "2.3", "Mapping Scalars to Sequences", passed, total);
- RunSpecTest(&Spec::SequenceOfMappings, "2.4", "Sequence of Mappings", passed, total);
- RunSpecTest(&Spec::SequenceOfSequences, "2.5", "Sequence of Sequences", passed, total);
- RunSpecTest(&Spec::MappingOfMappings, "2.6", "Mapping of Mappings", passed, total);
- RunSpecTest(&Spec::TwoDocumentsInAStream, "2.7", "Two Documents in a Stream", passed, total);
- RunSpecTest(&Spec::PlayByPlayFeed, "2.8", "Play by Play Feed from a Game", passed, total);
- RunSpecTest(&Spec::SingleDocumentWithTwoComments, "2.9", "Single Document with Two Comments", passed, total);
- RunSpecTest(&Spec::SimpleAnchor, "2.10", "Node for \"Sammy Sosa\" appears twice in this document", passed, total);
- RunSpecTest(&Spec::MappingBetweenSequences, "2.11", "Mapping between Sequences", passed, total);
- RunSpecTest(&Spec::CompactNestedMapping, "2.12", "Compact Nested Mapping", passed, total);
- RunSpecTest(&Spec::InLiteralsNewlinesArePreserved, "2.13", "In literals, newlines are preserved", passed, total);
- RunSpecTest(&Spec::InFoldedScalarsNewlinesBecomeSpaces, "2.14", "In folded scalars, newlines become spaces", passed, total);
- RunSpecTest(&Spec::FoldedNewlinesArePreservedForMoreIndentedAndBlankLines, "2.15", "Folded newlines are preserved for \"more indented\" and blank lines", passed, total);
- RunSpecTest(&Spec::IndentationDeterminesScope, "2.16", "Indentation determines scope", passed, total);
- RunSpecTest(&Spec::QuotedScalars, "2.17", "Quoted scalars", passed, total);
- RunSpecTest(&Spec::MultiLineFlowScalars, "2.18", "Multi-line flow scalars", passed, total);
-
- RunSpecTest(&Spec::VariousExplicitTags, "2.23", "Various Explicit Tags", passed, total);
- RunSpecTest(&Spec::GlobalTags, "2.24", "Global Tags", passed, total);
- RunSpecTest(&Spec::UnorderedSets, "2.25", "Unordered Sets", passed, total);
- RunSpecTest(&Spec::OrderedMappings, "2.26", "Ordered Mappings", passed, total);
- RunSpecTest(&Spec::Invoice, "2.27", "Invoice", passed, total);
- RunSpecTest(&Spec::LogFile, "2.28", "Log File", passed, total);
-
- RunSpecTest(&Spec::BlockStructureIndicators, "5.3", "Block Structure Indicators", passed, total);
- RunSpecTest(&Spec::FlowStructureIndicators, "5.4", "Flow Structure Indicators", passed, total);
- RunSpecTest(&Spec::NodePropertyIndicators, "5.6", "Node Property Indicators", passed, total);
- RunSpecTest(&Spec::BlockScalarIndicators, "5.7", "Block Scalar Indicators", passed, total);
- RunSpecTest(&Spec::QuotedScalarIndicators, "5.8", "Quoted Scalar Indicators", passed, total);
- RunSpecTest(&Spec::LineBreakCharacters, "5.11", "Line Break Characters", passed, total);
- RunSpecTest(&Spec::TabsAndSpaces, "5.12", "Tabs and Spaces", passed, total);
- RunSpecTest(&Spec::EscapedCharacters, "5.13", "Escaped Characters", passed, total);
- RunSpecTest(&Spec::InvalidEscapedCharacters, "5.14", "Invalid Escaped Characters", passed, total);
-
- RunSpecTest(&Spec::IndentationSpaces, "6.1", "Indentation Spaces", passed, total);
- RunSpecTest(&Spec::IndentationIndicators, "6.2", "Indentation Indicators", passed, total);
- RunSpecTest(&Spec::SeparationSpaces, "6.3", "Separation Spaces", passed, total);
- RunSpecTest(&Spec::LinePrefixes, "6.4", "Line Prefixes", passed, total);
- RunSpecTest(&Spec::EmptyLines, "6.5", "Empty Lines", passed, total);
- RunSpecTest(&Spec::LineFolding, "6.6", "Line Folding", passed, total);
- RunSpecTest(&Spec::BlockFolding, "6.7", "Block Folding", passed, total);
- RunSpecTest(&Spec::FlowFolding, "6.8", "Flow Folding", passed, total);
- RunSpecTest(&Spec::SeparatedComment, "6.9", "Separated Comment", passed, total);
- RunSpecTest(&Spec::CommentLines, "6.10", "Comment Lines", passed, total);
- RunSpecTest(&Spec::MultiLineComments, "6.11", "Multi-Line Comments", passed, total);
- RunSpecTest(&Spec::SeparationSpacesII, "6.12", "Separation Spaces", passed, total);
- RunSpecTest(&Spec::ReservedDirectives, "6.13", "Reserved Directives", passed, total);
- RunSpecTest(&Spec::YAMLDirective, "6.14", "YAML Directive", passed, total);
- RunSpecTest(&Spec::InvalidRepeatedYAMLDirective, "6.15", "Invalid Repeated YAML Directive", passed, total);
- RunSpecTest(&Spec::TagDirective, "6.16", "Tag Directive", passed, total);
- RunSpecTest(&Spec::InvalidRepeatedTagDirective, "6.17", "Invalid Repeated Tag Directive", passed, total);
- RunSpecTest(&Spec::PrimaryTagHandle, "6.18", "Primary Tag Handle", passed, total);
- RunSpecTest(&Spec::SecondaryTagHandle, "6.19", "SecondaryTagHandle", passed, total);
- RunSpecTest(&Spec::TagHandles, "6.20", "TagHandles", passed, total);
- RunSpecTest(&Spec::LocalTagPrefix, "6.21", "LocalTagPrefix", passed, total);
- RunSpecTest(&Spec::GlobalTagPrefix, "6.22", "GlobalTagPrefix", passed, total);
- RunSpecTest(&Spec::NodeProperties, "6.23", "NodeProperties", passed, total);
- RunSpecTest(&Spec::VerbatimTags, "6.24", "Verbatim Tags", passed, total);
- RunSpecTest(&Spec::InvalidVerbatimTags, "6.25", "Invalid Verbatim Tags", passed, total);
- RunSpecTest(&Spec::TagShorthands, "6.26", "Tag Shorthands", passed, total);
- RunSpecTest(&Spec::InvalidTagShorthands, "6.27", "Invalid Tag Shorthands", passed, total);
- RunSpecTest(&Spec::NonSpecificTags, "6.28", "Non Specific Tags", passed, total);
- RunSpecTest(&Spec::NodeAnchors, "6.29", "Node Anchors", passed, total);
-
- RunSpecTest(&Spec::AliasNodes, "7.1", "Alias Nodes", passed, total);
- RunSpecTest(&Spec::EmptyNodes, "7.2", "Empty Nodes", passed, total);
- RunSpecTest(&Spec::CompletelyEmptyNodes, "7.3", "Completely Empty Nodes", passed, total);
- RunSpecTest(&Spec::DoubleQuotedImplicitKeys, "7.4", "Double Quoted Implicit Keys", passed, total);
- RunSpecTest(&Spec::DoubleQuotedLineBreaks, "7.5", "Double Quoted Line Breaks", passed, total);
- RunSpecTest(&Spec::DoubleQuotedLines, "7.6", "Double Quoted Lines", passed, total);
- RunSpecTest(&Spec::SingleQuotedCharacters, "7.7", "Single Quoted Characters", passed, total);
- RunSpecTest(&Spec::SingleQuotedImplicitKeys, "7.8", "Single Quoted Implicit Keys", passed, total);
- RunSpecTest(&Spec::SingleQuotedLines, "7.9", "Single Quoted Lines", passed, total);
- RunSpecTest(&Spec::PlainCharacters, "7.10", "Plain Characters", passed, total);
- RunSpecTest(&Spec::PlainImplicitKeys, "7.11", "Plain Implicit Keys", passed, total);
- RunSpecTest(&Spec::PlainLines, "7.12", "Plain Lines", passed, total);
- RunSpecTest(&Spec::FlowSequence, "7.13", "Flow Sequence", passed, total);
- RunSpecTest(&Spec::FlowSequenceEntries, "7.14", "Flow Sequence Entries", passed, total);
- RunSpecTest(&Spec::FlowMappings, "7.15", "Flow Mappings", passed, total);
- RunSpecTest(&Spec::FlowMappingEntries, "7.16", "Flow Mapping Entries", passed, total);
- RunSpecTest(&Spec::FlowMappingSeparateValues, "7.17", "Flow Mapping Separate Values", passed, total);
- RunSpecTest(&Spec::FlowMappingAdjacentValues, "7.18", "Flow Mapping Adjacent Values", passed, total);
- RunSpecTest(&Spec::SinglePairFlowMappings, "7.19", "Single Pair Flow Mappings", passed, total);
- RunSpecTest(&Spec::SinglePairExplicitEntry, "7.20", "Single Pair Explicit Entry", passed, total);
- RunSpecTest(&Spec::SinglePairImplicitEntries, "7.21", "Single Pair Implicit Entries", passed, total);
- RunSpecTest(&Spec::InvalidImplicitKeys, "7.22", "Invalid Implicit Keys", passed, total);
- RunSpecTest(&Spec::FlowContent, "7.23", "Flow Content", passed, total);
- RunSpecTest(&Spec::FlowNodes, "7.24", "FlowNodes", passed, total);
-
- RunSpecTest(&Spec::BlockScalarHeader, "8.1", "Block Scalar Header", passed, total);
- RunSpecTest(&Spec::BlockIndentationHeader, "8.2", "Block Indentation Header", passed, total);
- RunSpecTest(&Spec::InvalidBlockScalarIndentationIndicators, "8.3", "Invalid Block Scalar Indentation Indicators", passed, total);
- RunSpecTest(&Spec::ChompingFinalLineBreak, "8.4", "Chomping Final Line Break", passed, total);
- RunSpecTest(&Spec::ChompingTrailingLines, "8.5", "Chomping Trailing Lines", passed, total);
- RunSpecTest(&Spec::EmptyScalarChomping, "8.6", "Empty Scalar Chomping", passed, total);
- RunSpecTest(&Spec::LiteralScalar, "8.7", "Literal Scalar", passed, total);
- RunSpecTest(&Spec::LiteralContent, "8.8", "Literal Content", passed, total);
- RunSpecTest(&Spec::FoldedScalar, "8.9", "Folded Scalar", passed, total);
- RunSpecTest(&Spec::FoldedLines, "8.10", "Folded Lines", passed, total);
- RunSpecTest(&Spec::MoreIndentedLines, "8.11", "More Indented Lines", passed, total);
- RunSpecTest(&Spec::EmptySeparationLines, "8.12", "Empty Separation Lines", passed, total);
- RunSpecTest(&Spec::FinalEmptyLines, "8.13", "Final Empty Lines", passed, total);
- RunSpecTest(&Spec::BlockSequence, "8.14", "Block Sequence", passed, total);
- RunSpecTest(&Spec::BlockSequenceEntryTypes, "8.15", "Block Sequence Entry Types", passed, total);
- RunSpecTest(&Spec::BlockMappings, "8.16", "Block Mappings", passed, total);
- RunSpecTest(&Spec::ExplicitBlockMappingEntries, "8.17", "Explicit Block Mapping Entries", passed, total);
- RunSpecTest(&Spec::ImplicitBlockMappingEntries, "8.18", "Implicit Block Mapping Entries", passed, total);
- RunSpecTest(&Spec::CompactBlockMappings, "8.19", "Compact Block Mappings", passed, total);
- RunSpecTest(&Spec::BlockNodeTypes, "8.20", "Block Node Types", passed, total);
- RunSpecTest(&Spec::BlockScalarNodes, "8.21", "Block Scalar Nodes", passed, total);
- RunSpecTest(&Spec::BlockCollectionNodes, "8.22", "Block Collection Nodes", passed, total);
-
- std::cout << "Spec tests: " << passed << "/" << total << " passed\n";
- return passed == total;
- }
-}
diff --git a/yaml-cpp/test/spectests.h b/yaml-cpp/test/spectests.h
deleted file mode 100755
index 5246df58..00000000
--- a/yaml-cpp/test/spectests.h
+++ /dev/null
@@ -1,360 +0,0 @@
-#ifndef SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-#define SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
-#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
-#pragma once
-#endif
-
-#include <string>
-
-namespace Test {
- struct TEST {
- TEST(): ok(false) {}
- TEST(bool ok_): ok(ok_) {}
- TEST(const char *error_): ok(false), error(error_) {}
-
- bool ok;
- std::string error;
- };
-
- namespace Spec {
- // 2.1
- TEST SeqScalars();
-
- // 2.2
- TEST MappingScalarsToScalars();
-
- // 2.3
- TEST MappingScalarsToSequences();
-
- // 2.4
- TEST SequenceOfMappings();
-
- // 2.5
- TEST SequenceOfSequences();
-
- // 2.6
- TEST MappingOfMappings();
-
- // 2.7
- TEST TwoDocumentsInAStream();
-
- // 2.8
- TEST PlayByPlayFeed();
-
- // 2.9
- TEST SingleDocumentWithTwoComments();
-
- // 2.10
- TEST SimpleAnchor();
-
- // 2.11
- TEST MappingBetweenSequences();
-
- // 2.12
- TEST CompactNestedMapping();
-
- // 2.13
- TEST InLiteralsNewlinesArePreserved();
-
- // 2.14
- TEST InFoldedScalarsNewlinesBecomeSpaces();
-
- // 2.15
- TEST FoldedNewlinesArePreservedForMoreIndentedAndBlankLines();
-
- // 2.16
- TEST IndentationDeterminesScope();
-
- // 2.17
- TEST QuotedScalars();
-
- // 2.18
- TEST MultiLineFlowScalars();
-
- // TODO: 2.19 - 2.22 schema tags
-
- // 2.23
- TEST VariousExplicitTags();
-
- // 2.24
- TEST GlobalTags();
-
- // 2.25
- TEST UnorderedSets();
-
- // 2.26
- TEST OrderedMappings();
-
- // 2.27
- TEST Invoice();
-
- // 2.28
- TEST LogFile();
-
- // TODO: 5.1 - 5.2 BOM
-
- // 5.3
- TEST BlockStructureIndicators();
-
- // 5.4
- TEST FlowStructureIndicators();
-
- // 5.5
- TEST CommentIndicator();
-
- // 5.6
- TEST NodePropertyIndicators();
-
- // 5.7
- TEST BlockScalarIndicators();
-
- // 5.8
- TEST QuotedScalarIndicators();
-
- // TODO: 5.9 directive
- // TODO: 5.10 reserved indicator
-
- // 5.11
- TEST LineBreakCharacters();
-
- // 5.12
- TEST TabsAndSpaces();
-
- // 5.13
- TEST EscapedCharacters();
-
- // 5.14
- TEST InvalidEscapedCharacters();
-
- // 6.1
- TEST IndentationSpaces();
-
- // 6.2
- TEST IndentationIndicators();
-
- // 6.3
- TEST SeparationSpaces();
-
- // 6.4
- TEST LinePrefixes();
-
- // 6.5
- TEST EmptyLines();
-
- // 6.6
- TEST LineFolding();
-
- // 6.7
- TEST BlockFolding();
-
- // 6.8
- TEST FlowFolding();
-
- // 6.9
- TEST SeparatedComment();
-
- // 6.10
- TEST CommentLines();
-
- // 6.11
- TEST MultiLineComments();
-
- // 6.12
- TEST SeparationSpacesII();
-
- // 6.13
- TEST ReservedDirectives();
-
- // 6.14
- TEST YAMLDirective();
-
- // 6.15
- TEST InvalidRepeatedYAMLDirective();
-
- // 6.16
- TEST TagDirective();
-
- // 6.17
- TEST InvalidRepeatedTagDirective();
-
- // 6.18
- TEST PrimaryTagHandle();
-
- // 6.19
- TEST SecondaryTagHandle();
-
- // 6.20
- TEST TagHandles();
-
- // 6.21
- TEST LocalTagPrefix();
-
- // 6.22
- TEST GlobalTagPrefix();
-
- // 6.23
- TEST NodeProperties();
-
- // 6.24
- TEST VerbatimTags();
-
- // 6.25
- TEST InvalidVerbatimTags();
-
- // 6.26
- TEST TagShorthands();
-
- // 6.27
- TEST InvalidTagShorthands();
-
- // 6.28
- TEST NonSpecificTags();
-
- // 6.29
- TEST NodeAnchors();
-
- // 7.1
- TEST AliasNodes();
-
- // 7.2
- TEST EmptyNodes();
-
- // 7.3
- TEST CompletelyEmptyNodes();
-
- // 7.4
- TEST DoubleQuotedImplicitKeys();
-
- // 7.5
- TEST DoubleQuotedLineBreaks();
-
- // 7.6
- TEST DoubleQuotedLines();
-
- // 7.7
- TEST SingleQuotedCharacters();
-
- // 7.8
- TEST SingleQuotedImplicitKeys();
-
- // 7.9
- TEST SingleQuotedLines();
-
- // 7.10
- TEST PlainCharacters();
-
- // 7.11
- TEST PlainImplicitKeys();
-
- // 7.12
- TEST PlainLines();
-
- // 7.13
- TEST FlowSequence();
-
- // 7.14
- TEST FlowSequenceEntries();
-
- // 7.15
- TEST FlowMappings();
-
- // 7.16
- TEST FlowMappingEntries();
-
- // 7.17
- TEST FlowMappingSeparateValues();
-
- // 7.18
- TEST FlowMappingAdjacentValues();
-
- // 7.19
- TEST SinglePairFlowMappings();
-
- // 7.20
- TEST SinglePairExplicitEntry();
-
- // 7.21
- TEST SinglePairImplicitEntries();
-
- // 7.22
- TEST InvalidImplicitKeys();
-
- // 7.23
- TEST FlowContent();
-
- // 7.24
- TEST FlowNodes();
-
- // 8.1
- TEST BlockScalarHeader();
-
- // 8.2
- TEST BlockIndentationHeader();
-
- // 8.3
- TEST InvalidBlockScalarIndentationIndicators();
-
- // 8.4
- TEST ChompingFinalLineBreak();
-
- // 8.5
- TEST ChompingTrailingLines();
-
- // 8.6
- TEST EmptyScalarChomping();
-
- // 8.7
- TEST LiteralScalar();
-
- // 8.8
- TEST LiteralContent();
-
- // 8.9
- TEST FoldedScalar();
-
- // 8.10
- TEST FoldedLines();
-
- // 8.11
- TEST MoreIndentedLines();
-
- // 8.12
- TEST EmptySeparationLines();
-
- // 8.13
- TEST FinalEmptyLines();
-
- // 8.14
- TEST BlockSequence();
-
- // 8.15
- TEST BlockSequenceEntryTypes();
-
- // 8.16
- TEST BlockMappings();
-
- // 8.17
- TEST ExplicitBlockMappingEntries();
-
- // 8.18
- TEST ImplicitBlockMappingEntries();
-
- // 8.19
- TEST CompactBlockMappings();
-
- // 8.20
- TEST BlockNodeTypes();
-
- // 8.21
- TEST BlockScalarNodes();
-
- // 8.22
- TEST BlockCollectionNodes();
- }
-
- bool RunSpecTests();
-}
-
-#endif // SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
diff --git a/yaml-cpp/test/tests.cpp b/yaml-cpp/test/tests.cpp
deleted file mode 100755
index 2dff6eeb..00000000
--- a/yaml-cpp/test/tests.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "tests.h"
-#include "emittertests.h"
-#include "nodetests.h"
-#include "parsertests.h"
-#include "spectests.h"
-#include "yaml-cpp/yaml.h"
-#include <fstream>
-#include <sstream>
-#include <vector>
-#include <iostream>
-
-namespace Test
-{
- void RunAll()
- {
- bool passed = true;
- if(!RunParserTests())
- passed = false;
-
- if(!RunEmitterTests())
- passed = false;
-
- if(!RunSpecTests())
- passed = false;
-
- if(passed)
- std::cout << "All tests passed!\n";
- }
-}
-
diff --git a/yaml-cpp/test/tests.h b/yaml-cpp/test/tests.h
deleted file mode 100755
index 757dbc53..00000000
--- a/yaml-cpp/test/tests.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-#define TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
-
-#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
-#pragma once
-#endif
-
-#include <string>
-
-namespace Test {
- void RunAll();
-
- namespace Parser {
- // scalar tests
- void SimpleScalar(std::string& inputScalar, std::string& desiredOutput);
- void MultiLineScalar(std::string& inputScalar, std::string& desiredOutput);
- void LiteralScalar(std::string& inputScalar, std::string& desiredOutput);
- void FoldedScalar(std::string& inputScalar, std::string& desiredOutput);
- void ChompedFoldedScalar(std::string& inputScalar, std::string& desiredOutput);
- void ChompedLiteralScalar(std::string& inputScalar, std::string& desiredOutput);
- void FoldedScalarWithIndent(std::string& inputScalar, std::string& desiredOutput);
- void ColonScalar(std::string& inputScalar, std::string& desiredOutput);
- void QuotedScalar(std::string& inputScalar, std::string& desiredOutput);
- void CommaScalar(std::string& inputScalar, std::string& desiredOutput);
- void DashScalar(std::string& inputScalar, std::string& desiredOutput);
- void URLScalar(std::string& inputScalar, std::string& desiredOutput);
-
- // misc tests
- bool SimpleSeq();
- bool SimpleMap();
- bool FlowSeq();
- bool FlowMap();
- bool FlowMapWithOmittedKey();
- bool FlowMapWithOmittedValue();
- bool FlowMapWithSoloEntry();
- bool FlowMapEndingWithSoloEntry();
- bool QuotedSimpleKeys();
- bool CompressedMapAndSeq();
- bool NullBlockSeqEntry();
- bool NullBlockMapKey();
- bool NullBlockMapValue();
- bool SimpleAlias();
- bool AliasWithNull();
- bool AnchorInSimpleKey();
- bool AliasAsSimpleKey();
- bool ExplicitDoc();
- bool MultipleDocs();
- bool ExplicitEndDoc();
- bool MultipleDocsWithSomeExplicitIndicators();
- }
-}
-
-#endif // TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66