2 #include "yaml-cpp/yaml.h"
8 void RunSpecTest(TEST (*test
)(), const std::string
& index
, const std::string
& name
, int& passed
, int& total
) {
12 } catch(const YAML::Exception
& e
) {
14 ret
.error
= std::string(" Exception caught: ") + e
.what();
18 std::cout
<< "Spec test " << index
<< " failed: " << name
<< "\n";
19 std::cout
<< ret
.error
<< "\n";
32 RunSpecTest(&Spec::SeqScalars
, "2.1", "Sequence of Scalars", passed
, total
);
33 RunSpecTest(&Spec::MappingScalarsToScalars
, "2.2", "Mapping Scalars to Scalars", passed
, total
);
34 RunSpecTest(&Spec::MappingScalarsToSequences
, "2.3", "Mapping Scalars to Sequences", passed
, total
);
35 RunSpecTest(&Spec::SequenceOfMappings
, "2.4", "Sequence of Mappings", passed
, total
);
36 RunSpecTest(&Spec::SequenceOfSequences
, "2.5", "Sequence of Sequences", passed
, total
);
37 RunSpecTest(&Spec::MappingOfMappings
, "2.6", "Mapping of Mappings", passed
, total
);
38 RunSpecTest(&Spec::TwoDocumentsInAStream
, "2.7", "Two Documents in a Stream", passed
, total
);
39 RunSpecTest(&Spec::PlayByPlayFeed
, "2.8", "Play by Play Feed from a Game", passed
, total
);
40 RunSpecTest(&Spec::SingleDocumentWithTwoComments
, "2.9", "Single Document with Two Comments", passed
, total
);
41 RunSpecTest(&Spec::SimpleAnchor
, "2.10", "Node for \"Sammy Sosa\" appears twice in this document", passed
, total
);
42 RunSpecTest(&Spec::MappingBetweenSequences
, "2.11", "Mapping between Sequences", passed
, total
);
43 RunSpecTest(&Spec::CompactNestedMapping
, "2.12", "Compact Nested Mapping", passed
, total
);
44 RunSpecTest(&Spec::InLiteralsNewlinesArePreserved
, "2.13", "In literals, newlines are preserved", passed
, total
);
45 RunSpecTest(&Spec::InFoldedScalarsNewlinesBecomeSpaces
, "2.14", "In folded scalars, newlines become spaces", passed
, total
);
46 RunSpecTest(&Spec::FoldedNewlinesArePreservedForMoreIndentedAndBlankLines
, "2.15", "Folded newlines are preserved for \"more indented\" and blank lines", passed
, total
);
47 RunSpecTest(&Spec::IndentationDeterminesScope
, "2.16", "Indentation determines scope", passed
, total
);
48 RunSpecTest(&Spec::QuotedScalars
, "2.17", "Quoted scalars", passed
, total
);
49 RunSpecTest(&Spec::MultiLineFlowScalars
, "2.18", "Multi-line flow scalars", passed
, total
);
51 RunSpecTest(&Spec::VariousExplicitTags
, "2.23", "Various Explicit Tags", passed
, total
);
52 RunSpecTest(&Spec::GlobalTags
, "2.24", "Global Tags", passed
, total
);
53 RunSpecTest(&Spec::UnorderedSets
, "2.25", "Unordered Sets", passed
, total
);
54 RunSpecTest(&Spec::OrderedMappings
, "2.26", "Ordered Mappings", passed
, total
);
55 RunSpecTest(&Spec::Invoice
, "2.27", "Invoice", passed
, total
);
56 RunSpecTest(&Spec::LogFile
, "2.28", "Log File", passed
, total
);
58 RunSpecTest(&Spec::BlockStructureIndicators
, "5.3", "Block Structure Indicators", passed
, total
);
59 RunSpecTest(&Spec::FlowStructureIndicators
, "5.4", "Flow Structure Indicators", passed
, total
);
60 RunSpecTest(&Spec::NodePropertyIndicators
, "5.6", "Node Property Indicators", passed
, total
);
61 RunSpecTest(&Spec::BlockScalarIndicators
, "5.7", "Block Scalar Indicators", passed
, total
);
62 RunSpecTest(&Spec::QuotedScalarIndicators
, "5.8", "Quoted Scalar Indicators", passed
, total
);
63 RunSpecTest(&Spec::LineBreakCharacters
, "5.11", "Line Break Characters", passed
, total
);
64 RunSpecTest(&Spec::TabsAndSpaces
, "5.12", "Tabs and Spaces", passed
, total
);
65 RunSpecTest(&Spec::EscapedCharacters
, "5.13", "Escaped Characters", passed
, total
);
66 RunSpecTest(&Spec::InvalidEscapedCharacters
, "5.14", "Invalid Escaped Characters", passed
, total
);
68 RunSpecTest(&Spec::IndentationSpaces
, "6.1", "Indentation Spaces", passed
, total
);
69 RunSpecTest(&Spec::IndentationIndicators
, "6.2", "Indentation Indicators", passed
, total
);
70 RunSpecTest(&Spec::SeparationSpaces
, "6.3", "Separation Spaces", passed
, total
);
71 RunSpecTest(&Spec::LinePrefixes
, "6.4", "Line Prefixes", passed
, total
);
72 RunSpecTest(&Spec::EmptyLines
, "6.5", "Empty Lines", passed
, total
);
73 RunSpecTest(&Spec::LineFolding
, "6.6", "Line Folding", passed
, total
);
74 RunSpecTest(&Spec::BlockFolding
, "6.7", "Block Folding", passed
, total
);
75 RunSpecTest(&Spec::FlowFolding
, "6.8", "Flow Folding", passed
, total
);
76 RunSpecTest(&Spec::SeparatedComment
, "6.9", "Separated Comment", passed
, total
);
77 RunSpecTest(&Spec::CommentLines
, "6.10", "Comment Lines", passed
, total
);
78 RunSpecTest(&Spec::MultiLineComments
, "6.11", "Multi-Line Comments", passed
, total
);
79 RunSpecTest(&Spec::SeparationSpacesII
, "6.12", "Separation Spaces", passed
, total
);
80 RunSpecTest(&Spec::ReservedDirectives
, "6.13", "Reserved Directives", passed
, total
);
81 RunSpecTest(&Spec::YAMLDirective
, "6.14", "YAML Directive", passed
, total
);
82 RunSpecTest(&Spec::InvalidRepeatedYAMLDirective
, "6.15", "Invalid Repeated YAML Directive", passed
, total
);
83 RunSpecTest(&Spec::TagDirective
, "6.16", "Tag Directive", passed
, total
);
84 RunSpecTest(&Spec::InvalidRepeatedTagDirective
, "6.17", "Invalid Repeated Tag Directive", passed
, total
);
85 RunSpecTest(&Spec::PrimaryTagHandle
, "6.18", "Primary Tag Handle", passed
, total
);
86 RunSpecTest(&Spec::SecondaryTagHandle
, "6.19", "SecondaryTagHandle", passed
, total
);
87 RunSpecTest(&Spec::TagHandles
, "6.20", "TagHandles", passed
, total
);
88 RunSpecTest(&Spec::LocalTagPrefix
, "6.21", "LocalTagPrefix", passed
, total
);
89 RunSpecTest(&Spec::GlobalTagPrefix
, "6.22", "GlobalTagPrefix", passed
, total
);
90 RunSpecTest(&Spec::NodeProperties
, "6.23", "NodeProperties", passed
, total
);
91 RunSpecTest(&Spec::VerbatimTags
, "6.24", "Verbatim Tags", passed
, total
);
92 RunSpecTest(&Spec::InvalidVerbatimTags
, "6.25", "Invalid Verbatim Tags", passed
, total
);
93 RunSpecTest(&Spec::TagShorthands
, "6.26", "Tag Shorthands", passed
, total
);
94 RunSpecTest(&Spec::InvalidTagShorthands
, "6.27", "Invalid Tag Shorthands", passed
, total
);
95 RunSpecTest(&Spec::NonSpecificTags
, "6.28", "Non Specific Tags", passed
, total
);
96 RunSpecTest(&Spec::NodeAnchors
, "6.29", "Node Anchors", passed
, total
);
98 RunSpecTest(&Spec::AliasNodes
, "7.1", "Alias Nodes", passed
, total
);
99 RunSpecTest(&Spec::EmptyNodes
, "7.2", "Empty Nodes", passed
, total
);
100 RunSpecTest(&Spec::CompletelyEmptyNodes
, "7.3", "Completely Empty Nodes", passed
, total
);
101 RunSpecTest(&Spec::DoubleQuotedImplicitKeys
, "7.4", "Double Quoted Implicit Keys", passed
, total
);
102 RunSpecTest(&Spec::DoubleQuotedLineBreaks
, "7.5", "Double Quoted Line Breaks", passed
, total
);
103 RunSpecTest(&Spec::DoubleQuotedLines
, "7.6", "Double Quoted Lines", passed
, total
);
104 RunSpecTest(&Spec::SingleQuotedCharacters
, "7.7", "Single Quoted Characters", passed
, total
);
105 RunSpecTest(&Spec::SingleQuotedImplicitKeys
, "7.8", "Single Quoted Implicit Keys", passed
, total
);
106 RunSpecTest(&Spec::SingleQuotedLines
, "7.9", "Single Quoted Lines", passed
, total
);
107 RunSpecTest(&Spec::PlainCharacters
, "7.10", "Plain Characters", passed
, total
);
108 RunSpecTest(&Spec::PlainImplicitKeys
, "7.11", "Plain Implicit Keys", passed
, total
);
109 RunSpecTest(&Spec::PlainLines
, "7.12", "Plain Lines", passed
, total
);
110 RunSpecTest(&Spec::FlowSequence
, "7.13", "Flow Sequence", passed
, total
);
111 RunSpecTest(&Spec::FlowSequenceEntries
, "7.14", "Flow Sequence Entries", passed
, total
);
112 RunSpecTest(&Spec::FlowMappings
, "7.15", "Flow Mappings", passed
, total
);
113 RunSpecTest(&Spec::FlowMappingEntries
, "7.16", "Flow Mapping Entries", passed
, total
);
114 RunSpecTest(&Spec::FlowMappingSeparateValues
, "7.17", "Flow Mapping Separate Values", passed
, total
);
115 RunSpecTest(&Spec::FlowMappingAdjacentValues
, "7.18", "Flow Mapping Adjacent Values", passed
, total
);
116 RunSpecTest(&Spec::SinglePairFlowMappings
, "7.19", "Single Pair Flow Mappings", passed
, total
);
117 RunSpecTest(&Spec::SinglePairExplicitEntry
, "7.20", "Single Pair Explicit Entry", passed
, total
);
118 RunSpecTest(&Spec::SinglePairImplicitEntries
, "7.21", "Single Pair Implicit Entries", passed
, total
);
119 RunSpecTest(&Spec::InvalidImplicitKeys
, "7.22", "Invalid Implicit Keys", passed
, total
);
120 RunSpecTest(&Spec::FlowContent
, "7.23", "Flow Content", passed
, total
);
121 RunSpecTest(&Spec::FlowNodes
, "7.24", "FlowNodes", passed
, total
);
123 RunSpecTest(&Spec::BlockScalarHeader
, "8.1", "Block Scalar Header", passed
, total
);
124 RunSpecTest(&Spec::BlockIndentationHeader
, "8.2", "Block Indentation Header", passed
, total
);
125 RunSpecTest(&Spec::InvalidBlockScalarIndentationIndicators
, "8.3", "Invalid Block Scalar Indentation Indicators", passed
, total
);
126 RunSpecTest(&Spec::ChompingFinalLineBreak
, "8.4", "Chomping Final Line Break", passed
, total
);
127 RunSpecTest(&Spec::ChompingTrailingLines
, "8.5", "Chomping Trailing Lines", passed
, total
);
128 RunSpecTest(&Spec::EmptyScalarChomping
, "8.6", "Empty Scalar Chomping", passed
, total
);
129 RunSpecTest(&Spec::LiteralScalar
, "8.7", "Literal Scalar", passed
, total
);
130 RunSpecTest(&Spec::LiteralContent
, "8.8", "Literal Content", passed
, total
);
131 RunSpecTest(&Spec::FoldedScalar
, "8.9", "Folded Scalar", passed
, total
);
132 RunSpecTest(&Spec::FoldedLines
, "8.10", "Folded Lines", passed
, total
);
133 RunSpecTest(&Spec::MoreIndentedLines
, "8.11", "More Indented Lines", passed
, total
);
134 RunSpecTest(&Spec::EmptySeparationLines
, "8.12", "Empty Separation Lines", passed
, total
);
135 RunSpecTest(&Spec::FinalEmptyLines
, "8.13", "Final Empty Lines", passed
, total
);
136 RunSpecTest(&Spec::BlockSequence
, "8.14", "Block Sequence", passed
, total
);
137 RunSpecTest(&Spec::BlockSequenceEntryTypes
, "8.15", "Block Sequence Entry Types", passed
, total
);
138 RunSpecTest(&Spec::BlockMappings
, "8.16", "Block Mappings", passed
, total
);
139 RunSpecTest(&Spec::ExplicitBlockMappingEntries
, "8.17", "Explicit Block Mapping Entries", passed
, total
);
140 RunSpecTest(&Spec::ImplicitBlockMappingEntries
, "8.18", "Implicit Block Mapping Entries", passed
, total
);
141 RunSpecTest(&Spec::CompactBlockMappings
, "8.19", "Compact Block Mappings", passed
, total
);
142 RunSpecTest(&Spec::BlockNodeTypes
, "8.20", "Block Node Types", passed
, total
);
143 RunSpecTest(&Spec::BlockScalarNodes
, "8.21", "Block Scalar Nodes", passed
, total
);
144 RunSpecTest(&Spec::BlockCollectionNodes
, "8.22", "Block Collection Nodes", passed
, total
);
146 std::cout
<< "Spec tests: " << passed
<< "/" << total
<< " passed\n";
147 return passed
== total
;