#pragma warning(disable: 4786 4250 4503) #include "CppUnit/framework/TestCase.h" #include "CppUnit/framework/TestSuite.h" #include "CppUnit/framework/TestCaller.h" #include class PITest : public TestCase { DOM::DOMImplementation factory; public: PITest(std::string name) : TestCase(name) { } // PITest void setUp() { factory = SimpleDOM::DOMImplementation::getDOMImplementation(); } // setUp void testNull() { DOM::ProcessingInstruction d; DOM::Node n; assert(d == 0); assert(n == 0); assert(n == d); } // testNull void testCreate() { DOM::Document d = factory.createDocument("","", 0); DOM::ProcessingInstruction p = d.createProcessingInstruction("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.createDocument("","", 0); DOM::ProcessingInstruction pi = d.createProcessingInstruction("target", "data"); DOM::Node n; assert(n != pi); n = pi; assert(n == pi); DOM::ProcessingInstruction pi2; assert(n != pi2); pi2 = static_cast >(n); assert(pi == pi2); assert(n == pi2); } // testConverstion void testEverythingElse() { DOM::Document d = factory.createDocument("","", 0); DOM::ProcessingInstruction pi = d.createProcessingInstruction("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* ProcessingInstructionTest_suite() { TestSuite *suiteOfTests = new TestSuite; suiteOfTests->addTest(new TestCaller("testNull", &PITest::testNull)); suiteOfTests->addTest(new TestCaller("testCreate", &PITest::testCreate)); suiteOfTests->addTest(new TestCaller("testConversion", &PITest::testConversion)); suiteOfTests->addTest(new TestCaller("testEverythingElse", &PITest::testEverythingElse)); return suiteOfTests; } // MathTest_suite