summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse/src/test.cpp54
1 files changed, 31 insertions, 23 deletions
diff --git a/gentoobrowse/src/test.cpp b/gentoobrowse/src/test.cpp
index 01ffa76..a534cc6 100644
--- a/gentoobrowse/src/test.cpp
+++ b/gentoobrowse/src/test.cpp
@@ -37,6 +37,13 @@ public:
hdr["Accept-Encoding"] = "gzip, deflate, sdch";
hdr["Accept-Language"] = "en-GB,en;q=0.8";
}
+ auto
+ getOutputPath(const char * name, const char * ext)
+ {
+ auto realname
+ = std::unique_ptr<char, decltype(&std::free)> {abi::__cxa_demangle(name, 0, 0, nullptr), std::free};
+ return (binDir / realname.get()).replace_extension(ext);
+ }
};
template<typename T = void> class ChromiumRequestT : public ChromiumRequest {
using ChromiumRequest::ChromiumRequest;
@@ -55,11 +62,6 @@ public:
standardAssertions(const char * name) override
{
BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) {
- auto realname
- = std::unique_ptr<char, decltype(&std::free)> {abi::__cxa_demangle(name, 0, 0, nullptr), std::free};
- const auto outputPath {(binDir / realname.get()).replace_extension(".html")};
- std::ofstream {outputPath} << (output.str());
-
auto h = getResponseHeaders();
BOOST_REQUIRE_EQUAL(h["Status"], "200 OK");
BOOST_REQUIRE_EQUAL(h["Content-Type"], "text/html");
@@ -71,7 +73,7 @@ public:
BOOST_REQUIRE_EQUAL(1, tidyOptSetInt(tdoc, TidyWrapLen, 0));
BOOST_REQUIRE_EQUAL(0, tidyParseSource(tdoc, &tis));
BOOST_CHECK_EQUAL(0, tidyCleanAndRepair(tdoc));
- BOOST_CHECK_EQUAL(0, tidySaveFile(tdoc, outputPath.c_str()));
+ BOOST_CHECK_EQUAL(0, tidySaveFile(tdoc, getOutputPath(name, ".html").c_str()));
BOOST_CHECK_EQUAL(0, tidyRunDiagnostics(tdoc));
tidyRelease(tdoc);
}
@@ -95,24 +97,28 @@ public:
using ChromiumRequestT::ChromiumRequestT;
virtual std::unique_ptr<xmlpp::DomParser>
- standardAssertions(const char *) override
+ standardAssertions(const char * name) override
{
- auto h = getResponseHeaders();
- BOOST_REQUIRE_EQUAL(h["Status"], "200 OK");
- BOOST_REQUIRE_EQUAL(h["Content-Type"], "application/xml");
- BOOST_TEST_INFO(this->output.view());
- BOOST_REQUIRE_NE(this->output.view().find("<?xml version"), std::string_view::npos);
auto p = std::make_unique<xmlpp::DomParser>();
- p->parse_stream(this->output);
+ BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) {
+ auto h = getResponseHeaders();
+ BOOST_REQUIRE_EQUAL(h["Status"], "200 OK");
+ BOOST_REQUIRE_EQUAL(h["Content-Type"], "application/xml");
+ BOOST_REQUIRE_NE(this->output.view().find("<?xml version"), std::string_view::npos);
+ p->parse_stream(this->output);
+ p->get_document()->write_to_file_formatted(getOutputPath(name, ".xml"));
+ }
return p;
}
void
xsdAssertions(const char * name, const std::filesystem::path & xsd)
{
- auto doc = standardAssertions(name);
- xmlpp::XsdValidator validator {xsd};
- validator.validate(doc->get_document());
+ BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) {
+ auto doc = standardAssertions(name);
+ xmlpp::XsdValidator validator {xsd};
+ validator.validate(doc->get_document());
+ }
}
};
@@ -132,15 +138,17 @@ public:
}
virtual std::unique_ptr<xmlpp::DomParser>
- standardAssertions(const char *) override
+ standardAssertions(const char * name) override
{
- auto h = getResponseHeaders();
- BOOST_REQUIRE_EQUAL(h["Status"], "200 OK");
- BOOST_REQUIRE_EQUAL(h["Content-Type"], "application/atom+xml");
- BOOST_TEST_INFO(this->output.view());
- BOOST_REQUIRE_NE(this->output.view().find("<?xml version"), std::string_view::npos);
auto p = std::make_unique<xmlpp::DomParser>();
- p->parse_stream(this->output);
+ BOOST_TEST_CONTEXT(__FUNCTION__ << " : " << name) {
+ auto h = getResponseHeaders();
+ BOOST_REQUIRE_EQUAL(h["Status"], "200 OK");
+ BOOST_REQUIRE_EQUAL(h["Content-Type"], "application/atom+xml");
+ BOOST_REQUIRE_NE(this->output.view().find("<?xml version"), std::string_view::npos);
+ p->parse_stream(this->output);
+ p->get_document()->write_to_file_formatted(getOutputPath(name, ".xml"));
+ }
return p;
}
};