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
98830a4a
Commit
98830a4a
authored
Sep 13, 2011
by
Jesse Beder
Browse files
Added 6.x tests with tags
parent
3a88c4b4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
12 deletions
+109
-12
test/new-api/spectests.cpp
test/new-api/spectests.cpp
+103
-11
test/specexamples.h
test/specexamples.h
+6
-1
No files found.
test/new-api/spectests.cpp
View file @
98830a4a
...
@@ -593,43 +593,135 @@ namespace Test
...
@@ -593,43 +593,135 @@ namespace Test
}
}
// 6.16
// 6.16
TEST
TagDirective
()
{
return
" not written yet"
;
}
TEST
TagDirective
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_16
);
YAML_ASSERT
(
doc
.
Tag
()
==
"tag:yaml.org,2002:str"
);
YAML_ASSERT
(
doc
.
as
<
std
::
string
>
()
==
"foo"
);
return
true
;
}
// 6.17
// 6.17
TEST
InvalidRepeatedTagDirective
()
{
return
" not written yet"
;
}
TEST
InvalidRepeatedTagDirective
()
{
try
{
YAML
::
Parse
(
ex6_17
);
}
catch
(
const
YAML
::
ParserException
&
e
)
{
if
(
e
.
msg
==
YAML
::
ErrorMsg
::
REPEATED_TAG_DIRECTIVE
)
return
true
;
throw
;
}
return
" No exception was thrown"
;
}
// 6.18
// 6.18
TEST
PrimaryTagHandle
()
{
return
" not written yet"
;
}
TEST
PrimaryTagHandle
()
{
return
" not written yet"
;
}
// 6.19
// 6.19
TEST
SecondaryTagHandle
()
{
return
" not written yet"
;
}
TEST
SecondaryTagHandle
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_19
);
YAML_ASSERT
(
doc
.
Tag
()
==
"tag:example.com,2000:app/int"
);
YAML_ASSERT
(
doc
.
as
<
std
::
string
>
()
==
"1 - 3"
);
return
true
;
}
// 6.20
// 6.20
TEST
TagHandles
()
{
return
" not written yet"
;
}
TEST
TagHandles
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_20
);
YAML_ASSERT
(
doc
.
Tag
()
==
"tag:example.com,2000:app/foo"
);
YAML_ASSERT
(
doc
.
as
<
std
::
string
>
()
==
"bar"
);
return
true
;
}
// 6.21
// 6.21
TEST
LocalTagPrefix
()
{
return
" not written yet"
;
}
TEST
LocalTagPrefix
()
{
return
" not written yet"
;
}
// 6.22
// 6.22
TEST
GlobalTagPrefix
()
{
return
" not written yet"
;
}
TEST
GlobalTagPrefix
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_22
);
YAML_ASSERT
(
doc
.
size
()
==
1
);
YAML_ASSERT
(
doc
[
0
].
Tag
()
==
"tag:example.com,2000:app/foo"
);
YAML_ASSERT
(
doc
[
0
].
as
<
std
::
string
>
()
==
"bar"
);
return
true
;
}
// 6.23
// 6.23
TEST
NodeProperties
()
{
return
" not written yet"
;
}
TEST
NodeProperties
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_23
);
YAML_ASSERT
(
doc
.
size
()
==
2
);
for
(
YAML
::
const_iterator
it
=
doc
.
begin
();
it
!=
doc
.
end
();
++
it
)
{
if
(
it
->
first
.
as
<
std
::
string
>
()
==
"foo"
)
{
YAML_ASSERT
(
it
->
first
.
Tag
()
==
"tag:yaml.org,2002:str"
);
YAML_ASSERT
(
it
->
second
.
Tag
()
==
"tag:yaml.org,2002:str"
);
YAML_ASSERT
(
it
->
second
.
as
<
std
::
string
>
()
==
"bar"
);
}
else
if
(
it
->
first
.
as
<
std
::
string
>
()
==
"baz"
)
{
YAML_ASSERT
(
it
->
second
.
as
<
std
::
string
>
()
==
"foo"
);
}
else
return
" unknown key"
;
}
return
true
;
}
// 6.24
// 6.24
TEST
VerbatimTags
()
{
return
" not written yet"
;
}
TEST
VerbatimTags
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_24
);
YAML_ASSERT
(
doc
.
size
()
==
1
);
for
(
YAML
::
const_iterator
it
=
doc
.
begin
();
it
!=
doc
.
end
();
++
it
)
{
YAML_ASSERT
(
it
->
first
.
Tag
()
==
"tag:yaml.org,2002:str"
);
YAML_ASSERT
(
it
->
first
.
as
<
std
::
string
>
()
==
"foo"
);
YAML_ASSERT
(
it
->
second
.
Tag
()
==
"!bar"
);
YAML_ASSERT
(
it
->
second
.
as
<
std
::
string
>
()
==
"baz"
);
}
return
true
;
}
// 6.25
// 6.25
TEST
InvalidVerbatimTags
()
{
return
" not written yet"
;
}
TEST
InvalidVerbatimTags
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_25
);
return
" not implemented yet"
;
// TODO: check tags (but we probably will say these are valid, I think)
}
// 6.26
// 6.26
TEST
TagShorthands
()
{
return
" not written yet"
;
}
TEST
TagShorthands
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_26
);
YAML_ASSERT
(
doc
.
size
()
==
3
);
YAML_ASSERT
(
doc
[
0
].
Tag
()
==
"!local"
);
YAML_ASSERT
(
doc
[
0
].
as
<
std
::
string
>
()
==
"foo"
);
YAML_ASSERT
(
doc
[
1
].
Tag
()
==
"tag:yaml.org,2002:str"
);
YAML_ASSERT
(
doc
[
1
].
as
<
std
::
string
>
()
==
"bar"
);
YAML_ASSERT
(
doc
[
2
].
Tag
()
==
"tag:example.com,2000:app/tag%21"
);
YAML_ASSERT
(
doc
[
2
].
as
<
std
::
string
>
()
==
"baz"
);
return
true
;
}
// 6.27
// 6.27
TEST
InvalidTagShorthands
()
{
return
" not written yet"
;
}
TEST
InvalidTagShorthands
()
{
bool
threw
=
false
;
try
{
YAML
::
Parse
(
ex6_27a
);
}
catch
(
const
YAML
::
ParserException
&
e
)
{
threw
=
true
;
if
(
e
.
msg
!=
YAML
::
ErrorMsg
::
TAG_WITH_NO_SUFFIX
)
throw
;
}
if
(
!
threw
)
return
" No exception was thrown for a tag with no suffix"
;
YAML
::
Parse
(
ex6_27b
);
// TODO: should we reject this one (since !h! is not declared)?
return
" not implemented yet"
;
}
// 6.28
// 6.28
TEST
NonSpecificTags
()
{
return
" not written yet"
;
}
TEST
NonSpecificTags
()
{
YAML
::
Node
doc
=
YAML
::
Parse
(
ex6_28
);
YAML_ASSERT
(
doc
.
size
()
==
3
);
YAML_ASSERT
(
doc
[
0
].
as
<
std
::
string
>
()
==
"12"
);
// TODO: check tags. How?
YAML_ASSERT
(
doc
[
1
].
as
<
int
>
()
==
12
);
YAML_ASSERT
(
doc
[
2
].
as
<
std
::
string
>
()
==
"12"
);
return
true
;
}
// 6.29
// 6.29
TEST
NodeAnchors
()
{
TEST
NodeAnchors
()
{
...
...
test/specexamples.h
View file @
98830a4a
...
@@ -498,11 +498,16 @@ namespace Test {
...
@@ -498,11 +498,16 @@ namespace Test {
"- !!str bar
\n
"
"- !!str bar
\n
"
"- !e!tag%21 baz
\n
"
;
"- !e!tag%21 baz
\n
"
;
const
char
*
ex6_27
=
const
char
*
ex6_27
a
=
"%TAG !e! tag:example,2000:app/
\n
"
"%TAG !e! tag:example,2000:app/
\n
"
"---
\n
"
"---
\n
"
"- !e! foo"
;
"- !e! foo"
;
const
char
*
ex6_27b
=
"%TAG !e! tag:example,2000:app/
\n
"
"---
\n
"
"- !h!bar baz"
;
const
char
*
ex6_28
=
const
char
*
ex6_28
=
"# Assuming conventional resolution:
\n
"
"# Assuming conventional resolution:
\n
"
"-
\"
12
\"\n
"
"-
\"
12
\"\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