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
5af3fc04
Commit
5af3fc04
authored
May 22, 2012
by
Jesse Beder
Browse files
Registered all the generated emitter tests
parent
0fb59c18
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
8 deletions
+65
-8
test/create-emitter-tests.py
test/create-emitter-tests.py
+8
-4
test/genemittertests.h
test/genemittertests.h
+53
-0
test/handlermacros.h
test/handlermacros.h
+4
-4
No files found.
test/create-emitter-tests.py
View file @
5af3fc04
...
...
@@ -25,13 +25,13 @@ def doc_start(implicit=False):
if
implicit
:
return
{
'emit'
:
''
,
'handle'
:
'DOC_START()'
}
else
:
return
{
'emit'
:
'YAML::
DocStart
'
,
'handle'
:
'DOC_START()'
}
return
{
'emit'
:
'YAML::
BeginDoc
'
,
'handle'
:
'DOC_START()'
}
def
doc_end
(
implicit
=
False
):
if
implicit
:
return
{
'emit'
:
''
,
'handle'
:
'DOC_END()'
}
else
:
return
{
'emit'
:
'YAML::
Doc
End'
,
'handle'
:
'DOC_END()'
}
return
{
'emit'
:
'YAML::End
Doc
'
,
'handle'
:
'DOC_END()'
}
def
scalar
(
value
,
tag
=
''
,
anchor
=
''
,
anchor_id
=
0
):
emit
=
[]
...
...
@@ -39,8 +39,12 @@ def scalar(value, tag='', anchor='', anchor_id=0):
emit
+=
[
'YAML::VerbatimTag("%s")'
%
encode
(
tag
)]
if
anchor
:
emit
+=
[
'YAML::Anchor("%s")'
%
encode
(
anchor
)]
if
tag
:
out_tag
=
encode
(
tag
)
else
:
out_tag
=
'!'
emit
+=
[
'"%s"'
%
encode
(
value
)]
return
{
'emit'
:
emit
,
'handle'
:
'SCALAR("%s", %s, "%s")'
%
(
encode
(
tag
)
,
anchor_id
,
encode
(
value
))}
return
{
'emit'
:
emit
,
'handle'
:
'SCALAR("%s", %s, "%s")'
%
(
out_
tag
,
anchor_id
,
encode
(
value
))}
def
gen_outlines
():
yield
[
doc_start
(),
scalar
(
'foo
\n
'
),
doc_end
()]
...
...
@@ -87,7 +91,7 @@ def create_emitter_tests(out):
out
.
write
(
'void RunGenEmitterTests(int& passed, int& total)
\n
'
)
out
.
write
(
'{
\n
'
)
for
test
in
tests
:
out
.
write
(
' RunGenEmitterTest(&Emitter::%s, %s, passed, total);
\n
'
%
(
test
[
'name'
],
encode
(
test
[
'name'
])))
out
.
write
(
' RunGenEmitterTest(&Emitter::%s,
"
%s
"
, passed, total);
\n
'
%
(
test
[
'name'
],
encode
(
test
[
'name'
])))
out
.
write
(
'}
\n
'
)
if
__name__
==
'__main__'
:
...
...
test/genemittertests.h
0 → 100644
View file @
5af3fc04
namespace
Emitter
{
TEST
testb3471d40ef2dadee13be
(
YAML
::
Emitter
&
out
)
{
out
<<
YAML
::
BeginDoc
;
out
<<
"foo
\n
"
;
out
<<
YAML
::
EndDoc
;
HANDLE
(
out
.
c_str
());
EXPECT_DOC_START
();
EXPECT_SCALAR
(
"!"
,
0
,
"foo
\n
"
);
EXPECT_DOC_END
();
DONE
();
}
TEST
testb1f8cfb6083c3fc130aa
(
YAML
::
Emitter
&
out
)
{
out
<<
"foo
\n
"
;
out
<<
YAML
::
EndDoc
;
HANDLE
(
out
.
c_str
());
EXPECT_DOC_START
();
EXPECT_SCALAR
(
"!"
,
0
,
"foo
\n
"
);
EXPECT_DOC_END
();
DONE
();
}
TEST
testa2f381bb144cf8886efe
(
YAML
::
Emitter
&
out
)
{
out
<<
YAML
::
BeginDoc
;
out
<<
"foo
\n
"
;
HANDLE
(
out
.
c_str
());
EXPECT_DOC_START
();
EXPECT_SCALAR
(
"!"
,
0
,
"foo
\n
"
);
EXPECT_DOC_END
();
DONE
();
}
TEST
test29a80ae92b2f00fa1d06
(
YAML
::
Emitter
&
out
)
{
out
<<
"foo
\n
"
;
HANDLE
(
out
.
c_str
());
EXPECT_DOC_START
();
EXPECT_SCALAR
(
"!"
,
0
,
"foo
\n
"
);
EXPECT_DOC_END
();
DONE
();
}
}
void
RunGenEmitterTests
(
int
&
passed
,
int
&
total
)
{
RunGenEmitterTest
(
&
Emitter
::
testb3471d40ef2dadee13be
,
"testb3471d40ef2dadee13be"
,
passed
,
total
);
RunGenEmitterTest
(
&
Emitter
::
testb1f8cfb6083c3fc130aa
,
"testb1f8cfb6083c3fc130aa"
,
passed
,
total
);
RunGenEmitterTest
(
&
Emitter
::
testa2f381bb144cf8886efe
,
"testa2f381bb144cf8886efe"
,
passed
,
total
);
RunGenEmitterTest
(
&
Emitter
::
test29a80ae92b2f00fa1d06
,
"test29a80ae92b2f00fa1d06"
,
passed
,
total
);
}
test/handlermacros.h
View file @
5af3fc04
...
...
@@ -7,7 +7,7 @@
#include <cassert>
namespace
Test
{
std
::
string
Quote
(
const
std
::
string
&
text
)
{
inline
std
::
string
Quote
(
const
std
::
string
&
text
)
{
YAML
::
Emitter
out
;
out
<<
YAML
::
DoubleQuoted
<<
text
;
return
out
.
c_str
();
...
...
@@ -52,15 +52,15 @@ namespace Test {
}
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Event
&
event
)
{
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Event
&
event
)
{
return
event
.
write
(
out
);
}
bool
operator
==
(
const
Event
&
a
,
const
Event
&
b
)
{
inline
bool
operator
==
(
const
Event
&
a
,
const
Event
&
b
)
{
return
a
.
type
==
b
.
type
&&
a
.
tag
==
b
.
tag
&&
a
.
anchor
==
b
.
anchor
&&
a
.
scalar
==
b
.
scalar
;
}
bool
operator
!=
(
const
Event
&
a
,
const
Event
&
b
)
{
inline
bool
operator
!=
(
const
Event
&
a
,
const
Event
&
b
)
{
return
!
(
a
==
b
);
}
...
...
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