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
5af3fc04
Commit
5af3fc04
authored
May 22, 2012
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Registered all the generated emitter tests
parent
0fb59c18
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
8 deletions
+65
-8
test/create-emitter-tests.py
+8
-4
test/genemittertests.h
+53
-0
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):
...
@@ -25,13 +25,13 @@ def doc_start(implicit=False):
if
implicit
:
if
implicit
:
return
{
'emit'
:
''
,
'handle'
:
'DOC_START()'
}
return
{
'emit'
:
''
,
'handle'
:
'DOC_START()'
}
else
:
else
:
return
{
'emit'
:
'YAML::
DocStart
'
,
'handle'
:
'DOC_START()'
}
return
{
'emit'
:
'YAML::
BeginDoc
'
,
'handle'
:
'DOC_START()'
}
def
doc_end
(
implicit
=
False
):
def
doc_end
(
implicit
=
False
):
if
implicit
:
if
implicit
:
return
{
'emit'
:
''
,
'handle'
:
'DOC_END()'
}
return
{
'emit'
:
''
,
'handle'
:
'DOC_END()'
}
else
:
else
:
return
{
'emit'
:
'YAML::
DocEnd
'
,
'handle'
:
'DOC_END()'
}
return
{
'emit'
:
'YAML::
EndDoc
'
,
'handle'
:
'DOC_END()'
}
def
scalar
(
value
,
tag
=
''
,
anchor
=
''
,
anchor_id
=
0
):
def
scalar
(
value
,
tag
=
''
,
anchor
=
''
,
anchor_id
=
0
):
emit
=
[]
emit
=
[]
...
@@ -39,8 +39,12 @@ def scalar(value, tag='', anchor='', anchor_id=0):
...
@@ -39,8 +39,12 @@ def scalar(value, tag='', anchor='', anchor_id=0):
emit
+=
[
'YAML::VerbatimTag("
%
s")'
%
encode
(
tag
)]
emit
+=
[
'YAML::VerbatimTag("
%
s")'
%
encode
(
tag
)]
if
anchor
:
if
anchor
:
emit
+=
[
'YAML::Anchor("
%
s")'
%
encode
(
anchor
)]
emit
+=
[
'YAML::Anchor("
%
s")'
%
encode
(
anchor
)]
if
tag
:
out_tag
=
encode
(
tag
)
else
:
out_tag
=
'!'
emit
+=
[
'"
%
s"'
%
encode
(
value
)]
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
():
def
gen_outlines
():
yield
[
doc_start
(),
scalar
(
'foo
\n
'
),
doc_end
()]
yield
[
doc_start
(),
scalar
(
'foo
\n
'
),
doc_end
()]
...
@@ -87,7 +91,7 @@ def create_emitter_tests(out):
...
@@ -87,7 +91,7 @@ def create_emitter_tests(out):
out
.
write
(
'void RunGenEmitterTests(int& passed, int& total)
\n
'
)
out
.
write
(
'void RunGenEmitterTests(int& passed, int& total)
\n
'
)
out
.
write
(
'{
\n
'
)
out
.
write
(
'{
\n
'
)
for
test
in
tests
:
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
'
)
out
.
write
(
'}
\n
'
)
if
__name__
==
'__main__'
:
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 @@
...
@@ -7,7 +7,7 @@
#include <cassert>
#include <cassert>
namespace
Test
{
namespace
Test
{
std
::
string
Quote
(
const
std
::
string
&
text
)
{
inline
std
::
string
Quote
(
const
std
::
string
&
text
)
{
YAML
::
Emitter
out
;
YAML
::
Emitter
out
;
out
<<
YAML
::
DoubleQuoted
<<
text
;
out
<<
YAML
::
DoubleQuoted
<<
text
;
return
out
.
c_str
();
return
out
.
c_str
();
...
@@ -52,15 +52,15 @@ namespace Test {
...
@@ -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
);
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
;
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
);
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