diff options
Diffstat (limited to 'project2/xml/unittests/testxml.cpp')
-rw-r--r-- | project2/xml/unittests/testxml.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/project2/xml/unittests/testxml.cpp b/project2/xml/unittests/testxml.cpp new file mode 100644 index 0000000..539c0a0 --- /dev/null +++ b/project2/xml/unittests/testxml.cpp @@ -0,0 +1,34 @@ +#define BOOST_TEST_MODULE TestXML +#include <boost/test/unit_test.hpp> + +#include <definedDirs.h> +#include "xmlPresenter.h" +#include "xmlScriptParser.h" +#include <testScriptHost.h> +#include <testOptionsSource.h> +#include <fstream> +#include <logger.h> + +template <typename ... T> +int +systembf(const char * fmt, const T & ... params) +{ + return system(stringbf(fmt, params...).c_str()); +} + +BOOST_AUTO_TEST_CASE( rawview ) +{ + TestOptionsSource::LoadTestOptions({ }); + ScriptReaderPtr s = new XmlScriptParser(RootDir / "rawview.xml"); + boost::intrusive_ptr<TestScriptHost> h = new TestScriptHost(s); + h->executeViews(NULL); + auto p = boost::dynamic_pointer_cast<XmlPresenter>(h->getPresenter(NULL)); + BOOST_REQUIRE(p); + std::fstream strm("/tmp/out.xml", std::ios::out); + BOOST_REQUIRE(strm.is_open()); + p->writeTo(strm, "utf-8", NULL); + BOOST_REQUIRE_EQUAL(0, systembf("diff -w --unified %s %s", + "/tmp/out.xml", + RootDir / "expected" / "rawview.xml")); +} + |