From e17ba6dde7588f717bc5e79b3cb64cddd73d6173 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Tue, 6 May 2014 20:12:11 +0200 Subject: Added basic external read file function test case * ... as a test of how well we are able to test DOM structures * required change of constructDocument visibility --- tests/function_read_file.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/function_read_file.cc (limited to 'tests') diff --git a/tests/function_read_file.cc b/tests/function_read_file.cc new file mode 100644 index 0000000..e0bb8da --- /dev/null +++ b/tests/function_read_file.cc @@ -0,0 +1,43 @@ +#include "gtest/gtest.h" + +#include +#include +#include +#include + +#include + +#include "function/base.h" +#include "function/read_file.h" + +typedef std::basic_string XmlString; + +class FunctionReadFileTest : public ::testing::Test { + friend InputXSLT::FunctionReadFile; +}; + +TEST_F(FunctionReadFileTest, constructDocumentTest) { + const InputXSLT::FilesystemContext fsContext("../tests"); + const boost::filesystem::path filePath( + fsContext.resolve("./function_read_file.cc") + ); + + InputXSLT::FunctionReadFile function; + + xercesc::DOMDocument* const domDocument = function.constructDocument( + fsContext, + filePath + ); + + EXPECT_NE(domDocument, nullptr); + + EXPECT_EQ( + XmlString(domDocument->getDocumentElement()->getNodeName()), + XmlString(reinterpret_cast(u"content")) + ); + + EXPECT_EQ( + XmlString(domDocument->getDocumentElement()->getFirstChild()->getNodeName()), + XmlString(reinterpret_cast(u"result")) + ); +} -- cgit v1.2.3