diff options
author | Adrian Kummerländer | 2014-05-06 20:12:11 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-05-06 20:12:11 +0200 |
commit | e17ba6dde7588f717bc5e79b3cb64cddd73d6173 (patch) | |
tree | 537d9beef3960b31ab39ebf80d30ed56c69166a8 /tests | |
parent | 9aad4dffd9c8b0fde534b3abc3c27875547423fa (diff) | |
download | InputXSLT-e17ba6dde7588f717bc5e79b3cb64cddd73d6173.tar InputXSLT-e17ba6dde7588f717bc5e79b3cb64cddd73d6173.tar.gz InputXSLT-e17ba6dde7588f717bc5e79b3cb64cddd73d6173.tar.bz2 InputXSLT-e17ba6dde7588f717bc5e79b3cb64cddd73d6173.tar.lz InputXSLT-e17ba6dde7588f717bc5e79b3cb64cddd73d6173.tar.xz InputXSLT-e17ba6dde7588f717bc5e79b3cb64cddd73d6173.tar.zst InputXSLT-e17ba6dde7588f717bc5e79b3cb64cddd73d6173.zip |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/function_read_file.cc | 43 |
1 files changed, 43 insertions, 0 deletions
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 <xercesc/dom/DOMDocument.hpp> +#include <xercesc/dom/DOMImplementation.hpp> +#include <xercesc/dom/DOMElement.hpp> +#include <xercesc/dom/DOMText.hpp> + +#include <string> + +#include "function/base.h" +#include "function/read_file.h" + +typedef std::basic_string<XMLCh> 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<const XMLCh*>(u"content")) + ); + + EXPECT_EQ( + XmlString(domDocument->getDocumentElement()->getFirstChild()->getNodeName()), + XmlString(reinterpret_cast<const XMLCh*>(u"result")) + ); +} |