Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
973ac4b3
Commit
973ac4b3
authored
Sep 06, 2009
by
Jesse Beder
Browse files
Added spec tests through example 2.13
parent
e91a152e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
yaml-reader/spectests.cpp
yaml-reader/spectests.cpp
+49
-0
No files found.
yaml-reader/spectests.cpp
View file @
973ac4b3
...
...
@@ -333,6 +333,53 @@ namespace Test {
YAML_ASSERT
(
doc
[
Pair
(
"New York Yankees"
,
"Atlanta Braves"
)][
2
]
==
"2001-08-14"
);
return
true
;
}
TEST
CompactNestedMapping
()
{
std
::
string
input
=
"---
\n
"
"# Products purchased
\n
"
"- item : Super Hoop
\n
"
" quantity: 1
\n
"
"- item : Basketball
\n
"
" quantity: 4
\n
"
"- item : Big Shoes
\n
"
" quantity: 1"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
.
size
()
==
3
);
YAML_ASSERT
(
doc
[
0
].
size
()
==
2
);
YAML_ASSERT
(
doc
[
0
][
"item"
]
==
"Super Hoop"
);
YAML_ASSERT
(
doc
[
0
][
"quantity"
]
==
1
);
YAML_ASSERT
(
doc
[
1
].
size
()
==
2
);
YAML_ASSERT
(
doc
[
1
][
"item"
]
==
"Basketball"
);
YAML_ASSERT
(
doc
[
1
][
"quantity"
]
==
4
);
YAML_ASSERT
(
doc
[
2
].
size
()
==
2
);
YAML_ASSERT
(
doc
[
2
][
"item"
]
==
"Big Shoes"
);
YAML_ASSERT
(
doc
[
2
][
"quantity"
]
==
1
);
return
true
;
}
TEST
InLiteralsNewlinesArePreserved
()
{
std
::
string
input
=
"# ASCII Art
\n
"
"--- |
\n
"
"
\\
//||
\\
/||
\n
"
" // || ||__"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
==
"
\\
//||
\\
/||
\n
"
"// || ||__"
);
return
true
;
}
}
bool
RunSpecTests
()
...
...
@@ -349,6 +396,8 @@ namespace Test {
RunSpecTest
(
&
Spec
::
SingleDocumentWithTwoComments
,
"2.9"
,
"Single Document with Two Comments"
,
passed
);
RunSpecTest
(
&
Spec
::
SimpleAnchor
,
"2.10"
,
"Node for
\"
Sammy Sosa
\"
appears twice in this document"
,
passed
);
RunSpecTest
(
&
Spec
::
MappingBetweenSequences
,
"2.11"
,
"Mapping between Sequences"
,
passed
);
RunSpecTest
(
&
Spec
::
CompactNestedMapping
,
"2.12"
,
"Compact Nested Mapping"
,
passed
);
RunSpecTest
(
&
Spec
::
InLiteralsNewlinesArePreserved
,
"2.13"
,
"In literals, newlines are preserved"
,
passed
);
return
passed
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment