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
bd9103f4
Commit
bd9103f4
authored
May 08, 2012
by
beder
Browse files
Added node iterator tests
parent
485afcb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
test/new-api/nodetests.cpp
test/new-api/nodetests.cpp
+23
-0
No files found.
test/new-api/nodetests.cpp
View file @
bd9103f4
...
@@ -326,6 +326,27 @@ namespace Test
...
@@ -326,6 +326,27 @@ namespace Test
return
true
;
return
true
;
}
}
TEST
IterateSequence
()
{
YAML
::
Node
node
=
YAML
::
Load
(
"[1, 3, 5, 7]"
);
int
seq
[]
=
{
1
,
3
,
5
,
7
};
int
i
=
0
;
for
(
YAML
::
const_iterator
it
=
node
.
begin
();
it
!=
node
.
end
();
++
it
)
{
int
x
=
seq
[
i
++
];
YAML_ASSERT
(
it
->
as
<
int
>
()
==
x
);
}
return
true
;
}
TEST
IterateMap
()
{
YAML
::
Node
node
=
YAML
::
Load
(
"{a: A, b: B, c: C}"
);
for
(
YAML
::
const_iterator
it
=
node
.
begin
();
it
!=
node
.
end
();
++
it
)
{
YAML_ASSERT
(
it
->
first
.
as
<
char
>
()
+
'A'
-
'a'
==
it
->
second
.
as
<
char
>
());
}
return
true
;
}
TEST
ForEach
()
TEST
ForEach
()
{
{
YAML
::
Node
node
=
YAML
::
Load
(
"[1, 3, 5, 7]"
);
YAML
::
Node
node
=
YAML
::
Load
(
"[1, 3, 5, 7]"
);
...
@@ -386,6 +407,8 @@ namespace Test
...
@@ -386,6 +407,8 @@ namespace Test
RunNodeTest
(
&
Node
::
FallbackValues
,
"fallback values"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
FallbackValues
,
"fallback values"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
NumericConversion
,
"numeric conversion"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
NumericConversion
,
"numeric conversion"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
Binary
,
"binary"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
Binary
,
"binary"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
IterateSequence
,
"iterate sequence"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
IterateMap
,
"iterate map"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
ForEach
,
"for each"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
ForEach
,
"for each"
,
passed
,
total
);
std
::
cout
<<
"Node tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
std
::
cout
<<
"Node tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
...
...
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