parameterised the DOM tests

This commit is contained in:
jez_higgins 2005-10-31 12:07:30 +00:00
parent ac043e277a
commit 0185a7f9dd
25 changed files with 373 additions and 341 deletions

View file

@ -27,7 +27,7 @@ void TestRunner::printBanner ()
cout << "Usage: driver [ -wait ] testName, where name is the name of a test case class" << endl;
} // printBanner
void TestRunner::run(int ac, char **av)
void TestRunner::run(int ac, const char **av)
{
string testCase;
int numberOfTests = 0;

View file

@ -14,7 +14,7 @@ public:
TestRunner() : m_wait(false) {}
~TestRunner();
void run(int ac, char **av);
void run(int ac, const char **av);
void addTest(std::string name, Test *test)
{ m_mappings.push_back(std::make_pair(name, test)); }

View file

@ -142,6 +142,9 @@
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath=".\dom_test_suite.hpp">
</File>
<File
RelativePath=".\main.cpp">
</File>
@ -149,46 +152,6 @@
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath=".\test_Attribute.h">
</File>
<File
RelativePath=".\test_CDATA.hpp">
</File>
<File
RelativePath=".\test_CharacterData.hpp">
</File>
<File
RelativePath=".\test_Document.h">
</File>
<File
RelativePath=".\test_DocumentFragment.h">
</File>
<File
RelativePath=".\test_DocumentType.h">
</File>
<File
RelativePath=".\test_DOMImplementation.h">
</File>
<File
RelativePath=".\test_Element.h">
</File>
<File
RelativePath=".\test_ProcessingInstruction.h">
</File>
<File
RelativePath=".\test_SAX.h">
</File>
<File
RelativePath=".\test_Siblings.h">
</File>
<File
RelativePath=".\test_Text.hpp">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
<Filter
Name="Libs">

View file

@ -1,5 +1,6 @@
-include ../../Makefile.header
-include ../../Makefile.common
######################################
# ADDITIONAL BUILD FLAGS
@ -12,16 +13,27 @@ DYNAMIC_LIBS += -lArabica
######################################
# SOURCE FILES
DOMTEST_SRCS = main.cpp
DOMTEST_HDRS = $(patsubst %.cpp,%.h,$(DOMTEST_SRCS))
DOMTEST_OBJS = $(patsubst %.cpp,%.o,$(DOMTEST_SRCS))
DOMTEST_TESTS = dom_test_suite.hpp \
test_Attribute.h \
test_CDATA.hpp \
test_CharacterData.hpp \
test_DOMImplementation.h \
test_Document.h \
test_DocumentFragment.h \
test_DocumentType.h \
test_Element.h \
test_ProcessingInstruction.h \
test_Siblings.h \
test_Text.hpp
######################################
# High level rules
all : sax2dom_test
all : dom_test
dom_test : $(DOMTEST_OBJS) $(CPPUNIT_OBJS)
$(LD) $(LDFLAGS) -o $@ $(DOMTEST_OBJS) $(CPPUNIT_OBJS) $(LIBS_DIRS) $(STATIC_LIBS) $(DYNAMIC_LIBS)
$(COPY) sax2dom_test$(EXESUFFIX) ../../bin
$(COPY) dom_test$(EXESUFFIX) ../../bin
######################

View file

@ -0,0 +1,41 @@
#ifndef ARABICA_DOM_TEST_SUITE_HPP
#define ARABICA_DOM_TEST_SUITE_HPP
#include "../CppUnit/TestRunner.hpp"
#include "../CppUnit/framework/Test.h"
#include "../CppUnit/framework/TestSuite.h"
#include "test_DOMImplementation.h"
#include "test_DocumentType.h"
#include "test_Document.h"
#include "test_ProcessingInstruction.h"
#include "test_Siblings.h"
#include "test_Element.h"
#include "test_DocumentFragment.h"
#include "test_Attribute.h"
#include "test_Text.hpp"
#include "test_CDATA.hpp"
#include "test_CharacterData.hpp"
template<class string_type, class string_adaptor>
void DOM_test_suite(int argc, const char** argv)
{
TestRunner runner;
runner.addTest("DOMImplementationTest", DOMImplementationTest_suite<string_type, string_adaptor >());
runner.addTest("DocumentTypeTest", DocumentTypeTest_suite<string_type, string_adaptor >());
runner.addTest("DocumentTest", DocumentTest_suite<string_type, string_adaptor >());
runner.addTest("SiblingsTest", SiblingsTest_suite<string_type, string_adaptor >());
runner.addTest("ElementTest", ElementTest_suite<string_type, string_adaptor >());
runner.addTest("AttributeTest", AttrTest_suite<string_type, string_adaptor >());
runner.addTest("ProcessingInstructionTest", ProcessingInstructionTest_suite<string_type, string_adaptor >());
runner.addTest("TextTest", TextTest_suite<string_type, string_adaptor >());
runner.addTest("CDATATest", CDATATest_suite<string_type, string_adaptor >());
runner.addTest("CharacterDataText", CharacterDataTest_suite<string_type, string_adaptor >());
runner.addTest("DocumentFragmentTest", DocumentFragmentTest_suite<string_type, string_adaptor >());
runner.run(argc, argv);
} // main
#endif

View file

@ -1,46 +1,13 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503)
#endif
#include <iostream>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include "../CppUnit/TestRunner.hpp"
#include "../CppUnit/framework/Test.h"
#include "../CppUnit/framework/TestSuite.h"
#include "test_DOMImplementation.h"
#include "test_DocumentType.h"
#include "test_Document.h"
#include "test_ProcessingInstruction.h"
#include "test_Siblings.h"
#include "test_Element.h"
#include "test_DocumentFragment.h"
#include "test_Attribute.h"
#include "test_Text.hpp"
#include "test_CDATA.hpp"
#include "test_CharacterData.hpp"
#include "dom_test_suite.hpp"
////////////////////////////////////////////////
int main(int argc, char* argv[])
int main(int argc, const char* argv[])
{
TestRunner runner;
runner.addTest("DOMImplementationTest", DOMImplementationTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("DocumentTypeTest", DocumentTypeTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("DocumentTest", DocumentTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("SiblingsTest", SiblingsTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("ElementTest", ElementTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("AttributeTest", AttrTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("ProcessingInstructionTest", ProcessingInstructionTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("TextTest", TextTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("CDATATest", CDATATest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("CharacterDataText", CharacterDataTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.addTest("DocumentFragmentTest", DocumentFragmentTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
runner.run(argc, argv);
DOM_test_suite<std::string, Arabica::default_string_adaptor<std::string> >(argc, argv);
return 0;
} // main

View file

@ -21,7 +21,7 @@ class CDATATest : public TestCase
void setUp()
{
factory = SimpleDOM::DOMImplementation<string_type>::getDOMImplementation();
factory = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
} // setUp
void testNull()
@ -149,4 +149,5 @@ TestSuite* CDATATest_suite()
} // CDATATest_suite
#endif
#endif

View file

@ -21,7 +21,7 @@ class CharacterDataTest : public TestCase
void setUp()
{
factory = SimpleDOM::DOMImplementation<string_type>::getDOMImplementation();
factory = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
} // setUp
void testNull()
@ -157,4 +157,5 @@ TestSuite* CharacterDataTest_suite()
return suiteOfTests;
} // CharacterDataTest_suite
#endif
#endif

View file

@ -11,6 +11,8 @@ template<class string_type, class string_adaptor>
class DocumentTest : public TestCase
{
DOM::DOMImplementation<string_type> factory;
typedef string_adaptor SA;
public:
DocumentTest(std::string name) :
@ -20,7 +22,7 @@ class DocumentTest : public TestCase
void setUp()
{
factory = SimpleDOM::DOMImplementation<string_type>::getDOMImplementation();
factory = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
} // setUp
void testNull()
@ -34,10 +36,10 @@ class DocumentTest : public TestCase
void testAssignment()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
assert(d != 0);
assert(d.getNodeName() == "#document");
assert(d.getNodeValue() == "");
assert(d.getNodeName() == SA::construct_from_utf8("#document"));
assert(d.getNodeValue() == SA::construct_from_utf8(""));
DOM::Node<string_type> n;
assert(n == 0);
@ -55,7 +57,7 @@ class DocumentTest : public TestCase
assert(d == d2);
assert(d2 == d);
DOM::Document<string_type> d3 = factory.createDocument("","", 0);
DOM::Document<string_type> d3 = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
assert(d != d3);
assert(d3!= d);
d3 = d;
@ -65,11 +67,11 @@ class DocumentTest : public TestCase
void testDocElem()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::NodeList<string_type> nl = d.getChildNodes();
assert(nl.getLength() == 0);
DOM::Element<string_type> elem = d.createElement("root");
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
assert(elem.getParentNode() == 0);
assert(elem.getOwnerDocument() == d);
@ -82,7 +84,7 @@ class DocumentTest : public TestCase
assert(d.getFirstChild() == elem);
assert(nl.item(0) == elem);
DOM::Element<string_type> elem2 = d.createElement("root1");
DOM::Element<string_type> elem2 = d.createElement(SA::construct_from_utf8("root1"));
try
{
d.appendChild(elem2);
@ -108,11 +110,11 @@ class DocumentTest : public TestCase
void test4()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
d.appendChild(d.createElement("root"));
d.getFirstChild().appendChild(d.createElement("child"));
d.getFirstChild().appendChild(d.createElement("child2"));
d.getFirstChild().appendChild(d.createElement("child3"));
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
d.appendChild(d.createElement(SA::construct_from_utf8("root")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child2")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child3")));
DOM::Document<string_type> clone = DOM::Document<string_type>(d.cloneNode(false));
assert(clone.getFirstChild() == 0);
@ -120,25 +122,25 @@ class DocumentTest : public TestCase
void test5()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
d.appendChild(d.createElement("root"));
d.getFirstChild().appendChild(d.createElement("child"));
d.getFirstChild().appendChild(d.createElement("child2"));
d.getFirstChild().appendChild(d.createElement("child3"));
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
d.appendChild(d.createElement(SA::construct_from_utf8("root")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child2")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child3")));
DOM::Document<string_type> clone = DOM::Document<string_type>(d.cloneNode(true));
assert(clone.getFirstChild().getNodeName() == "root");
assert(clone.getFirstChild().getFirstChild().getNodeName() == "child");
assert(clone.getFirstChild().getLastChild().getNodeName() == "child3");
assert(clone.getFirstChild().getNodeName() == SA::construct_from_utf8("root"));
assert(clone.getFirstChild().getFirstChild().getNodeName() == SA::construct_from_utf8("child"));
assert(clone.getFirstChild().getLastChild().getNodeName() == SA::construct_from_utf8("child3"));
} // test5
void test6()
{
DOM::Document<string_type> d1 = factory.createDocument("","", 0);
DOM::Document<string_type> d2 = factory.createDocument("","", 0);
DOM::Document<string_type> d1 = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Document<string_type> d2 = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Attr<string_type> a1 = d1.createAttribute("attr");
a1.setNodeValue("value");
DOM::Attr<string_type> a1 = d1.createAttribute(SA::construct_from_utf8("attr"));
a1.setNodeValue(SA::construct_from_utf8("value"));
DOM::Node<string_type> a2 = d2.importNode(a1, true);
assert(a2.getNodeType() == DOM::Node<string_type>::ATTRIBUTE_NODE);
@ -146,7 +148,7 @@ class DocumentTest : public TestCase
assert(a2.getNodeValue() == a1.getNodeValue());
assert(a2.getOwnerDocument() == d2);
assert(a2.getChildNodes().getLength() == 1);
assert(a2.getFirstChild().getNodeValue() == "value");
assert(a2.getFirstChild().getNodeValue() == SA::construct_from_utf8("value"));
DOM::Attr<string_type> asAttr = DOM::Attr<string_type>(a2);
assert(asAttr.getSpecified());
assert(asAttr.getOwnerElement() == 0);
@ -154,18 +156,18 @@ class DocumentTest : public TestCase
void test7()
{
DOM::Document<string_type> d1 = factory.createDocument("","", 0);
DOM::Document<string_type> d2 = factory.createDocument("","", 0);
DOM::Document<string_type> d1 = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Document<string_type> d2 = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::DocumentFragment<string_type> df1 = d1.createDocumentFragment();
df1.appendChild(d1.createElement("c1"));
df1.appendChild(d1.createElement("c2"));
df1.appendChild(d1.createElement("c3"));
df1.appendChild(d1.createElement("c4"));
df1.getFirstChild().appendChild(d1.createElement("sc1"));
df1.getFirstChild().appendChild(d1.createElement("sc2"));
df1.getFirstChild().appendChild(d1.createElement("sc3"));
df1.getFirstChild().appendChild(d1.createElement("sc4"));
df1.appendChild(d1.createElement(SA::construct_from_utf8("c1")));
df1.appendChild(d1.createElement(SA::construct_from_utf8("c2")));
df1.appendChild(d1.createElement(SA::construct_from_utf8("c3")));
df1.appendChild(d1.createElement(SA::construct_from_utf8("c4")));
df1.getFirstChild().appendChild(d1.createElement(SA::construct_from_utf8("sc1")));
df1.getFirstChild().appendChild(d1.createElement(SA::construct_from_utf8("sc2")));
df1.getFirstChild().appendChild(d1.createElement(SA::construct_from_utf8("c3")));
df1.getFirstChild().appendChild(d1.createElement(SA::construct_from_utf8("c4")));
DOM::Node<string_type> df2nc = d2.importNode(df1, false);
assert(df2nc.getOwnerDocument() == d2);
@ -177,116 +179,116 @@ class DocumentTest : public TestCase
assert(df2.getChildNodes().getLength() == 4);
assert(df2.getFirstChild().getChildNodes().getLength() == 4);
DOM::NodeList<string_type> c = df2.getChildNodes();
assert(c.item(0).getNodeName() == "c1");
assert(c.item(1).getNodeName() == "c2");
assert(c.item(2).getNodeName() == "c3");
assert(c.item(3).getNodeName() == "c4");
assert(c.item(0).getNodeName() == SA::construct_from_utf8("c1"));
assert(c.item(1).getNodeName() == SA::construct_from_utf8("c2"));
assert(c.item(2).getNodeName() == SA::construct_from_utf8("c3"));
assert(c.item(3).getNodeName() == SA::construct_from_utf8("c4"));
assert(c.item(0).getChildNodes().getLength() == 4);
assert(c.item(1).getChildNodes().getLength() == 0);
assert(c.item(2).getChildNodes().getLength() == 0);
assert(c.item(3).getChildNodes().getLength() == 0);
c = df2.getFirstChild().getChildNodes();
assert(c.item(0).getNodeName() == "sc1");
assert(c.item(1).getNodeName() == "sc2");
assert(c.item(2).getNodeName() == "sc3");
assert(c.item(3).getNodeName() == "sc4");
assert(c.item(0).getNodeName() == SA::construct_from_utf8("sc1"));
assert(c.item(1).getNodeName() == SA::construct_from_utf8("sc2"));
assert(c.item(2).getNodeName() == SA::construct_from_utf8("c3"));
assert(c.item(3).getNodeName() == SA::construct_from_utf8("c4"));
} // test7
void test8()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
d.appendChild(d.createElement("root"));
d.getFirstChild().appendChild(d.createElement("child"));
d.getFirstChild().appendChild(d.createElement("child"));
d.getFirstChild().appendChild(d.createElement("child"));
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
d.appendChild(d.createElement(SA::construct_from_utf8("root")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child")));
d.getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child")));
assert(d.getElementsByTagName("boots").getLength() == 0);
assert(d.getElementsByTagName("root").getLength() == 1);
assert(d.getElementsByTagName("*").getLength() == 4);
assert(d.getElementsByTagNameNS("*", "*").getLength() == 4);
assert(d.getElementsByTagName(SA::construct_from_utf8("boots")).getLength() == 0);
assert(d.getElementsByTagName(SA::construct_from_utf8("root")).getLength() == 1);
assert(d.getElementsByTagName(SA::construct_from_utf8("*")).getLength() == 4);
assert(d.getElementsByTagNameNS(SA::construct_from_utf8("*"), SA::construct_from_utf8("*")).getLength() == 4);
DOM::NodeList<string_type> children = d.getElementsByTagName("child");
DOM::NodeList<string_type> children = d.getElementsByTagName(SA::construct_from_utf8("child"));
assert(children.getLength() == 3);
assert(children.item(0) == d.getFirstChild().getFirstChild());
d.getFirstChild().getFirstChild().appendChild(d.createElement("donkey"));
d.getFirstChild().getFirstChild().appendChild(d.createElement("child"));
d.getFirstChild().getFirstChild().appendChild(d.createElement("donkey"));
d.getFirstChild().getLastChild().appendChild(d.createElement("donkey"));
d.getFirstChild().getLastChild().appendChild(d.createElement("child"));
d.getFirstChild().getLastChild().appendChild(d.createElement("donkey"));
d.getFirstChild().getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("donkey")));
d.getFirstChild().getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("child")));
d.getFirstChild().getFirstChild().appendChild(d.createElement(SA::construct_from_utf8("donkey")));
d.getFirstChild().getLastChild().appendChild(d.createElement(SA::construct_from_utf8("donkey")));
d.getFirstChild().getLastChild().appendChild(d.createElement(SA::construct_from_utf8("child")));
d.getFirstChild().getLastChild().appendChild(d.createElement(SA::construct_from_utf8("donkey")));
assert(children.getLength() == 5);
assert(DOM::Element<string_type>(d.getFirstChild().getFirstChild()).getElementsByTagName("donkey").getLength() == 2);
assert(DOM::Element<string_type>(d.getFirstChild()).getElementsByTagName("donkey").getLength() == 4);
assert(DOM::Element<string_type>(d.getFirstChild().getFirstChild()).getElementsByTagName(SA::construct_from_utf8("donkey")).getLength() == 2);
assert(DOM::Element<string_type>(d.getFirstChild()).getElementsByTagName(SA::construct_from_utf8("donkey")).getLength() == 4);
} // test8
void test9()
{
DOM::Document<string_type> d = factory.createDocument("","root", 0);
assert(d.getFirstChild().getNodeName() == "root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8("root"), 0);
assert(d.getFirstChild().getNodeName() == SA::construct_from_utf8("root"));
assert(d.getFirstChild().hasPrefix() == false);
assert(d.getFirstChild().hasNamespaceURI() == false);
assert(d.getFirstChild().getLocalName() == "root");
assert(d.getFirstChild().getPrefix() == "");
assert(d.getFirstChild().getNamespaceURI() == "");
assert(d.getFirstChild().getLocalName() == SA::construct_from_utf8("root"));
assert(d.getFirstChild().getPrefix() == SA::construct_from_utf8(""));
assert(d.getFirstChild().getNamespaceURI() == SA::construct_from_utf8(""));
} // test9
void test10()
{
DOM::Document<string_type> d = factory.createDocument("http://test/test","test:root", 0);
assert(d.getFirstChild().getNodeName() == "test:root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8("http://test/test"), SA::construct_from_utf8("test:root"), 0);
assert(d.getFirstChild().getNodeName() == SA::construct_from_utf8("test:root"));
assert(d.getFirstChild().hasPrefix() == true);
assert(d.getFirstChild().hasNamespaceURI() == true);
assert(d.getFirstChild().getLocalName() == "root");
assert(d.getFirstChild().getPrefix() == "test");
assert(d.getFirstChild().getNamespaceURI() == "http://test/test");
assert(d.getFirstChild().getLocalName() == SA::construct_from_utf8("root"));
assert(d.getFirstChild().getPrefix() == SA::construct_from_utf8("test"));
assert(d.getFirstChild().getNamespaceURI() == SA::construct_from_utf8("http://test/test"));
} // test10
void test11()
{
DOM::Document<string_type> d = factory.createDocument("http://test/test","root", 0);
assert(d.getFirstChild().getNodeName() == "root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8("http://test/test"), SA::construct_from_utf8("root"), 0);
assert(d.getFirstChild().getNodeName() == SA::construct_from_utf8("root"));
assert(d.getFirstChild().hasPrefix() == false);
assert(d.getFirstChild().hasNamespaceURI() == true);
assert(d.getFirstChild().getLocalName() == "root");
assert(d.getFirstChild().getPrefix() == "");
assert(d.getFirstChild().getNamespaceURI() == "http://test/test");
assert(d.getFirstChild().getLocalName() == SA::construct_from_utf8("root"));
assert(d.getFirstChild().getPrefix() == SA::construct_from_utf8(""));
assert(d.getFirstChild().getNamespaceURI() == SA::construct_from_utf8("http://test/test"));
} // test11
void test12()
{
DOM::Document<string_type> d = factory.createDocument("http://test/test","root", 0);
assert(d.getFirstChild().getNodeName() == "root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8("http://test/test"), SA::construct_from_utf8("root"), 0);
assert(d.getFirstChild().getNodeName() == SA::construct_from_utf8("root"));
assert(d.getFirstChild().hasPrefix() == false);
assert(d.getFirstChild().hasNamespaceURI() == true);
assert(d.getFirstChild().getLocalName() == "root");
assert(d.getFirstChild().getPrefix() == "");
assert(d.getFirstChild().getNamespaceURI() == "http://test/test");
assert(d.getFirstChild().getLocalName() == SA::construct_from_utf8("root"));
assert(d.getFirstChild().getPrefix() == SA::construct_from_utf8(""));
assert(d.getFirstChild().getNamespaceURI() == SA::construct_from_utf8("http://test/test"));
d.getFirstChild().setPrefix("test");
assert(d.getFirstChild().getNodeName() == "test:root");
d.getFirstChild().setPrefix(SA::construct_from_utf8("test"));
assert(d.getFirstChild().getNodeName() == SA::construct_from_utf8("test:root"));
assert(d.getFirstChild().hasPrefix() == true);
assert(d.getFirstChild().hasNamespaceURI() == true);
assert(d.getFirstChild().getLocalName() == "root");
assert(d.getFirstChild().getPrefix() == "test");
assert(d.getFirstChild().getNamespaceURI() == "http://test/test");
assert(d.getFirstChild().getLocalName() == SA::construct_from_utf8("root"));
assert(d.getFirstChild().getPrefix() == SA::construct_from_utf8("test"));
assert(d.getFirstChild().getNamespaceURI() == SA::construct_from_utf8("http://test/test"));
} // test12
void test13()
{
DOM::Document<string_type> d = factory.createDocument("http://test/test","root", 0);
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8("http://test/test"), SA::construct_from_utf8("root"), 0);
DOM::Element<string_type> root = d.getDocumentElement();
root.appendChild(d.createTextNode("hello "));
root.appendChild(d.createTextNode("mother, " ));
root.appendChild(d.createTextNode("how "));
root.appendChild(d.createTextNode("are "));
root.appendChild(d.createTextNode("you?"));
root.appendChild(d.createTextNode(SA::construct_from_utf8("hello ")));
root.appendChild(d.createTextNode(SA::construct_from_utf8("mother, ")));
root.appendChild(d.createTextNode(SA::construct_from_utf8("how ")));
root.appendChild(d.createTextNode(SA::construct_from_utf8("are ")));
root.appendChild(d.createTextNode(SA::construct_from_utf8("you?")));
assert(root.getChildNodes().getLength() == 5);
root.normalize();
assert(root.getChildNodes().getLength() == 1);
assert(root.getFirstChild().getNodeValue() == "hello mother, how are you?");
assert(root.getFirstChild().getNodeValue() == SA::construct_from_utf8("hello mother, how are you?"));
} // test13
};

View file

@ -11,6 +11,7 @@ template<class string_type, class string_adaptor>
class DocumentFragmentTest : public TestCase
{
DOM::DOMImplementation<string_type> factory;
typedef string_adaptor SA;
public:
DocumentFragmentTest(std::string name) :
@ -20,7 +21,7 @@ class DocumentFragmentTest : public TestCase
void setUp()
{
factory = SimpleDOM::DOMImplementation<string_type>::getDOMImplementation();
factory = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
} // setUp
void test1()
@ -34,67 +35,67 @@ class DocumentFragmentTest : public TestCase
void test2()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::DocumentFragment<string_type> frag = d.createDocumentFragment();
frag.appendChild(d.createElement("child"));
frag.appendChild(d.createElement("child2"));
frag.appendChild(d.createElement("child3"));
frag.appendChild(d.createElement(SA::construct_from_utf8("child")));
frag.appendChild(d.createElement(SA::construct_from_utf8("child2")));
frag.appendChild(d.createElement(SA::construct_from_utf8("child3")));
assert(frag.getChildNodes().getLength() == 3);
} // test2
void test3()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::DocumentFragment<string_type> frag = d.createDocumentFragment();
frag.appendChild(d.createElement("child"));
frag.appendChild(d.createElement("child2"));
frag.appendChild(d.createElement("child3"));
frag.appendChild(d.createElement(SA::construct_from_utf8("child")));
frag.appendChild(d.createElement(SA::construct_from_utf8("child2")));
frag.appendChild(d.createElement(SA::construct_from_utf8("child3")));
DOM::Element<string_type> elem = d.createElement("root");
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
elem.appendChild(frag);
assert(elem.getChildNodes().getLength() == 3);
assert(elem.getFirstChild().getNodeName() == "child");
assert(elem.getLastChild().getNodeName() == "child3");
assert(elem.getFirstChild().getNodeName() == SA::construct_from_utf8("child"));
assert(elem.getLastChild().getNodeName() == SA::construct_from_utf8("child3"));
assert(frag.getChildNodes().getLength() == 0);
} // test3
void test4()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::DocumentFragment<string_type> frag = d.createDocumentFragment();
frag.appendChild(d.createElement("child"));
frag.appendChild(d.createElement("child2"));
frag.appendChild(d.createElement("child3"));
frag.appendChild(d.createElement(SA::construct_from_utf8("child")));
frag.appendChild(d.createElement(SA::construct_from_utf8("child2")));
frag.appendChild(d.createElement(SA::construct_from_utf8("child3")));
DOM::Element<string_type> elem = d.createElement("root");
elem.appendChild(d.createElement("t"));
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
elem.appendChild(d.createElement(SA::construct_from_utf8("t")));
assert(elem.getChildNodes().getLength() == 1);
elem.replaceChild(frag, elem.getFirstChild());
assert(elem.getChildNodes().getLength() == 3);
assert(elem.getFirstChild().getNodeName() == "child");
assert(elem.getLastChild().getNodeName() == "child3");
assert(elem.getFirstChild().getNodeName() == SA::construct_from_utf8("child"));
assert(elem.getLastChild().getNodeName() == SA::construct_from_utf8("child3"));
assert(frag.getChildNodes().getLength() == 0);
} // test4
void test5()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::DocumentFragment<string_type> frag = d.createDocumentFragment();
frag.appendChild(d.createElement("child"));
frag.appendChild(d.createElement("child2"));
frag.appendChild(d.createElement("child3"));
frag.appendChild(d.createElement(SA::construct_from_utf8("child")));
frag.appendChild(d.createElement(SA::construct_from_utf8("child2")));
frag.appendChild(d.createElement(SA::construct_from_utf8("child3")));
DOM::Element<string_type> elem = d.createElement("root");
elem.appendChild(d.createElement("t"));
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
elem.appendChild(d.createElement(SA::construct_from_utf8("t")));
assert(elem.getChildNodes().getLength() == 1);
elem.insertBefore(frag, elem.getFirstChild());
assert(elem.getChildNodes().getLength() == 4);
assert(elem.getFirstChild().getNodeName() == "child");
assert(elem.getLastChild().getNodeName() == "t");
assert(elem.getFirstChild().getNodeName() == SA::construct_from_utf8("child"));
assert(elem.getLastChild().getNodeName() == SA::construct_from_utf8("t"));
assert(frag.getChildNodes().getLength() == 0);
} // test5
};

View file

@ -11,6 +11,7 @@ template<class string_type, class string_adaptor>
class ElementTest : public TestCase
{
DOM::DOMImplementation<string_type> factory;
typedef string_adaptor SA;
public:
ElementTest(std::string name) :
@ -20,7 +21,7 @@ class ElementTest : public TestCase
void setUp()
{
factory = SimpleDOM::DOMImplementation<string_type>::getDOMImplementation();
factory = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
} // setUp
void test1()
@ -34,26 +35,26 @@ class ElementTest : public TestCase
void test2()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Element<string_type> elem = d.createElement("root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
assert(elem.getParentNode() == 0);
assert(elem.getOwnerDocument() == d);
d.appendChild(elem);
DOM::Element<string_type> child = d.createElement("child");
DOM::Element<string_type> child = d.createElement(SA::construct_from_utf8("child"));
elem.appendChild(child);
} // test2
void test3()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Element<string_type> elem = d.createElement("root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
assert(elem.getParentNode() == 0);
assert(elem.getOwnerDocument() == d);
d.appendChild(elem);
DOM::Attr<string_type> attr = d.createAttribute("attr");
attr.setNodeValue("trousers");
DOM::Attr<string_type> attr = d.createAttribute(SA::construct_from_utf8("attr"));
attr.setNodeValue(SA::construct_from_utf8("trousers"));
try
{
elem.appendChild(attr);
@ -64,83 +65,83 @@ class ElementTest : public TestCase
void test4()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Element<string_type> elem = d.createElement("root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
assert(elem.getParentNode() == 0);
assert(elem.getOwnerDocument() == d);
d.appendChild(elem);
DOM::Attr<string_type> attr = d.createAttribute("attr");
DOM::Attr<string_type> attr = d.createAttribute(SA::construct_from_utf8("attr"));
elem.setAttributeNode(attr);
assert(elem.getAttributeNode("attr") == attr);
assert(elem.getAttributeNode(SA::construct_from_utf8("attr")) == attr);
assert(elem.removeAttributeNode(attr) == attr);
} // test4
void test5()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Element<string_type> elem = d.createElement("root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
assert(elem.getParentNode() == 0);
assert(elem.getOwnerDocument() == d);
d.appendChild(elem);
assert(elem.hasAttributes() == false);
assert(elem.hasAttribute("attr") == false);
elem.setAttribute("attr", "poop");
assert(elem.hasAttribute(SA::construct_from_utf8("attr")) == false);
elem.setAttribute(SA::construct_from_utf8("attr"), SA::construct_from_utf8("poop"));
assert(elem.hasAttributes() == true);
assert(elem.hasAttribute("attr") == true);
assert(elem.hasAttribute(SA::construct_from_utf8("attr")) == true);
DOM::Node<string_type> n = elem.getAttributeNode("attr");
assert(n.getNodeValue() == "poop");
assert(elem.setAttributeNode(d.createAttribute("attr")) == n);
DOM::Node<string_type> n = elem.getAttributeNode(SA::construct_from_utf8("attr"));
assert(n.getNodeValue() == SA::construct_from_utf8("poop"));
assert(elem.setAttributeNode(d.createAttribute(SA::construct_from_utf8("attr"))) == n);
} // test5
void test6()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Element<string_type> elem = d.createElement("root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
assert(elem.getParentNode() == 0);
assert(elem.getOwnerDocument() == d);
d.appendChild(elem);
assert(elem.hasAttributes() == false);
assert(elem.hasAttribute("attr") == false);
elem.setAttribute("attr", "poop");
assert(elem.hasAttribute(SA::construct_from_utf8("attr")) == false);
elem.setAttribute(SA::construct_from_utf8("attr"), SA::construct_from_utf8("poop"));
assert(elem.hasAttributes() == true);
assert(elem.hasAttribute("attr") == true);
elem.removeAttribute("attr");
assert(elem.hasAttribute(SA::construct_from_utf8("attr")) == true);
elem.removeAttribute(SA::construct_from_utf8("attr"));
assert(elem.hasAttributes() == false);
assert(elem.hasAttribute("attr") == false);
assert(elem.hasAttribute(SA::construct_from_utf8("attr")) == false);
} // test6
void test7()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Element<string_type> elem = d.createElement("root");
elem.setAttribute("attr", "poop");
elem.appendChild(d.createElement("child"));
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
elem.setAttribute(SA::construct_from_utf8("attr"), SA::construct_from_utf8("poop"));
elem.appendChild(d.createElement(SA::construct_from_utf8("child")));
DOM::Element<string_type> e2 = DOM::Element<string_type>(elem.cloneNode(false));
assert(e2.getOwnerDocument() == d);
assert(e2.getParentNode() == 0);
assert(e2.hasAttributes() == true);
assert(e2.getAttribute("attr") == "poop");
assert(e2.getAttribute(SA::construct_from_utf8("attr")) == SA::construct_from_utf8("poop"));
assert(e2.getFirstChild() == 0);
} // test7
void test8()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Element<string_type> elem = d.createElement("root");
elem.setAttribute("attr", "poop");
elem.appendChild(d.createElement("child"));
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Element<string_type> elem = d.createElement(SA::construct_from_utf8("root"));
elem.setAttribute(SA::construct_from_utf8("attr"), SA::construct_from_utf8("poop"));
elem.appendChild(d.createElement(SA::construct_from_utf8("child")));
DOM::Element<string_type> e2 = DOM::Element<string_type>(elem.cloneNode(true));
assert(e2.getOwnerDocument() == d);
assert(e2.getParentNode() == 0);
assert(e2.hasAttributes() == true);
assert(e2.getAttribute("attr") == "poop");
assert(e2.getFirstChild().getNodeName() == "child");
assert(e2.getAttribute(SA::construct_from_utf8("attr")) == SA::construct_from_utf8("poop"));
assert(e2.getFirstChild().getNodeName() == SA::construct_from_utf8("child"));
} // test
};

View file

@ -21,7 +21,7 @@ class PITest : public TestCase
void setUp()
{
factory = SimpleDOM::DOMImplementation<string_type>::getDOMImplementation();
factory = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
} // setUp
void testNull()

View file

@ -11,6 +11,7 @@ template<class string_type, class string_adaptor>
class SiblingsTest : public TestCase
{
DOM::DOMImplementation<string_type> factory;
typedef string_adaptor SA;
public:
SiblingsTest(std::string name) :
@ -20,19 +21,19 @@ class SiblingsTest : public TestCase
void setUp()
{
factory = SimpleDOM::DOMImplementation<string_type>::getDOMImplementation();
factory = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
} // setUp
void test1()
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
DOM::Element<string_type> root = d.createElement("root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
DOM::Element<string_type> root = d.createElement(SA::construct_from_utf8("root"));
d.appendChild(root);
assert(root.getPreviousSibling() == 0);
assert(root.getNextSibling() == 0);
DOM::ProcessingInstruction<string_type> p = d.createProcessingInstruction("target", "data");
DOM::ProcessingInstruction<string_type> p = d.createProcessingInstruction(SA::construct_from_utf8("target"), SA::construct_from_utf8("data"));
d.insertBefore(p, root);
assert(d.getFirstChild() == p);
assert(d.getLastChild() == root);
@ -41,7 +42,7 @@ class SiblingsTest : public TestCase
assert(root.getPreviousSibling() == p);
assert(root.getNextSibling() == 0);
DOM::ProcessingInstruction<string_type> p2 = d.createProcessingInstruction("target", "data");
DOM::ProcessingInstruction<string_type> p2 = d.createProcessingInstruction(SA::construct_from_utf8("target"), SA::construct_from_utf8("data"));
d.insertBefore(p2, root);
assert(d.getFirstChild() == p);
assert(d.getLastChild() == root);
@ -107,21 +108,21 @@ class SiblingsTest : public TestCase
{
DOM::Element<string_type> root;
{
DOM::Document<string_type> d = factory.createDocument("","", 0);
root = d.createElement("root");
DOM::Document<string_type> d = factory.createDocument(SA::construct_from_utf8(""), SA::construct_from_utf8(""), 0);
root = d.createElement(SA::construct_from_utf8("root"));
d.appendChild(root);
assert(root.getPreviousSibling() == 0);
assert(root.getNextSibling() == 0);
DOM::ProcessingInstruction<string_type> p = d.createProcessingInstruction("target", "data");
DOM::ProcessingInstruction<string_type> p = d.createProcessingInstruction(SA::construct_from_utf8("target"), SA::construct_from_utf8("data"));
d.insertBefore(p, root);
}
DOM::Node<string_type> n = root.getPreviousSibling();
DOM::ProcessingInstruction<string_type> p = DOM::ProcessingInstruction<string_type>(n);
assert(p.getTarget() == "target");
assert(p.getData() == "data");
assert(p.getTarget() == SA::construct_from_utf8("target"));
assert(p.getData() == SA::construct_from_utf8("data"));
} // test2
};

View file

@ -21,7 +21,7 @@ class TextTest : public TestCase
void setUp()
{
factory = SimpleDOM::DOMImplementation<string_type>::getDOMImplementation();
factory = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
} // setUp
void testNull()
@ -117,4 +117,5 @@ TestSuite* TextTest_suite()
return suiteOfTests;
} // TextTest_suite
#endif
#endif

View file

@ -152,46 +152,12 @@
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\Dom\dom_test_suite.hpp">
</File>
<File
RelativePath="..\silly_string\silly_string.hpp">
</File>
<File
RelativePath="..\Dom\test_Attribute.h">
</File>
<File
RelativePath="..\Dom\test_CDATA.hpp">
</File>
<File
RelativePath="..\Dom\test_CharacterData.hpp">
</File>
<File
RelativePath="..\Dom\test_Document.h">
</File>
<File
RelativePath="..\Dom\test_DocumentFragment.h">
</File>
<File
RelativePath="..\Dom\test_DocumentType.h">
</File>
<File
RelativePath="..\Dom\test_DOMImplementation.h">
</File>
<File
RelativePath="..\Dom\test_Element.h">
</File>
<File
RelativePath="..\Dom\test_ProcessingInstruction.h">
</File>
<File
RelativePath="..\Dom\test_Siblings.h">
</File>
<File
RelativePath="..\Dom\test_Text.hpp">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
<Filter
Name="Libs">

52
test/DOM_silly/Makefile Normal file
View file

@ -0,0 +1,52 @@
-include ../../Makefile.header
-include ../../Makefile.common
######################################
# ADDITIONAL BUILD FLAGS
INCS_DIRS += -I../..
LIBS_DIRS += -L../../bin
STATIC_LIBS +=
DYNAMIC_LIBS += -lArabica
######################################
# SOURCE FILES
DOMTEST_SRCS = main.cpp ../silly_string/silly_string.cpp
DOMTEST_OBJS = $(patsubst %.cpp,%.o,$(DOMTEST_SRCS))
DOMTEST_TESTS = ..\DOM\dom_test_suite.hpp \
..\DOM\test_Attribute.h \
..\DOM\test_CDATA.hpp \
..\DOM\test_CharacterData.hpp \
..\DOM\test_DOMImplementation.h \
..\DOM\test_Document.h \
..\DOM\test_DocumentFragment.h \
..\DOM\test_DocumentType.h \
..\DOM\test_Element.h \
..\DOM\test_ProcessingInstruction.h \
..\DOM\test_Siblings.h \
..\DOM\test_Text.hpp
######################################
# High level rules
all : dom_test_ss
dom_test_ss : $(DOMTEST_OBJS) $(CPPUNIT_OBJS)
$(LD) $(LDFLAGS) -o $@ $(DOMTEST_OBJS) $(CPPUNIT_OBJS) $(LIBS_DIRS) $(STATIC_LIBS) $(DYNAMIC_LIBS)
$(COPY) dom_test_ss$(EXESUFFIX) ../../bin
######################
# Compile rules
####
-include ../../Makefile.rules
######################
# Cleaning up
clean :
$(REMOVE) $(CPPUNIT_OBJS) \
$(DOMTEST_OBJS) \
dom_test_ss$(EXESUFFIX) \
../../bin/dom_test_ss$(EXESUFFIX)
# End of File

View file

@ -1,52 +1,16 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503)
#endif
#include <iostream>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include "../CppUnit/TestRunner.hpp"
#include "../CppUnit/framework/Test.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../DOM/test_DOMImplementation.h"
#include "../DOM/test_DocumentType.h"
//#include "test_Document.h"
#include "../DOM/test_ProcessingInstruction.h"
//#include "test_Siblings.h"
//#include "test_Element.h"
//#include "test_DocumentFragment.h"
#include "../DOM/test_Attribute.h"
#include "../DOM/test_Text.hpp"
#include "../DOM/test_CDATA.hpp"
#include "../DOM/test_CharacterData.hpp"
#include "../DOM/dom_test_suite.hpp"
#include "../silly_string/silly_string.hpp"
template<> class Arabica::default_string_adaptor<silly_string> : public silly_string_adaptor { };
//template<> class Arabica::default_string_adaptor<silly_string> : public silly_string_adaptor { };
////////////////////////////////////////////////
int main(int argc, char* argv[])
int main(int argc, const char* argv[])
{
TestRunner runner;
runner.addTest("DOMImplementationTest", DOMImplementationTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
runner.addTest("DocumentTypeTest", DocumentTypeTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
//runner.addTest("DocumentTest", DocumentTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
//runner.addTest("SiblingsTest", SiblingsTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
//runner.addTest("ElementTest", ElementTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
runner.addTest("AttributeTest", AttrTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
runner.addTest("ProcessingInstructionTest", ProcessingInstructionTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
runner.addTest("TextTest", TextTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
runner.addTest("CDATATest", CDATATest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
runner.addTest("CharacterDataText", CharacterDataTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
//runner.addTest("DocumentFragmentTest", DocumentFragmentTest_suite<silly_string, Arabica::default_string_adaptor<silly_string> >());
runner.run(argc, argv);
DOM_test_suite<silly_string, silly_string_adaptor>(argc, argv);
return 0;
} // main

52
test/DOM_wide/Makefile Normal file
View file

@ -0,0 +1,52 @@
-include ../../Makefile.header
-include ../../Makefile.common
######################################
# ADDITIONAL BUILD FLAGS
INCS_DIRS += -I../..
LIBS_DIRS += -L../../bin
STATIC_LIBS +=
DYNAMIC_LIBS += -lArabica
######################################
# SOURCE FILES
DOMTEST_SRCS = main.cpp
DOMTEST_OBJS = $(patsubst %.cpp,%.o,$(DOMTEST_SRCS))
DOMTEST_TESTS = ..\DOM\dom_test_suite.hpp \
..\DOM\test_Attribute.h \
..\DOM\test_CDATA.hpp \
..\DOM\test_CharacterData.hpp \
..\DOM\test_DOMImplementation.h \
..\DOM\test_Document.h \
..\DOM\test_DocumentFragment.h \
..\DOM\test_DocumentType.h \
..\DOM\test_Element.h \
..\DOM\test_ProcessingInstruction.h \
..\DOM\test_Siblings.h \
..\DOM\test_Text.hpp
######################################
# High level rules
all : dom_test_wide
dom_test_wide : $(DOMTEST_OBJS) $(CPPUNIT_OBJS)
$(LD) $(LDFLAGS) -o $@ $(DOMTEST_OBJS) $(CPPUNIT_OBJS) $(LIBS_DIRS) $(STATIC_LIBS) $(DYNAMIC_LIBS)
$(COPY) dom_test_wide$(EXESUFFIX) ../../bin
######################
# Compile rules
####
-include ../../Makefile.rules
######################
# Cleaning up
clean :
$(REMOVE) $(CPPUNIT_OBJS) \
$(DOMTEST_OBJS) \
dom_test_wide$(EXESUFFIX) \
../../bin/dom_test_wide$(EXESUFFIX)
# End of File

View file

@ -2,6 +2,8 @@
all:
cd DOM; ${MAKE}
cd DOM_wide; ${MAKE}
cd DOM_silly; ${MAKE}
cd SAX2DOM; ${MAKE}
cd XPath; ${MAKE}
cd XPath_wide; ${MAKE}
@ -9,6 +11,8 @@ all:
clean:
cd DOM; ${MAKE} clean
cd DOM_wide; ${MAKE} clean
cd DOM_silly; ${MAKE} clean
cd SAX2DOM; ${MAKE} clean
cd XPath; ${MAKE} clean
cd XPath_wide; ${MAKE} clean

View file

@ -17,7 +17,7 @@
#include "test_SAX.h"
////////////////////////////////////////////////
int main(int argc, char* argv[])
int main(int argc, const char* argv[])
{
TestRunner runner;

View file

@ -7,7 +7,7 @@
#include "xpath_test_suite.hpp"
/////////////////////////////////////////
int main(int argc, char** argv)
int main(int argc, const char** argv)
{
std::cout << "Hello" << std::endl;

View file

@ -16,7 +16,7 @@
#include "execute_test.hpp"
template<class string_type, class string_adaptor>
void XPath_test_suite(int argc, char** argv)
void XPath_test_suite(int argc, const char** argv)
{
TestRunner runner;

View file

@ -11,7 +11,7 @@
template<> class Arabica::default_string_adaptor<silly_string> : public silly_string_adaptor { };
/////////////////////////////////////////
int main(int argc, char** argv)
int main(int argc, const char** argv)
{
std::cout << "Hello" << std::endl;

View file

@ -7,7 +7,7 @@
#include "../XPath/xpath_test_suite.hpp"
/////////////////////////////////////////
int main(int argc, char** argv)
int main(int argc, const char** argv)
{
std::cout << "Hello" << std::endl;

View file

@ -79,13 +79,16 @@ std::basic_ostream<CharType, Traits>& operator<<(std::basic_ostream<CharType, Tr
return os;
} // operator<<
namespace std {
template<>
struct std::less<silly_string> : public binary_function<silly_string, silly_string, bool>
struct less<silly_string> : public binary_function<silly_string, silly_string, bool>
{ // functor for operator<
bool operator()(const silly_string& lhs, const silly_string& rhs) const
{ // apply operator< to operands
return (silly_string_adaptor::asStdString(lhs) < silly_string_adaptor::asStdString(rhs));
}
};
} // namespace std
#endif