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
fa885d18
Commit
fa885d18
authored
Sep 08, 2009
by
Jesse Beder
Browse files
More tests, found bug in implicit keys in flow sequence
parent
da4614eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
yaml-reader/spectests.cpp
yaml-reader/spectests.cpp
+83
-0
No files found.
yaml-reader/spectests.cpp
View file @
fa885d18
...
...
@@ -1123,6 +1123,84 @@ namespace Test {
YAML_ASSERT
(
doc
[
"Second occurrence"
]
==
"Value"
);
return
true
;
}
// 7.1
TEST
AliasNodes
()
{
std
::
string
input
=
"First occurrence: &anchor Foo
\n
"
"Second occurrence: *anchor
\n
"
"Override anchor: &anchor Bar
\n
"
"Reuse anchor: *anchor"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
.
size
()
==
4
);
YAML_ASSERT
(
doc
[
"First occurrence"
]
==
"Foo"
);
YAML_ASSERT
(
doc
[
"Second occurrence"
]
==
"Foo"
);
YAML_ASSERT
(
doc
[
"Override anchor"
]
==
"Bar"
);
YAML_ASSERT
(
doc
[
"Reuse anchor"
]
==
"Bar"
);
return
true
;
}
// 7.2
TEST
EmptyNodes
()
{
std
::
string
input
=
"{
\n
"
" foo : !!str,
\n
"
" !!str : bar,
\n
"
"}"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
.
size
()
==
2
);
YAML_ASSERT
(
doc
[
"foo"
]
==
""
);
// TODO: check tag
YAML_ASSERT
(
doc
[
""
]
==
"bar"
);
return
true
;
}
// 7.3
TEST
CompletelyEmptyNodes
()
{
std
::
string
input
=
"{
\n
"
" ? foo :,
\n
"
" : bar,
\n
"
"}
\n
"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
.
size
()
==
2
);
YAML_ASSERT
(
IsNull
(
doc
[
"foo"
]));
YAML_ASSERT
(
doc
[
YAML
::
Null
]
==
"bar"
);
return
true
;
}
// 7.4
TEST
DoubleQuotedImplicitKeys
()
{
std
::
string
input
=
"
\"
implicit block key
\"
: [
\n
"
"
\"
implicit flow key
\"
: value,
\n
"
" ]"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
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"
]
==
"value"
);
return
true
;
}
}
bool
RunSpecTests
()
...
...
@@ -1174,6 +1252,11 @@ namespace Test {
RunSpecTest
(
&
Spec
::
SeparationSpacesII
,
"6.11"
,
"Separation Spaces"
,
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
);
std
::
cout
<<
"Spec tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
return
passed
==
total
;
...
...
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