mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Split test struct and handler macros out for the emitter/spec tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "tests.h"
|
||||
#include "handlermacros.h"
|
||||
#include "yaml-cpp/yaml.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include <iostream>
|
||||
@@ -1051,7 +1052,37 @@ namespace Test
|
||||
}
|
||||
total++;
|
||||
}
|
||||
|
||||
void RunGenEmitterTest(TEST (*test)(YAML::Emitter&), const std::string& name, int& passed, int& total) {
|
||||
YAML::Emitter out;
|
||||
TEST ret;
|
||||
|
||||
try {
|
||||
ret = test(out);
|
||||
} catch(const YAML::Exception& e) {
|
||||
ret.ok = false;
|
||||
ret.error = std::string(" Exception caught: ") + e.what();
|
||||
}
|
||||
|
||||
if(!out.good()) {
|
||||
ret.ok = false;
|
||||
ret.error = out.GetLastError();
|
||||
}
|
||||
|
||||
if(!ret.ok) {
|
||||
std::cout << "Generated emitter test failed: " << name << "\n";
|
||||
std::cout << "Output:\n";
|
||||
std::cout << out.c_str() << "<<<\n";
|
||||
std::cout << ret.error << "\n";
|
||||
}
|
||||
|
||||
if(ret.ok)
|
||||
passed++;
|
||||
total++;
|
||||
}
|
||||
}
|
||||
|
||||
#include "genemittertests.h"
|
||||
|
||||
bool RunEmitterTests()
|
||||
{
|
||||
@@ -1142,6 +1173,8 @@ namespace Test
|
||||
RunEmitterErrorTest(&Emitter::InvalidAnchor, "invalid anchor", passed, total);
|
||||
RunEmitterErrorTest(&Emitter::InvalidAlias, "invalid alias", passed, total);
|
||||
RunEmitterErrorTest(&Emitter::BadLocalTag, "bad local tag", passed, total);
|
||||
|
||||
RunGenEmitterTests(passed, total);
|
||||
|
||||
std::cout << "Emitter tests: " << passed << "/" << total << " passed\n";
|
||||
return passed == total;
|
||||
|
Reference in New Issue
Block a user