Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
4dcd222d
Commit
4dcd222d
authored
Sep 08, 2009
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests through 6.29, skipping directives and tags
parent
7bdd31b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
0 deletions
+117
-0
yaml-reader/spectests.cpp
+117
-0
No files found.
yaml-reader/spectests.cpp
View file @
4dcd222d
...
...
@@ -1011,6 +1011,118 @@ namespace Test {
YAML_ASSERT
(
doc
==
" foo
\n
bar
\n
baz "
);
return
true
;
}
// 6.9
TEST
SeparatedComment
()
{
std
::
string
input
=
"key: # Comment
\n
"
" value"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
.
size
()
==
1
);
YAML_ASSERT
(
doc
[
"key"
]
==
"value"
);
return
true
;
}
// 6.10
TEST
CommentLines
()
{
std
::
string
input
=
" # Comment
\n
"
"
\n
"
"
\n
"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML_ASSERT
(
!
parser
);
return
true
;
}
// 6.11
TEST
MultiLineComments
()
{
std
::
string
input
=
"key: # Comment
\n
"
" # lines
\n
"
" value
\n
"
"
\n
"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
.
size
()
==
1
);
YAML_ASSERT
(
doc
[
"key"
]
==
"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
();
std
::
string
value
=
it
.
second
();
m
.
_
[
key
]
=
value
;
}
}
// 6.12
TEST
SeparationSpacesII
()
{
std
::
string
input
=
"{ first: Sammy, last: Sosa }:
\n
"
"# Statistics:
\n
"
" hr: # Home runs
\n
"
" 65
\n
"
" avg: # Average
\n
"
" 0.278"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
StringMap
key
;
key
.
_
[
"first"
]
=
"Sammy"
;
key
.
_
[
"last"
]
=
"Sosa"
;
YAML_ASSERT
(
doc
.
size
()
==
1
);
YAML_ASSERT
(
doc
[
key
].
size
()
==
2
);
YAML_ASSERT
(
doc
[
key
][
"hr"
]
==
65
);
YAML_ASSERT
(
doc
[
key
][
"avg"
]
==
"0.278"
);
return
true
;
}
// TODO: 6.13 - 6.17 directives
// TODO: 6.18 - 6.28 tags
// 6.29
TEST
NodeAnchors
()
{
std
::
string
input
=
"First occurrence: &anchor Value
\n
"
"Second occurrence: *anchor"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
.
size
()
==
2
);
YAML_ASSERT
(
doc
[
"First occurrence"
]
==
"Value"
);
YAML_ASSERT
(
doc
[
"Second occurrence"
]
==
"Value"
);
return
true
;
}
}
bool
RunSpecTests
()
...
...
@@ -1057,6 +1169,11 @@ namespace Test {
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
::
SeparationSpacesII
,
"6.11"
,
"Separation Spaces"
,
passed
,
total
);
RunSpecTest
(
&
Spec
::
NodeAnchors
,
"6.29"
,
"Node Anchors"
,
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