#include "CppUnit/framework/TestCase.h" #include "CppUnit/framework/TestSuite.h" #include "CppUnit/framework/TestCaller.h" #include class NotationTest : public TestCase { SAX2DOM::DOMFactory factory; public: NotationTest(std::string name) : TestCase(name) { } // NotationTest void setUp() { } // setUp void testNull() { DOM::Notation d; DOM::Node n; assert(d == 0); assert(n == 0); assert(n == d); } // testNull void testCreate() { DOM::Document d = factory.newDocument(); DOM::Notation p = d.createNotation("target", "data"); assert(p.getTarget() == "target"); assert(p.getData() == "data"); assert(p.getNodeName() == p.getTarget()); assert(p.getNodeValue() == p.getData()); p.setData("newData"); assert(p.getData() == "newData"); } // testCreate void testConversion() { DOM::Document d = factory.newDocument(); DOM::Notation pi = d.createNotation("target", "data"); DOM::Node n; assert(n != pi); n = pi; assert(n == pi); DOM::Notation pi2; assert(n != pi2); pi2 = static_cast >(n); assert(pi == pi2); assert(n == pi2); } // testConverstion void testEverythingElse() { DOM::Document d = factory.newDocument(); DOM::Notation pi = d.createNotation("target", "data"); assert(pi.getNodeType() == DOM::Node::PROCESSING_INSTRUCTION_NODE); assert(pi.hasAttributes() == false); assert(pi.getAttributes() == 0); assert(pi.getChildNodes() == 0); assert(pi.getFirstChild() == 0); try { pi.appendChild(DOM::Node()); } catch(const DOM::DOMException&) { } assert(pi.getFirstChild() == 0); assert(pi.getOwnerDocument() == d); assert(pi.getParentNode() == 0); d.appendChild(pi); assert(pi.getOwnerDocument() == d); assert(pi.getParentNode() == d); assert(d.getFirstChild() == pi); } // }; TestSuite* NotationTest_suite() { TestSuite *suiteOfTests = new TestSuite; suiteOfTests->addTest(new TestCaller("testNull", NotationTest::testNull)); suiteOfTests->addTest(new TestCaller("testCreate", NotationTest::testCreate)); suiteOfTests->addTest(new TestCaller("testConversion", NotationTest::testConversion)); suiteOfTests->addTest(new TestCaller("testEverythingElse", NotationTest::testEverythingElse)); return suiteOfTests; } // MathTest_suite