mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Registered all the generated emitter tests
This commit is contained in:
@@ -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::DocEnd', 'handle': 'DOC_END()'}
|
||||
return {'emit': 'YAML::EndDoc', '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__':
|
||||
|
53
test/genemittertests.h
Normal file
53
test/genemittertests.h
Normal file
@@ -0,0 +1,53 @@
|
||||
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);
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user