mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 19:25:53 +02:00
change EOL to 'native'
This commit is contained in:
@@ -1,266 +1,266 @@
|
||||
//
|
||||
// AttributesImplTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/AttributesImplTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "AttributesImplTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/SAX/AttributesImpl.h"
|
||||
|
||||
|
||||
using Poco::XML::AttributesImpl;
|
||||
|
||||
|
||||
AttributesImplTest::AttributesImplTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AttributesImplTest::~AttributesImplTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::testNoNamespaces()
|
||||
{
|
||||
AttributesImpl attrs;
|
||||
|
||||
assert (attrs.getLength() == 0);
|
||||
assert (attrs.getIndex("foo") == -1);
|
||||
assert (attrs.getValue("foo").empty());
|
||||
|
||||
attrs.addAttribute("", "", "a1", "CDATA", "v1");
|
||||
assert (attrs.getLength() == 1);
|
||||
assert (attrs.getIndex("a1") == 0);
|
||||
assert (attrs.getQName(0) == "a1");
|
||||
assert (attrs.getType(0) == "CDATA");
|
||||
assert (attrs.getValue(0) == "v1");
|
||||
assert (attrs.isSpecified(0));
|
||||
|
||||
assert (attrs.getType("a1") == "CDATA");
|
||||
assert (attrs.getValue("a1") == "v1");
|
||||
|
||||
attrs.addAttribute("", "", "a2", "CDATA", "v2");
|
||||
assert (attrs.getLength() == 2);
|
||||
assert (attrs.getIndex("a2") == 1);
|
||||
assert (attrs.getQName(1) == "a2");
|
||||
assert (attrs.getType(1) == "CDATA");
|
||||
assert (attrs.getValue(1) == "v2");
|
||||
assert (attrs.isSpecified(1));
|
||||
|
||||
assert (attrs.getType("a2") == "CDATA");
|
||||
assert (attrs.getValue("a2") == "v2");
|
||||
|
||||
attrs.addAttribute("", "", "a3", "CDATA", "v3");
|
||||
assert (attrs.getLength() == 3);
|
||||
assert (attrs.getIndex("a3") == 2);
|
||||
assert (attrs.getValue("a3") == "v3");
|
||||
|
||||
attrs.removeAttribute(0);
|
||||
assert (attrs.getLength() == 2);
|
||||
assert (attrs.getIndex("a1") == -1);
|
||||
assert (attrs.getIndex("a2") == 0);
|
||||
assert (attrs.getIndex("a3") == 1);
|
||||
assert (attrs.getQName(0) == "a2");
|
||||
assert (attrs.getQName(1) == "a3");
|
||||
|
||||
attrs.removeAttribute("a3");
|
||||
assert (attrs.getLength() == 1);
|
||||
assert (attrs.getIndex("a1") == -1);
|
||||
assert (attrs.getIndex("a2") == 0);
|
||||
assert (attrs.getIndex("a3") == -1);
|
||||
assert (attrs.getQName(0) == "a2");
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::testNamespaces()
|
||||
{
|
||||
AttributesImpl attrs;
|
||||
|
||||
assert (attrs.getLength() == 0);
|
||||
assert (attrs.getIndex("urn:ns", "foo") == -1);
|
||||
assert (attrs.getValue("urn:ns", "foo").empty());
|
||||
|
||||
attrs.addAttribute("urn:ns", "a1", "p:a1", "CDATA", "v1");
|
||||
assert (attrs.getLength() == 1);
|
||||
assert (attrs.getIndex("urn:ns", "a1") == 0);
|
||||
assert (attrs.getQName(0) == "p:a1");
|
||||
assert (attrs.getLocalName(0) == "a1");
|
||||
assert (attrs.getURI(0) == "urn:ns");
|
||||
assert (attrs.getType(0) == "CDATA");
|
||||
assert (attrs.getValue(0) == "v1");
|
||||
assert (attrs.isSpecified(0));
|
||||
|
||||
assert (attrs.getType("urn:ns", "a1") == "CDATA");
|
||||
assert (attrs.getValue("urn:ns", "a1") == "v1");
|
||||
|
||||
attrs.addAttribute("urn:ns", "a2", "p:a2", "CDATA", "v2");
|
||||
assert (attrs.getLength() == 2);
|
||||
assert (attrs.getIndex("urn:ns", "a2") == 1);
|
||||
assert (attrs.getQName(1) == "p:a2");
|
||||
assert (attrs.getLocalName(1) == "a2");
|
||||
assert (attrs.getURI(1) == "urn:ns");
|
||||
assert (attrs.getType(1) == "CDATA");
|
||||
assert (attrs.getValue(1) == "v2");
|
||||
assert (attrs.isSpecified(1));
|
||||
|
||||
assert (attrs.getType("urn:ns", "a2") == "CDATA");
|
||||
assert (attrs.getValue("urn:ns", "a2") == "v2");
|
||||
|
||||
assert (attrs.getIndex("urn:ns2", "a2") == -1);
|
||||
|
||||
attrs.addAttribute("urn:ns2", "a3", "q:a3", "CDATA", "v3");
|
||||
assert (attrs.getLength() == 3);
|
||||
assert (attrs.getIndex("urn:ns2", "a3") == 2);
|
||||
assert (attrs.getValue("urn:ns2", "a3") == "v3");
|
||||
|
||||
attrs.removeAttribute(0);
|
||||
assert (attrs.getLength() == 2);
|
||||
assert (attrs.getIndex("urn:ns", "a1") == -1);
|
||||
assert (attrs.getIndex("urn:ns", "a2") == 0);
|
||||
assert (attrs.getIndex("urn:ns2", "a3") == 1);
|
||||
assert (attrs.getQName(0) == "p:a2");
|
||||
assert (attrs.getLocalName(0) == "a2");
|
||||
assert (attrs.getURI(0) == "urn:ns");
|
||||
assert (attrs.getQName(1) == "q:a3");
|
||||
assert (attrs.getLocalName(1) == "a3");
|
||||
assert (attrs.getURI(1) == "urn:ns2");
|
||||
|
||||
attrs.removeAttribute("urn:ns", "a3");
|
||||
assert (attrs.getLength() == 2);
|
||||
|
||||
attrs.removeAttribute("urn:ns2", "a3");
|
||||
assert (attrs.getLength() == 1);
|
||||
assert (attrs.getIndex("urn:ns", "a1") == -1);
|
||||
assert (attrs.getIndex("urn:ns", "a2") == 0);
|
||||
assert (attrs.getIndex("urn:ns2", "a3") == -1);
|
||||
assert (attrs.getQName(0) == "p:a2");
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::testAccessors()
|
||||
{
|
||||
AttributesImpl attrs;
|
||||
attrs.addAttribute("urn:ns1", "a1", "p:a1", "CDATA", "v1");
|
||||
attrs.addAttribute("urn:ns1", "a2", "p:a2", "CDATA", "v2", false);
|
||||
attrs.addAttribute("urn:ns2", "a3", "q:a3", "CDATA", "v3", true);
|
||||
|
||||
assert (attrs.getQName(0) == "p:a1");
|
||||
assert (attrs.getQName(1) == "p:a2");
|
||||
assert (attrs.getQName(2) == "q:a3");
|
||||
|
||||
assert (attrs.getLocalName(0) == "a1");
|
||||
assert (attrs.getLocalName(1) == "a2");
|
||||
assert (attrs.getLocalName(2) == "a3");
|
||||
|
||||
assert (attrs.getURI(0) == "urn:ns1");
|
||||
assert (attrs.getURI(1) == "urn:ns1");
|
||||
assert (attrs.getURI(2) == "urn:ns2");
|
||||
|
||||
assert (attrs.getValue(0) == "v1");
|
||||
assert (attrs.getValue(1) == "v2");
|
||||
assert (attrs.getValue(2) == "v3");
|
||||
|
||||
assert (attrs.isSpecified(0));
|
||||
assert (!attrs.isSpecified(1));
|
||||
assert (attrs.isSpecified(2));
|
||||
|
||||
attrs.setType(0, "NMTOKEN");
|
||||
assert (attrs.getType(0) == "NMTOKEN");
|
||||
assert (attrs.getType("urn:ns1", "a1") == "NMTOKEN");
|
||||
|
||||
attrs.setValue(1, "v2 v2");
|
||||
assert (attrs.getValue(1) == "v2 v2");
|
||||
assert (attrs.getValue("urn:ns1", "a2") == "v2 v2");
|
||||
assert (attrs.isSpecified(1));
|
||||
|
||||
attrs.setLocalName(2, "A3");
|
||||
assert (attrs.getLocalName(2) == "A3");
|
||||
attrs.setQName(2, "p:A3");
|
||||
assert (attrs.getQName(2) == "p:A3");
|
||||
attrs.setURI(2, "urn:ns1");
|
||||
assert (attrs.getURI(2) == "urn:ns1");
|
||||
|
||||
assert (attrs.getValue("urn:ns1", "A3") == "v3");
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::testCopy()
|
||||
{
|
||||
AttributesImpl attrs;
|
||||
attrs.addAttribute("urn:ns1", "a1", "p:a1", "CDATA", "v1");
|
||||
attrs.addAttribute("urn:ns1", "a2", "p:a2", "CDATA", "v2");
|
||||
attrs.addAttribute("urn:ns2", "a3", "q:a3", "CDATA", "v3");
|
||||
|
||||
AttributesImpl attrs2;
|
||||
attrs2.setAttributes(attrs);
|
||||
|
||||
assert (attrs2.getLength() == 3);
|
||||
|
||||
assert (attrs2.getQName(0) == "p:a1");
|
||||
assert (attrs2.getQName(1) == "p:a2");
|
||||
assert (attrs2.getQName(2) == "q:a3");
|
||||
|
||||
assert (attrs2.getLocalName(0) == "a1");
|
||||
assert (attrs2.getLocalName(1) == "a2");
|
||||
assert (attrs2.getLocalName(2) == "a3");
|
||||
|
||||
assert (attrs2.getURI(0) == "urn:ns1");
|
||||
assert (attrs2.getURI(1) == "urn:ns1");
|
||||
assert (attrs2.getURI(2) == "urn:ns2");
|
||||
|
||||
assert (attrs2.getValue(0) == "v1");
|
||||
assert (attrs2.getValue(1) == "v2");
|
||||
assert (attrs2.getValue(2) == "v3");
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* AttributesImplTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("AttributesImplTest");
|
||||
|
||||
CppUnit_addTest(pSuite, AttributesImplTest, testNoNamespaces);
|
||||
CppUnit_addTest(pSuite, AttributesImplTest, testNamespaces);
|
||||
CppUnit_addTest(pSuite, AttributesImplTest, testAccessors);
|
||||
CppUnit_addTest(pSuite, AttributesImplTest, testCopy);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// AttributesImplTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/AttributesImplTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "AttributesImplTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/SAX/AttributesImpl.h"
|
||||
|
||||
|
||||
using Poco::XML::AttributesImpl;
|
||||
|
||||
|
||||
AttributesImplTest::AttributesImplTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AttributesImplTest::~AttributesImplTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::testNoNamespaces()
|
||||
{
|
||||
AttributesImpl attrs;
|
||||
|
||||
assert (attrs.getLength() == 0);
|
||||
assert (attrs.getIndex("foo") == -1);
|
||||
assert (attrs.getValue("foo").empty());
|
||||
|
||||
attrs.addAttribute("", "", "a1", "CDATA", "v1");
|
||||
assert (attrs.getLength() == 1);
|
||||
assert (attrs.getIndex("a1") == 0);
|
||||
assert (attrs.getQName(0) == "a1");
|
||||
assert (attrs.getType(0) == "CDATA");
|
||||
assert (attrs.getValue(0) == "v1");
|
||||
assert (attrs.isSpecified(0));
|
||||
|
||||
assert (attrs.getType("a1") == "CDATA");
|
||||
assert (attrs.getValue("a1") == "v1");
|
||||
|
||||
attrs.addAttribute("", "", "a2", "CDATA", "v2");
|
||||
assert (attrs.getLength() == 2);
|
||||
assert (attrs.getIndex("a2") == 1);
|
||||
assert (attrs.getQName(1) == "a2");
|
||||
assert (attrs.getType(1) == "CDATA");
|
||||
assert (attrs.getValue(1) == "v2");
|
||||
assert (attrs.isSpecified(1));
|
||||
|
||||
assert (attrs.getType("a2") == "CDATA");
|
||||
assert (attrs.getValue("a2") == "v2");
|
||||
|
||||
attrs.addAttribute("", "", "a3", "CDATA", "v3");
|
||||
assert (attrs.getLength() == 3);
|
||||
assert (attrs.getIndex("a3") == 2);
|
||||
assert (attrs.getValue("a3") == "v3");
|
||||
|
||||
attrs.removeAttribute(0);
|
||||
assert (attrs.getLength() == 2);
|
||||
assert (attrs.getIndex("a1") == -1);
|
||||
assert (attrs.getIndex("a2") == 0);
|
||||
assert (attrs.getIndex("a3") == 1);
|
||||
assert (attrs.getQName(0) == "a2");
|
||||
assert (attrs.getQName(1) == "a3");
|
||||
|
||||
attrs.removeAttribute("a3");
|
||||
assert (attrs.getLength() == 1);
|
||||
assert (attrs.getIndex("a1") == -1);
|
||||
assert (attrs.getIndex("a2") == 0);
|
||||
assert (attrs.getIndex("a3") == -1);
|
||||
assert (attrs.getQName(0) == "a2");
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::testNamespaces()
|
||||
{
|
||||
AttributesImpl attrs;
|
||||
|
||||
assert (attrs.getLength() == 0);
|
||||
assert (attrs.getIndex("urn:ns", "foo") == -1);
|
||||
assert (attrs.getValue("urn:ns", "foo").empty());
|
||||
|
||||
attrs.addAttribute("urn:ns", "a1", "p:a1", "CDATA", "v1");
|
||||
assert (attrs.getLength() == 1);
|
||||
assert (attrs.getIndex("urn:ns", "a1") == 0);
|
||||
assert (attrs.getQName(0) == "p:a1");
|
||||
assert (attrs.getLocalName(0) == "a1");
|
||||
assert (attrs.getURI(0) == "urn:ns");
|
||||
assert (attrs.getType(0) == "CDATA");
|
||||
assert (attrs.getValue(0) == "v1");
|
||||
assert (attrs.isSpecified(0));
|
||||
|
||||
assert (attrs.getType("urn:ns", "a1") == "CDATA");
|
||||
assert (attrs.getValue("urn:ns", "a1") == "v1");
|
||||
|
||||
attrs.addAttribute("urn:ns", "a2", "p:a2", "CDATA", "v2");
|
||||
assert (attrs.getLength() == 2);
|
||||
assert (attrs.getIndex("urn:ns", "a2") == 1);
|
||||
assert (attrs.getQName(1) == "p:a2");
|
||||
assert (attrs.getLocalName(1) == "a2");
|
||||
assert (attrs.getURI(1) == "urn:ns");
|
||||
assert (attrs.getType(1) == "CDATA");
|
||||
assert (attrs.getValue(1) == "v2");
|
||||
assert (attrs.isSpecified(1));
|
||||
|
||||
assert (attrs.getType("urn:ns", "a2") == "CDATA");
|
||||
assert (attrs.getValue("urn:ns", "a2") == "v2");
|
||||
|
||||
assert (attrs.getIndex("urn:ns2", "a2") == -1);
|
||||
|
||||
attrs.addAttribute("urn:ns2", "a3", "q:a3", "CDATA", "v3");
|
||||
assert (attrs.getLength() == 3);
|
||||
assert (attrs.getIndex("urn:ns2", "a3") == 2);
|
||||
assert (attrs.getValue("urn:ns2", "a3") == "v3");
|
||||
|
||||
attrs.removeAttribute(0);
|
||||
assert (attrs.getLength() == 2);
|
||||
assert (attrs.getIndex("urn:ns", "a1") == -1);
|
||||
assert (attrs.getIndex("urn:ns", "a2") == 0);
|
||||
assert (attrs.getIndex("urn:ns2", "a3") == 1);
|
||||
assert (attrs.getQName(0) == "p:a2");
|
||||
assert (attrs.getLocalName(0) == "a2");
|
||||
assert (attrs.getURI(0) == "urn:ns");
|
||||
assert (attrs.getQName(1) == "q:a3");
|
||||
assert (attrs.getLocalName(1) == "a3");
|
||||
assert (attrs.getURI(1) == "urn:ns2");
|
||||
|
||||
attrs.removeAttribute("urn:ns", "a3");
|
||||
assert (attrs.getLength() == 2);
|
||||
|
||||
attrs.removeAttribute("urn:ns2", "a3");
|
||||
assert (attrs.getLength() == 1);
|
||||
assert (attrs.getIndex("urn:ns", "a1") == -1);
|
||||
assert (attrs.getIndex("urn:ns", "a2") == 0);
|
||||
assert (attrs.getIndex("urn:ns2", "a3") == -1);
|
||||
assert (attrs.getQName(0) == "p:a2");
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::testAccessors()
|
||||
{
|
||||
AttributesImpl attrs;
|
||||
attrs.addAttribute("urn:ns1", "a1", "p:a1", "CDATA", "v1");
|
||||
attrs.addAttribute("urn:ns1", "a2", "p:a2", "CDATA", "v2", false);
|
||||
attrs.addAttribute("urn:ns2", "a3", "q:a3", "CDATA", "v3", true);
|
||||
|
||||
assert (attrs.getQName(0) == "p:a1");
|
||||
assert (attrs.getQName(1) == "p:a2");
|
||||
assert (attrs.getQName(2) == "q:a3");
|
||||
|
||||
assert (attrs.getLocalName(0) == "a1");
|
||||
assert (attrs.getLocalName(1) == "a2");
|
||||
assert (attrs.getLocalName(2) == "a3");
|
||||
|
||||
assert (attrs.getURI(0) == "urn:ns1");
|
||||
assert (attrs.getURI(1) == "urn:ns1");
|
||||
assert (attrs.getURI(2) == "urn:ns2");
|
||||
|
||||
assert (attrs.getValue(0) == "v1");
|
||||
assert (attrs.getValue(1) == "v2");
|
||||
assert (attrs.getValue(2) == "v3");
|
||||
|
||||
assert (attrs.isSpecified(0));
|
||||
assert (!attrs.isSpecified(1));
|
||||
assert (attrs.isSpecified(2));
|
||||
|
||||
attrs.setType(0, "NMTOKEN");
|
||||
assert (attrs.getType(0) == "NMTOKEN");
|
||||
assert (attrs.getType("urn:ns1", "a1") == "NMTOKEN");
|
||||
|
||||
attrs.setValue(1, "v2 v2");
|
||||
assert (attrs.getValue(1) == "v2 v2");
|
||||
assert (attrs.getValue("urn:ns1", "a2") == "v2 v2");
|
||||
assert (attrs.isSpecified(1));
|
||||
|
||||
attrs.setLocalName(2, "A3");
|
||||
assert (attrs.getLocalName(2) == "A3");
|
||||
attrs.setQName(2, "p:A3");
|
||||
assert (attrs.getQName(2) == "p:A3");
|
||||
attrs.setURI(2, "urn:ns1");
|
||||
assert (attrs.getURI(2) == "urn:ns1");
|
||||
|
||||
assert (attrs.getValue("urn:ns1", "A3") == "v3");
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::testCopy()
|
||||
{
|
||||
AttributesImpl attrs;
|
||||
attrs.addAttribute("urn:ns1", "a1", "p:a1", "CDATA", "v1");
|
||||
attrs.addAttribute("urn:ns1", "a2", "p:a2", "CDATA", "v2");
|
||||
attrs.addAttribute("urn:ns2", "a3", "q:a3", "CDATA", "v3");
|
||||
|
||||
AttributesImpl attrs2;
|
||||
attrs2.setAttributes(attrs);
|
||||
|
||||
assert (attrs2.getLength() == 3);
|
||||
|
||||
assert (attrs2.getQName(0) == "p:a1");
|
||||
assert (attrs2.getQName(1) == "p:a2");
|
||||
assert (attrs2.getQName(2) == "q:a3");
|
||||
|
||||
assert (attrs2.getLocalName(0) == "a1");
|
||||
assert (attrs2.getLocalName(1) == "a2");
|
||||
assert (attrs2.getLocalName(2) == "a3");
|
||||
|
||||
assert (attrs2.getURI(0) == "urn:ns1");
|
||||
assert (attrs2.getURI(1) == "urn:ns1");
|
||||
assert (attrs2.getURI(2) == "urn:ns2");
|
||||
|
||||
assert (attrs2.getValue(0) == "v1");
|
||||
assert (attrs2.getValue(1) == "v2");
|
||||
assert (attrs2.getValue(2) == "v3");
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AttributesImplTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* AttributesImplTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("AttributesImplTest");
|
||||
|
||||
CppUnit_addTest(pSuite, AttributesImplTest, testNoNamespaces);
|
||||
CppUnit_addTest(pSuite, AttributesImplTest, testNamespaces);
|
||||
CppUnit_addTest(pSuite, AttributesImplTest, testAccessors);
|
||||
CppUnit_addTest(pSuite, AttributesImplTest, testCopy);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,63 +1,63 @@
|
||||
//
|
||||
// AttributesImplTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/AttributesImplTest.h#1 $
|
||||
//
|
||||
// Definition of the AttributesImplTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef AttributesImplTest_INCLUDED
|
||||
#define AttributesImplTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class AttributesImplTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
AttributesImplTest(const std::string& name);
|
||||
~AttributesImplTest();
|
||||
|
||||
void testNoNamespaces();
|
||||
void testNamespaces();
|
||||
void testAccessors();
|
||||
void testCopy();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // AttributesImplTest_INCLUDED
|
||||
//
|
||||
// AttributesImplTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/AttributesImplTest.h#1 $
|
||||
//
|
||||
// Definition of the AttributesImplTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef AttributesImplTest_INCLUDED
|
||||
#define AttributesImplTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class AttributesImplTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
AttributesImplTest(const std::string& name);
|
||||
~AttributesImplTest();
|
||||
|
||||
void testNoNamespaces();
|
||||
void testNamespaces();
|
||||
void testAccessors();
|
||||
void testCopy();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // AttributesImplTest_INCLUDED
|
||||
|
@@ -1,124 +1,124 @@
|
||||
//
|
||||
// ChildNodesTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ChildNodesTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "ChildNodesTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/NodeList.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::NodeList;
|
||||
using Poco::XML::Node;
|
||||
using Poco::XML::AutoPtr;
|
||||
|
||||
|
||||
ChildNodesTest::ChildNodesTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ChildNodesTest::~ChildNodesTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ChildNodesTest::testChildNodes()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
|
||||
assert (!pRoot->hasChildNodes());
|
||||
AutoPtr<NodeList> pNL = pRoot->childNodes();
|
||||
assert (pNL->length() == 0);
|
||||
|
||||
AutoPtr<Element> pChild1 = pDoc->createElement("child1");
|
||||
pRoot->appendChild(pChild1);
|
||||
assert (pRoot->hasChildNodes());
|
||||
|
||||
assert (pNL->length() == 1);
|
||||
assert (pNL->item(0) == pChild1);
|
||||
|
||||
AutoPtr<Element> pChild2 = pDoc->createElement("child2");
|
||||
pRoot->appendChild(pChild2);
|
||||
|
||||
assert (pNL->length() == 2);
|
||||
assert (pNL->item(0) == pChild1);
|
||||
assert (pNL->item(1) == pChild2);
|
||||
|
||||
AutoPtr<Element> pChild0 = pDoc->createElement("child0");
|
||||
pRoot->insertBefore(pChild0, pChild1);
|
||||
|
||||
assert (pNL->length() == 3);
|
||||
assert (pNL->item(0) == pChild0);
|
||||
assert (pNL->item(1) == pChild1);
|
||||
assert (pNL->item(2) == pChild2);
|
||||
|
||||
pRoot->removeChild(pChild1);
|
||||
assert (pNL->length() == 2);
|
||||
assert (pNL->item(0) == pChild0);
|
||||
assert (pNL->item(1) == pChild2);
|
||||
|
||||
pRoot->removeChild(pChild0);
|
||||
assert (pNL->length() == 1);
|
||||
assert (pNL->item(0) == pChild2);
|
||||
|
||||
pRoot->removeChild(pChild2);
|
||||
assert (pNL->length() == 0);
|
||||
assert (pNL->item(0) == 0);
|
||||
|
||||
assert (!pRoot->hasChildNodes());
|
||||
}
|
||||
|
||||
|
||||
void ChildNodesTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ChildNodesTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* ChildNodesTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ChildNodesTest");
|
||||
|
||||
CppUnit_addTest(pSuite, ChildNodesTest, testChildNodes);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// ChildNodesTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ChildNodesTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "ChildNodesTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/NodeList.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::NodeList;
|
||||
using Poco::XML::Node;
|
||||
using Poco::XML::AutoPtr;
|
||||
|
||||
|
||||
ChildNodesTest::ChildNodesTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ChildNodesTest::~ChildNodesTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ChildNodesTest::testChildNodes()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
|
||||
assert (!pRoot->hasChildNodes());
|
||||
AutoPtr<NodeList> pNL = pRoot->childNodes();
|
||||
assert (pNL->length() == 0);
|
||||
|
||||
AutoPtr<Element> pChild1 = pDoc->createElement("child1");
|
||||
pRoot->appendChild(pChild1);
|
||||
assert (pRoot->hasChildNodes());
|
||||
|
||||
assert (pNL->length() == 1);
|
||||
assert (pNL->item(0) == pChild1);
|
||||
|
||||
AutoPtr<Element> pChild2 = pDoc->createElement("child2");
|
||||
pRoot->appendChild(pChild2);
|
||||
|
||||
assert (pNL->length() == 2);
|
||||
assert (pNL->item(0) == pChild1);
|
||||
assert (pNL->item(1) == pChild2);
|
||||
|
||||
AutoPtr<Element> pChild0 = pDoc->createElement("child0");
|
||||
pRoot->insertBefore(pChild0, pChild1);
|
||||
|
||||
assert (pNL->length() == 3);
|
||||
assert (pNL->item(0) == pChild0);
|
||||
assert (pNL->item(1) == pChild1);
|
||||
assert (pNL->item(2) == pChild2);
|
||||
|
||||
pRoot->removeChild(pChild1);
|
||||
assert (pNL->length() == 2);
|
||||
assert (pNL->item(0) == pChild0);
|
||||
assert (pNL->item(1) == pChild2);
|
||||
|
||||
pRoot->removeChild(pChild0);
|
||||
assert (pNL->length() == 1);
|
||||
assert (pNL->item(0) == pChild2);
|
||||
|
||||
pRoot->removeChild(pChild2);
|
||||
assert (pNL->length() == 0);
|
||||
assert (pNL->item(0) == 0);
|
||||
|
||||
assert (!pRoot->hasChildNodes());
|
||||
}
|
||||
|
||||
|
||||
void ChildNodesTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ChildNodesTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* ChildNodesTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ChildNodesTest");
|
||||
|
||||
CppUnit_addTest(pSuite, ChildNodesTest, testChildNodes);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,60 +1,60 @@
|
||||
//
|
||||
// ChildNodesTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ChildNodesTest.h#1 $
|
||||
//
|
||||
// Definition of the ChildNodesTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef ChildNodesTest_INCLUDED
|
||||
#define ChildNodesTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class ChildNodesTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ChildNodesTest(const std::string& name);
|
||||
~ChildNodesTest();
|
||||
|
||||
void testChildNodes();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // ChildNodesTest_INCLUDED
|
||||
//
|
||||
// ChildNodesTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ChildNodesTest.h#1 $
|
||||
//
|
||||
// Definition of the ChildNodesTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef ChildNodesTest_INCLUDED
|
||||
#define ChildNodesTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class ChildNodesTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ChildNodesTest(const std::string& name);
|
||||
~ChildNodesTest();
|
||||
|
||||
void testChildNodes();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // ChildNodesTest_INCLUDED
|
||||
|
@@ -1,64 +1,64 @@
|
||||
//
|
||||
// DOMTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DOMTestSuite.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DOMTestSuite.h"
|
||||
#include "NodeTest.h"
|
||||
#include "ChildNodesTest.h"
|
||||
#include "ElementTest.h"
|
||||
#include "TextTest.h"
|
||||
#include "DocumentTest.h"
|
||||
#include "DocumentTypeTest.h"
|
||||
#include "EventTest.h"
|
||||
#include "NodeIteratorTest.h"
|
||||
#include "TreeWalkerTest.h"
|
||||
#include "ParserWriterTest.h"
|
||||
#include "NodeAppenderTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* DOMTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DOMTestSuite");
|
||||
|
||||
pSuite->addTest(NodeTest::suite());
|
||||
pSuite->addTest(ChildNodesTest::suite());
|
||||
pSuite->addTest(ElementTest::suite());
|
||||
pSuite->addTest(TextTest::suite());
|
||||
pSuite->addTest(DocumentTest::suite());
|
||||
pSuite->addTest(DocumentTypeTest::suite());
|
||||
pSuite->addTest(EventTest::suite());
|
||||
pSuite->addTest(NodeIteratorTest::suite());
|
||||
pSuite->addTest(TreeWalkerTest::suite());
|
||||
pSuite->addTest(ParserWriterTest::suite());
|
||||
pSuite->addTest(NodeAppenderTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// DOMTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DOMTestSuite.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DOMTestSuite.h"
|
||||
#include "NodeTest.h"
|
||||
#include "ChildNodesTest.h"
|
||||
#include "ElementTest.h"
|
||||
#include "TextTest.h"
|
||||
#include "DocumentTest.h"
|
||||
#include "DocumentTypeTest.h"
|
||||
#include "EventTest.h"
|
||||
#include "NodeIteratorTest.h"
|
||||
#include "TreeWalkerTest.h"
|
||||
#include "ParserWriterTest.h"
|
||||
#include "NodeAppenderTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* DOMTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DOMTestSuite");
|
||||
|
||||
pSuite->addTest(NodeTest::suite());
|
||||
pSuite->addTest(ChildNodesTest::suite());
|
||||
pSuite->addTest(ElementTest::suite());
|
||||
pSuite->addTest(TextTest::suite());
|
||||
pSuite->addTest(DocumentTest::suite());
|
||||
pSuite->addTest(DocumentTypeTest::suite());
|
||||
pSuite->addTest(EventTest::suite());
|
||||
pSuite->addTest(NodeIteratorTest::suite());
|
||||
pSuite->addTest(TreeWalkerTest::suite());
|
||||
pSuite->addTest(ParserWriterTest::suite());
|
||||
pSuite->addTest(NodeAppenderTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,49 +1,49 @@
|
||||
//
|
||||
// DOMTestSuite.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DOMTestSuite.h#1 $
|
||||
//
|
||||
// Definition of the DOMTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DOMTestSuite_INCLUDED
|
||||
#define DOMTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class DOMTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // DOMTestSuite_INCLUDED
|
||||
//
|
||||
// DOMTestSuite.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DOMTestSuite.h#1 $
|
||||
//
|
||||
// Definition of the DOMTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DOMTestSuite_INCLUDED
|
||||
#define DOMTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class DOMTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // DOMTestSuite_INCLUDED
|
||||
|
@@ -1,310 +1,310 @@
|
||||
//
|
||||
// DocumentTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DocumentTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DocumentTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Text.h"
|
||||
#include "Poco/DOM/NodeList.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
#include "Poco/DOM/DOMException.h"
|
||||
|
||||
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::Text;
|
||||
using Poco::XML::Node;
|
||||
using Poco::XML::NodeList;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
using Poco::XML::DOMException;
|
||||
|
||||
|
||||
DocumentTest::DocumentTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DocumentTest::~DocumentTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testDocumentElement()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
|
||||
assert (pDoc->documentElement() == 0);
|
||||
pDoc->appendChild(pRoot);
|
||||
assert (pDoc->documentElement() == pRoot);
|
||||
|
||||
AutoPtr<Text> pText = pDoc->createTextNode(" ");
|
||||
pDoc->insertBefore(pText, pRoot);
|
||||
assert (pDoc->documentElement() == pRoot);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testImport()
|
||||
{
|
||||
AutoPtr<Document> pDoc1 = new Document;
|
||||
AutoPtr<Element> pRoot1 = pDoc1->createElement("root");
|
||||
|
||||
AutoPtr<Document> pDoc2 = new Document;
|
||||
|
||||
try
|
||||
{
|
||||
pDoc2->appendChild(pRoot1);
|
||||
fail("wrong document - must throw exception");
|
||||
}
|
||||
catch (DOMException&)
|
||||
{
|
||||
}
|
||||
|
||||
AutoPtr<Element> pRoot2 = static_cast<Element*>(pDoc2->importNode(pRoot1, false));
|
||||
assert (pRoot2->ownerDocument() == pDoc2);
|
||||
assert (pRoot1->ownerDocument() == pDoc1);
|
||||
|
||||
pDoc2->appendChild(pRoot2);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testImportDeep()
|
||||
{
|
||||
AutoPtr<Document> pDoc1 = new Document;
|
||||
AutoPtr<Element> pRoot1 = pDoc1->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc1->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc1->createTextNode("text");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pRoot1->appendChild(pElem1);
|
||||
|
||||
pRoot1->setAttribute("a1", "v1");
|
||||
pRoot1->setAttribute("a2", "v2");
|
||||
|
||||
AutoPtr<Document> pDoc2 = new Document;
|
||||
|
||||
try
|
||||
{
|
||||
pDoc2->appendChild(pRoot1);
|
||||
fail("wrong document - must throw exception");
|
||||
}
|
||||
catch (DOMException&)
|
||||
{
|
||||
}
|
||||
|
||||
AutoPtr<Element> pRoot2 = static_cast<Element*>(pDoc2->importNode(pRoot1, true));
|
||||
assert (pRoot2->ownerDocument() == pDoc2);
|
||||
assert (pRoot2->firstChild()->ownerDocument() == pDoc2);
|
||||
assert (pRoot2->firstChild()->firstChild()->ownerDocument() == pDoc2);
|
||||
assert (pRoot1->ownerDocument() == pDoc1);
|
||||
assert (pRoot1->firstChild()->ownerDocument() == pDoc1);
|
||||
assert (pRoot1->firstChild()->firstChild()->ownerDocument() == pDoc1);
|
||||
|
||||
pDoc2->appendChild(pRoot2);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementsByTagName()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pDoc->appendChild(pRoot);
|
||||
AutoPtr<NodeList> pNL1 = pDoc->getElementsByTagName("*");
|
||||
AutoPtr<NodeList> pNL2 = pDoc->getElementsByTagName("elem");
|
||||
|
||||
assert (pNL1->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL2->length() == 0);
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
pRoot->appendChild(pElem1);
|
||||
|
||||
assert (pNL1->length() == 2);
|
||||
assert (pNL2->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL1->item(1) == pElem1);
|
||||
assert (pNL2->item(0) == pElem1);
|
||||
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("Elem");
|
||||
pRoot->appendChild(pElem2);
|
||||
|
||||
assert (pNL1->length() == 3);
|
||||
assert (pNL2->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL1->item(1) == pElem1);
|
||||
assert (pNL1->item(2) == pElem2);
|
||||
assert (pNL2->item(0) == pElem1);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementsByTagNameNS()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElementNS("urn:ns1", "root");
|
||||
pDoc->appendChild(pRoot);
|
||||
AutoPtr<NodeList> pNL1 = pDoc->getElementsByTagNameNS("*", "*");
|
||||
AutoPtr<NodeList> pNL2 = pDoc->getElementsByTagNameNS("*", "elem");
|
||||
|
||||
assert (pNL1->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL2->length() == 0);
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pRoot->appendChild(pElem1);
|
||||
|
||||
assert (pNL1->length() == 2);
|
||||
assert (pNL2->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL1->item(1) == pElem1);
|
||||
assert (pNL2->item(0) == pElem1);
|
||||
|
||||
AutoPtr<Element> pElem2 = pDoc->createElementNS("urn:ns1", "Elem");
|
||||
pRoot->appendChild(pElem2);
|
||||
|
||||
assert (pNL1->length() == 3);
|
||||
assert (pNL2->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL1->item(1) == pElem1);
|
||||
assert (pNL1->item(2) == pElem2);
|
||||
assert (pNL2->item(0) == pElem1);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementById()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pRoot->setAttribute("id", "0");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
pElem1->setAttribute("id", "1");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
pElem2->setAttribute("id", "2");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
pElem3->setAttribute("id", "3");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem1->appendChild(pElem2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem3);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
Element* pFound = pDoc->getElementById("0", "id");
|
||||
assert (pFound == pRoot);
|
||||
|
||||
pFound = pDoc->getElementById("1", "id");
|
||||
assert (pFound == pElem1);
|
||||
|
||||
pFound = pDoc->getElementById("2", "id");
|
||||
assert (pFound == pElem2);
|
||||
|
||||
pFound = pDoc->getElementById("3", "id");
|
||||
assert (pFound == pElem3);
|
||||
|
||||
pFound = pDoc->getElementById("4", "id");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementById("0", "ID");
|
||||
assert (pFound == 0);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementByIdNS()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElementNS("urn:ns1", "root");
|
||||
pRoot->setAttributeNS("urn:ns1", "id", "0");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem1->setAttributeNS("urn:ns1", "id", "1");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem2->setAttributeNS("urn:ns1", "id", "2");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem3->setAttributeNS("urn:ns1", "id", "3");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem1->appendChild(pElem2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem3);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
Element* pFound = pDoc->getElementByIdNS("0", "urn:ns1", "id");
|
||||
assert (pFound == pRoot);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("1", "urn:ns1", "id");
|
||||
assert (pFound == pElem1);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("2", "urn:ns1", "id");
|
||||
assert (pFound == pElem2);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("3", "urn:ns1", "id");
|
||||
assert (pFound == pElem3);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("4", "urn:ns1", "id");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("0", "urn:ns1", "ID");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("0", "urn:ns2", "id");
|
||||
assert (pFound == 0);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* DocumentTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DocumentTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DocumentTest, testDocumentElement);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testImport);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testImportDeep);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagName);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagNameNS);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementById);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementByIdNS);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// DocumentTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DocumentTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DocumentTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Text.h"
|
||||
#include "Poco/DOM/NodeList.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
#include "Poco/DOM/DOMException.h"
|
||||
|
||||
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::Text;
|
||||
using Poco::XML::Node;
|
||||
using Poco::XML::NodeList;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
using Poco::XML::DOMException;
|
||||
|
||||
|
||||
DocumentTest::DocumentTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DocumentTest::~DocumentTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testDocumentElement()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
|
||||
assert (pDoc->documentElement() == 0);
|
||||
pDoc->appendChild(pRoot);
|
||||
assert (pDoc->documentElement() == pRoot);
|
||||
|
||||
AutoPtr<Text> pText = pDoc->createTextNode(" ");
|
||||
pDoc->insertBefore(pText, pRoot);
|
||||
assert (pDoc->documentElement() == pRoot);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testImport()
|
||||
{
|
||||
AutoPtr<Document> pDoc1 = new Document;
|
||||
AutoPtr<Element> pRoot1 = pDoc1->createElement("root");
|
||||
|
||||
AutoPtr<Document> pDoc2 = new Document;
|
||||
|
||||
try
|
||||
{
|
||||
pDoc2->appendChild(pRoot1);
|
||||
fail("wrong document - must throw exception");
|
||||
}
|
||||
catch (DOMException&)
|
||||
{
|
||||
}
|
||||
|
||||
AutoPtr<Element> pRoot2 = static_cast<Element*>(pDoc2->importNode(pRoot1, false));
|
||||
assert (pRoot2->ownerDocument() == pDoc2);
|
||||
assert (pRoot1->ownerDocument() == pDoc1);
|
||||
|
||||
pDoc2->appendChild(pRoot2);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testImportDeep()
|
||||
{
|
||||
AutoPtr<Document> pDoc1 = new Document;
|
||||
AutoPtr<Element> pRoot1 = pDoc1->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc1->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc1->createTextNode("text");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pRoot1->appendChild(pElem1);
|
||||
|
||||
pRoot1->setAttribute("a1", "v1");
|
||||
pRoot1->setAttribute("a2", "v2");
|
||||
|
||||
AutoPtr<Document> pDoc2 = new Document;
|
||||
|
||||
try
|
||||
{
|
||||
pDoc2->appendChild(pRoot1);
|
||||
fail("wrong document - must throw exception");
|
||||
}
|
||||
catch (DOMException&)
|
||||
{
|
||||
}
|
||||
|
||||
AutoPtr<Element> pRoot2 = static_cast<Element*>(pDoc2->importNode(pRoot1, true));
|
||||
assert (pRoot2->ownerDocument() == pDoc2);
|
||||
assert (pRoot2->firstChild()->ownerDocument() == pDoc2);
|
||||
assert (pRoot2->firstChild()->firstChild()->ownerDocument() == pDoc2);
|
||||
assert (pRoot1->ownerDocument() == pDoc1);
|
||||
assert (pRoot1->firstChild()->ownerDocument() == pDoc1);
|
||||
assert (pRoot1->firstChild()->firstChild()->ownerDocument() == pDoc1);
|
||||
|
||||
pDoc2->appendChild(pRoot2);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementsByTagName()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pDoc->appendChild(pRoot);
|
||||
AutoPtr<NodeList> pNL1 = pDoc->getElementsByTagName("*");
|
||||
AutoPtr<NodeList> pNL2 = pDoc->getElementsByTagName("elem");
|
||||
|
||||
assert (pNL1->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL2->length() == 0);
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
pRoot->appendChild(pElem1);
|
||||
|
||||
assert (pNL1->length() == 2);
|
||||
assert (pNL2->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL1->item(1) == pElem1);
|
||||
assert (pNL2->item(0) == pElem1);
|
||||
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("Elem");
|
||||
pRoot->appendChild(pElem2);
|
||||
|
||||
assert (pNL1->length() == 3);
|
||||
assert (pNL2->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL1->item(1) == pElem1);
|
||||
assert (pNL1->item(2) == pElem2);
|
||||
assert (pNL2->item(0) == pElem1);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementsByTagNameNS()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElementNS("urn:ns1", "root");
|
||||
pDoc->appendChild(pRoot);
|
||||
AutoPtr<NodeList> pNL1 = pDoc->getElementsByTagNameNS("*", "*");
|
||||
AutoPtr<NodeList> pNL2 = pDoc->getElementsByTagNameNS("*", "elem");
|
||||
|
||||
assert (pNL1->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL2->length() == 0);
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pRoot->appendChild(pElem1);
|
||||
|
||||
assert (pNL1->length() == 2);
|
||||
assert (pNL2->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL1->item(1) == pElem1);
|
||||
assert (pNL2->item(0) == pElem1);
|
||||
|
||||
AutoPtr<Element> pElem2 = pDoc->createElementNS("urn:ns1", "Elem");
|
||||
pRoot->appendChild(pElem2);
|
||||
|
||||
assert (pNL1->length() == 3);
|
||||
assert (pNL2->length() == 1);
|
||||
assert (pNL1->item(0) == pRoot);
|
||||
assert (pNL1->item(1) == pElem1);
|
||||
assert (pNL1->item(2) == pElem2);
|
||||
assert (pNL2->item(0) == pElem1);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementById()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pRoot->setAttribute("id", "0");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
pElem1->setAttribute("id", "1");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
pElem2->setAttribute("id", "2");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
pElem3->setAttribute("id", "3");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem1->appendChild(pElem2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem3);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
Element* pFound = pDoc->getElementById("0", "id");
|
||||
assert (pFound == pRoot);
|
||||
|
||||
pFound = pDoc->getElementById("1", "id");
|
||||
assert (pFound == pElem1);
|
||||
|
||||
pFound = pDoc->getElementById("2", "id");
|
||||
assert (pFound == pElem2);
|
||||
|
||||
pFound = pDoc->getElementById("3", "id");
|
||||
assert (pFound == pElem3);
|
||||
|
||||
pFound = pDoc->getElementById("4", "id");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementById("0", "ID");
|
||||
assert (pFound == 0);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::testElementByIdNS()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElementNS("urn:ns1", "root");
|
||||
pRoot->setAttributeNS("urn:ns1", "id", "0");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem1->setAttributeNS("urn:ns1", "id", "1");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem2->setAttributeNS("urn:ns1", "id", "2");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElementNS("urn:ns1", "elem");
|
||||
pElem3->setAttributeNS("urn:ns1", "id", "3");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem1->appendChild(pElem2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem3);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
Element* pFound = pDoc->getElementByIdNS("0", "urn:ns1", "id");
|
||||
assert (pFound == pRoot);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("1", "urn:ns1", "id");
|
||||
assert (pFound == pElem1);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("2", "urn:ns1", "id");
|
||||
assert (pFound == pElem2);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("3", "urn:ns1", "id");
|
||||
assert (pFound == pElem3);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("4", "urn:ns1", "id");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("0", "urn:ns1", "ID");
|
||||
assert (pFound == 0);
|
||||
|
||||
pFound = pDoc->getElementByIdNS("0", "urn:ns2", "id");
|
||||
assert (pFound == 0);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DocumentTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* DocumentTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DocumentTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DocumentTest, testDocumentElement);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testImport);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testImportDeep);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagName);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementsByTagNameNS);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementById);
|
||||
CppUnit_addTest(pSuite, DocumentTest, testElementByIdNS);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,66 +1,66 @@
|
||||
//
|
||||
// DocumentTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DocumentTest.h#1 $
|
||||
//
|
||||
// Definition of the DocumentTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DocumentTest_INCLUDED
|
||||
#define DocumentTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class DocumentTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DocumentTest(const std::string& name);
|
||||
~DocumentTest();
|
||||
|
||||
void testDocumentElement();
|
||||
void testImport();
|
||||
void testImportDeep();
|
||||
void testElementsByTagName();
|
||||
void testElementsByTagNameNS();
|
||||
void testElementById();
|
||||
void testElementByIdNS();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // DocumentTest_INCLUDED
|
||||
//
|
||||
// DocumentTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DocumentTest.h#1 $
|
||||
//
|
||||
// Definition of the DocumentTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DocumentTest_INCLUDED
|
||||
#define DocumentTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class DocumentTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DocumentTest(const std::string& name);
|
||||
~DocumentTest();
|
||||
|
||||
void testDocumentElement();
|
||||
void testImport();
|
||||
void testImportDeep();
|
||||
void testElementsByTagName();
|
||||
void testElementsByTagNameNS();
|
||||
void testElementById();
|
||||
void testElementByIdNS();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // DocumentTest_INCLUDED
|
||||
|
@@ -1,130 +1,130 @@
|
||||
//
|
||||
// DocumentTypeTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DocumentTypeTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DocumentTypeTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/DocumentType.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Notation.h"
|
||||
#include "Poco/DOM/Entity.h"
|
||||
#include "Poco/DOM/DOMImplementation.h"
|
||||
#include "Poco/DOM/NamedNodeMap.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::DocumentType;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::Entity;
|
||||
using Poco::XML::Notation;
|
||||
using Poco::XML::DOMImplementation;
|
||||
using Poco::XML::NamedNodeMap;
|
||||
using Poco::XML::AutoPtr;
|
||||
|
||||
|
||||
DocumentTypeTest::DocumentTypeTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DocumentTypeTest::~DocumentTypeTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DocumentTypeTest::testDocumentType()
|
||||
{
|
||||
AutoPtr<DocumentType> pDoctype = DOMImplementation::instance().createDocumentType("test", "public", "system");
|
||||
|
||||
assert (pDoctype->ownerDocument() == 0);
|
||||
assert (pDoctype->name() == "test");
|
||||
assert (pDoctype->publicId() == "public");
|
||||
assert (pDoctype->systemId() == "system");
|
||||
|
||||
AutoPtr<Document> pDoc = new Document(pDoctype);
|
||||
assert (pDoc->doctype() == pDoctype);
|
||||
assert (pDoctype->ownerDocument() == pDoc);
|
||||
|
||||
AutoPtr<NamedNodeMap> pEntities = pDoctype->entities();
|
||||
AutoPtr<NamedNodeMap> pNotations = pDoctype->notations();
|
||||
|
||||
assert (pEntities->length() == 0);
|
||||
assert (pNotations->length() == 0);
|
||||
|
||||
AutoPtr<Entity> pEntity1 = pDoc->createEntity("entity1", "public1", "system1", "");
|
||||
pDoctype->appendChild(pEntity1);
|
||||
|
||||
assert (pEntities->length() == 1);
|
||||
assert (pNotations->length() == 0);
|
||||
assert (pEntities->item(0) == pEntity1);
|
||||
assert (pEntities->getNamedItem("entity1") == pEntity1);
|
||||
|
||||
AutoPtr<Entity> pEntity2 = pDoc->createEntity("entity2", "public2", "system2", "");
|
||||
pDoctype->appendChild(pEntity2);
|
||||
assert (pEntities->length() == 2);
|
||||
assert (pNotations->length() == 0);
|
||||
assert (pEntities->item(0) == pEntity1);
|
||||
assert (pEntities->item(1) == pEntity2);
|
||||
assert (pEntities->getNamedItem("entity1") == pEntity1);
|
||||
assert (pEntities->getNamedItem("entity2") == pEntity2);
|
||||
|
||||
AutoPtr<Notation> pNotation = pDoc->createNotation("notation", "public", "system");
|
||||
pDoctype->appendChild(pNotation);
|
||||
assert (pEntities->length() == 2);
|
||||
assert (pNotations->length() == 1);
|
||||
assert (pEntities->item(0) == pEntity1);
|
||||
assert (pEntities->item(1) == pEntity2);
|
||||
assert (pNotations->item(0) == pNotation);
|
||||
assert (pEntities->getNamedItem("entity1") == pEntity1);
|
||||
assert (pEntities->getNamedItem("entity2") == pEntity2);
|
||||
assert (pNotations->getNamedItem("notation") == pNotation);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTypeTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DocumentTypeTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* DocumentTypeTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DocumentTypeTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DocumentTypeTest, testDocumentType);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// DocumentTypeTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DocumentTypeTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DocumentTypeTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/DocumentType.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Notation.h"
|
||||
#include "Poco/DOM/Entity.h"
|
||||
#include "Poco/DOM/DOMImplementation.h"
|
||||
#include "Poco/DOM/NamedNodeMap.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::DocumentType;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::Entity;
|
||||
using Poco::XML::Notation;
|
||||
using Poco::XML::DOMImplementation;
|
||||
using Poco::XML::NamedNodeMap;
|
||||
using Poco::XML::AutoPtr;
|
||||
|
||||
|
||||
DocumentTypeTest::DocumentTypeTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DocumentTypeTest::~DocumentTypeTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DocumentTypeTest::testDocumentType()
|
||||
{
|
||||
AutoPtr<DocumentType> pDoctype = DOMImplementation::instance().createDocumentType("test", "public", "system");
|
||||
|
||||
assert (pDoctype->ownerDocument() == 0);
|
||||
assert (pDoctype->name() == "test");
|
||||
assert (pDoctype->publicId() == "public");
|
||||
assert (pDoctype->systemId() == "system");
|
||||
|
||||
AutoPtr<Document> pDoc = new Document(pDoctype);
|
||||
assert (pDoc->doctype() == pDoctype);
|
||||
assert (pDoctype->ownerDocument() == pDoc);
|
||||
|
||||
AutoPtr<NamedNodeMap> pEntities = pDoctype->entities();
|
||||
AutoPtr<NamedNodeMap> pNotations = pDoctype->notations();
|
||||
|
||||
assert (pEntities->length() == 0);
|
||||
assert (pNotations->length() == 0);
|
||||
|
||||
AutoPtr<Entity> pEntity1 = pDoc->createEntity("entity1", "public1", "system1", "");
|
||||
pDoctype->appendChild(pEntity1);
|
||||
|
||||
assert (pEntities->length() == 1);
|
||||
assert (pNotations->length() == 0);
|
||||
assert (pEntities->item(0) == pEntity1);
|
||||
assert (pEntities->getNamedItem("entity1") == pEntity1);
|
||||
|
||||
AutoPtr<Entity> pEntity2 = pDoc->createEntity("entity2", "public2", "system2", "");
|
||||
pDoctype->appendChild(pEntity2);
|
||||
assert (pEntities->length() == 2);
|
||||
assert (pNotations->length() == 0);
|
||||
assert (pEntities->item(0) == pEntity1);
|
||||
assert (pEntities->item(1) == pEntity2);
|
||||
assert (pEntities->getNamedItem("entity1") == pEntity1);
|
||||
assert (pEntities->getNamedItem("entity2") == pEntity2);
|
||||
|
||||
AutoPtr<Notation> pNotation = pDoc->createNotation("notation", "public", "system");
|
||||
pDoctype->appendChild(pNotation);
|
||||
assert (pEntities->length() == 2);
|
||||
assert (pNotations->length() == 1);
|
||||
assert (pEntities->item(0) == pEntity1);
|
||||
assert (pEntities->item(1) == pEntity2);
|
||||
assert (pNotations->item(0) == pNotation);
|
||||
assert (pEntities->getNamedItem("entity1") == pEntity1);
|
||||
assert (pEntities->getNamedItem("entity2") == pEntity2);
|
||||
assert (pNotations->getNamedItem("notation") == pNotation);
|
||||
}
|
||||
|
||||
|
||||
void DocumentTypeTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DocumentTypeTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* DocumentTypeTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DocumentTypeTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DocumentTypeTest, testDocumentType);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,60 +1,60 @@
|
||||
//
|
||||
// DocumentTypeTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DocumentTypeTest.h#1 $
|
||||
//
|
||||
// Definition of the DocumentTypeTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DocumentTypeTest_INCLUDED
|
||||
#define DocumentTypeTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class DocumentTypeTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DocumentTypeTest(const std::string& name);
|
||||
~DocumentTypeTest();
|
||||
|
||||
void testDocumentType();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // DocumentTypeTest_INCLUDED
|
||||
//
|
||||
// DocumentTypeTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/DocumentTypeTest.h#1 $
|
||||
//
|
||||
// Definition of the DocumentTypeTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DocumentTypeTest_INCLUDED
|
||||
#define DocumentTypeTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class DocumentTypeTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DocumentTypeTest(const std::string& name);
|
||||
~DocumentTypeTest();
|
||||
|
||||
void testDocumentType();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // DocumentTypeTest_INCLUDED
|
||||
|
@@ -1,39 +1,39 @@
|
||||
//
|
||||
// Driver.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/Driver.cpp#1 $
|
||||
//
|
||||
// Console-based test driver for Poco XML.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "XMLTestSuite.h"
|
||||
|
||||
|
||||
CppUnitMain(XMLTestSuite)
|
||||
//
|
||||
// Driver.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/Driver.cpp#1 $
|
||||
//
|
||||
// Console-based test driver for Poco XML.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "XMLTestSuite.h"
|
||||
|
||||
|
||||
CppUnitMain(XMLTestSuite)
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,70 +1,70 @@
|
||||
//
|
||||
// ElementTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ElementTest.h#1 $
|
||||
//
|
||||
// Definition of the ElementTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef ElementTest_INCLUDED
|
||||
#define ElementTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class ElementTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ElementTest(const std::string& name);
|
||||
~ElementTest();
|
||||
|
||||
void testAttributes();
|
||||
void testAttributesNS();
|
||||
void testAttrMap();
|
||||
void testAttrMapNS();
|
||||
void testElementsByTagName();
|
||||
void testElementsByTagNameNS();
|
||||
void testInnerText();
|
||||
void testChildElement();
|
||||
void testChildElementNS();
|
||||
void testNodeByPath();
|
||||
void testNodeByPathNS();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // ElementTest_INCLUDED
|
||||
//
|
||||
// ElementTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ElementTest.h#1 $
|
||||
//
|
||||
// Definition of the ElementTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef ElementTest_INCLUDED
|
||||
#define ElementTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class ElementTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ElementTest(const std::string& name);
|
||||
~ElementTest();
|
||||
|
||||
void testAttributes();
|
||||
void testAttributesNS();
|
||||
void testAttrMap();
|
||||
void testAttrMapNS();
|
||||
void testElementsByTagName();
|
||||
void testElementsByTagNameNS();
|
||||
void testInnerText();
|
||||
void testChildElement();
|
||||
void testChildElementNS();
|
||||
void testNodeByPath();
|
||||
void testNodeByPathNS();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // ElementTest_INCLUDED
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,68 +1,68 @@
|
||||
//
|
||||
// EventTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/EventTest.h#1 $
|
||||
//
|
||||
// Definition of the EventTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef EventTest_INCLUDED
|
||||
#define EventTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class EventTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
EventTest(const std::string& name);
|
||||
~EventTest();
|
||||
|
||||
void testInsert();
|
||||
void testInsertSubtree();
|
||||
void testRemove();
|
||||
void testRemoveSubtree();
|
||||
void testCharacterData();
|
||||
void testCancel();
|
||||
void testAttributes();
|
||||
void testAddRemoveInEvent();
|
||||
void testSuspended();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // EventTest_INCLUDED
|
||||
//
|
||||
// EventTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/EventTest.h#1 $
|
||||
//
|
||||
// Definition of the EventTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef EventTest_INCLUDED
|
||||
#define EventTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class EventTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
EventTest(const std::string& name);
|
||||
~EventTest();
|
||||
|
||||
void testInsert();
|
||||
void testInsertSubtree();
|
||||
void testRemove();
|
||||
void testRemoveSubtree();
|
||||
void testCharacterData();
|
||||
void testCancel();
|
||||
void testAttributes();
|
||||
void testAddRemoveInEvent();
|
||||
void testSuspended();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // EventTest_INCLUDED
|
||||
|
@@ -1,94 +1,94 @@
|
||||
//
|
||||
// NamePoolTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NamePoolTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NamePoolTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/XML/NamePool.h"
|
||||
#include "Poco/XML/Name.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::NamePool;
|
||||
using Poco::XML::Name;
|
||||
using Poco::XML::AutoPtr;
|
||||
|
||||
|
||||
NamePoolTest::NamePoolTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NamePoolTest::~NamePoolTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NamePoolTest::testNamePool()
|
||||
{
|
||||
AutoPtr<NamePool> pool = new NamePool;
|
||||
const Name* pName = 0;
|
||||
Name name("pre:local", "http://www.appinf.com");
|
||||
|
||||
pName = &pool->insert(name);
|
||||
const Name* pName2 = &pool->insert("pre:local", "http://www.appinf.com", "local");
|
||||
assert (pName == pName2);
|
||||
|
||||
pName2 = &pool->insert("pre:local2", "http://www.appinf.com", "local2");
|
||||
assert (pName2 != pName);
|
||||
|
||||
pName2 = &pool->insert(name);
|
||||
assert (pName2 == pName);
|
||||
|
||||
pName2 = &pool->insert(*pName);
|
||||
assert (pName2 == pName);
|
||||
}
|
||||
|
||||
|
||||
void NamePoolTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NamePoolTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NamePoolTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NamePoolTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NamePoolTest, testNamePool);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// NamePoolTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NamePoolTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NamePoolTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/XML/NamePool.h"
|
||||
#include "Poco/XML/Name.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::NamePool;
|
||||
using Poco::XML::Name;
|
||||
using Poco::XML::AutoPtr;
|
||||
|
||||
|
||||
NamePoolTest::NamePoolTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NamePoolTest::~NamePoolTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NamePoolTest::testNamePool()
|
||||
{
|
||||
AutoPtr<NamePool> pool = new NamePool;
|
||||
const Name* pName = 0;
|
||||
Name name("pre:local", "http://www.appinf.com");
|
||||
|
||||
pName = &pool->insert(name);
|
||||
const Name* pName2 = &pool->insert("pre:local", "http://www.appinf.com", "local");
|
||||
assert (pName == pName2);
|
||||
|
||||
pName2 = &pool->insert("pre:local2", "http://www.appinf.com", "local2");
|
||||
assert (pName2 != pName);
|
||||
|
||||
pName2 = &pool->insert(name);
|
||||
assert (pName2 == pName);
|
||||
|
||||
pName2 = &pool->insert(*pName);
|
||||
assert (pName2 == pName);
|
||||
}
|
||||
|
||||
|
||||
void NamePoolTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NamePoolTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NamePoolTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NamePoolTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NamePoolTest, testNamePool);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,60 +1,60 @@
|
||||
//
|
||||
// NamePoolTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NamePoolTest.h#1 $
|
||||
//
|
||||
// Definition of the NamePoolTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NamePoolTest_INCLUDED
|
||||
#define NamePoolTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NamePoolTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NamePoolTest(const std::string& name);
|
||||
~NamePoolTest();
|
||||
|
||||
void testNamePool();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NamePoolTest_INCLUDED
|
||||
//
|
||||
// NamePoolTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NamePoolTest.h#1 $
|
||||
//
|
||||
// Definition of the NamePoolTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NamePoolTest_INCLUDED
|
||||
#define NamePoolTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NamePoolTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NamePoolTest(const std::string& name);
|
||||
~NamePoolTest();
|
||||
|
||||
void testNamePool();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NamePoolTest_INCLUDED
|
||||
|
@@ -1,193 +1,193 @@
|
||||
//
|
||||
// NameTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NameTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NameTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/XML/Name.h"
|
||||
|
||||
|
||||
using Poco::XML::Name;
|
||||
|
||||
|
||||
NameTest::NameTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NameTest::~NameTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testSplit()
|
||||
{
|
||||
std::string qname = "name";
|
||||
std::string prefix;
|
||||
std::string local;
|
||||
Name::split(qname, prefix, local);
|
||||
assert (prefix.empty());
|
||||
assert (local == "name");
|
||||
|
||||
qname = "p:l";
|
||||
Name::split(qname, prefix, local);
|
||||
assert (prefix == "p");
|
||||
assert (local == "l");
|
||||
|
||||
qname = "pre:local";
|
||||
Name::split(qname, prefix, local);
|
||||
assert (prefix == "pre");
|
||||
assert (local == "local");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testLocalName()
|
||||
{
|
||||
std::string qname = "name";
|
||||
std::string local = Name::localName(qname);
|
||||
assert (local == "name");
|
||||
qname = "p:l";
|
||||
local = Name::localName(qname);
|
||||
assert (local == "l");
|
||||
qname = "pre:local";
|
||||
local = Name::localName(qname);
|
||||
assert (local == "local");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testPrefix()
|
||||
{
|
||||
std::string qname = "name";
|
||||
std::string prefix = Name::prefix(qname);
|
||||
assert (prefix.empty());
|
||||
qname = "p:l";
|
||||
prefix = Name::prefix(qname);
|
||||
assert (prefix == "p");
|
||||
qname = "pre:local";
|
||||
prefix = Name::prefix(qname);
|
||||
assert (prefix == "pre");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testName()
|
||||
{
|
||||
std::string qname = "name";
|
||||
Name name(qname);
|
||||
assert (name.qname() == "name");
|
||||
assert (name.prefix().empty());
|
||||
assert (name.namespaceURI().empty());
|
||||
assert (name.localName().empty());
|
||||
|
||||
qname.clear();
|
||||
name.assign(qname, "http://www.appinf.com/", "local");
|
||||
assert (name.qname().empty());
|
||||
assert (name.prefix().empty());
|
||||
assert (name.namespaceURI() == "http://www.appinf.com/");
|
||||
assert (name.localName() == "local");
|
||||
|
||||
Name name2("pre:local", "http://www.appinf.com/");
|
||||
assert (name2.qname() == "pre:local");
|
||||
assert (name2.prefix() == "pre");
|
||||
assert (name2.namespaceURI() == "http://www.appinf.com/");
|
||||
assert (name2.localName() == "local");
|
||||
|
||||
name2.assign("PRE:Local", "http://www.appinf.com/");
|
||||
assert (name2.qname() == "PRE:Local");
|
||||
assert (name2.prefix() == "PRE");
|
||||
assert (name2.namespaceURI() == "http://www.appinf.com/");
|
||||
assert (name2.localName() == "Local");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testCompare()
|
||||
{
|
||||
Name n1("pre:local");
|
||||
Name n2(n1);
|
||||
Name n3("pre:local2");
|
||||
|
||||
assert (n1.equals(n2));
|
||||
assert (!n1.equals(n3));
|
||||
|
||||
n1.assign("pre:local", "http://www.appinf.com", "local");
|
||||
n2.assign("pre:local", "http://www.appinf.com", "local");
|
||||
n3.assign("pre:local2", "http://www.appinf.com", "local2");
|
||||
|
||||
assert (n1.equals(n2));
|
||||
assert (!n1.equals(n3));
|
||||
|
||||
assert (n1.equals("pre:local", "http://www.appinf.com", "local"));
|
||||
assert (!n1.equals("pre:local", "", ""));
|
||||
assert (n1.equalsWeakly("pre:local", "", ""));
|
||||
assert (!n1.equalsWeakly("pre:local2", "", ""));
|
||||
assert (!n1.equals("", "http://www.appinf.com", "local"));
|
||||
assert (n1.equalsWeakly("", "http://www.appinf.com", "local"));
|
||||
assert (!n1.equalsWeakly("", "http://www.appinf.com", "local2"));
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testSwap()
|
||||
{
|
||||
Name n1("ns:name1", "http://www.appinf.com");
|
||||
Name n2("ns:name2", "http://www.foobar.com");
|
||||
n1.swap(n2);
|
||||
assert (n1.qname() == "ns:name2");
|
||||
assert (n1.namespaceURI() == "http://www.foobar.com");
|
||||
assert (n1.localName() == "name2");
|
||||
assert (n2.qname() == "ns:name1");
|
||||
assert (n2.namespaceURI() == "http://www.appinf.com");
|
||||
assert (n2.localName() == "name1");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NameTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NameTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NameTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NameTest, testSplit);
|
||||
CppUnit_addTest(pSuite, NameTest, testLocalName);
|
||||
CppUnit_addTest(pSuite, NameTest, testPrefix);
|
||||
CppUnit_addTest(pSuite, NameTest, testName);
|
||||
CppUnit_addTest(pSuite, NameTest, testCompare);
|
||||
CppUnit_addTest(pSuite, NameTest, testSwap);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// NameTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NameTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NameTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/XML/Name.h"
|
||||
|
||||
|
||||
using Poco::XML::Name;
|
||||
|
||||
|
||||
NameTest::NameTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NameTest::~NameTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testSplit()
|
||||
{
|
||||
std::string qname = "name";
|
||||
std::string prefix;
|
||||
std::string local;
|
||||
Name::split(qname, prefix, local);
|
||||
assert (prefix.empty());
|
||||
assert (local == "name");
|
||||
|
||||
qname = "p:l";
|
||||
Name::split(qname, prefix, local);
|
||||
assert (prefix == "p");
|
||||
assert (local == "l");
|
||||
|
||||
qname = "pre:local";
|
||||
Name::split(qname, prefix, local);
|
||||
assert (prefix == "pre");
|
||||
assert (local == "local");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testLocalName()
|
||||
{
|
||||
std::string qname = "name";
|
||||
std::string local = Name::localName(qname);
|
||||
assert (local == "name");
|
||||
qname = "p:l";
|
||||
local = Name::localName(qname);
|
||||
assert (local == "l");
|
||||
qname = "pre:local";
|
||||
local = Name::localName(qname);
|
||||
assert (local == "local");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testPrefix()
|
||||
{
|
||||
std::string qname = "name";
|
||||
std::string prefix = Name::prefix(qname);
|
||||
assert (prefix.empty());
|
||||
qname = "p:l";
|
||||
prefix = Name::prefix(qname);
|
||||
assert (prefix == "p");
|
||||
qname = "pre:local";
|
||||
prefix = Name::prefix(qname);
|
||||
assert (prefix == "pre");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testName()
|
||||
{
|
||||
std::string qname = "name";
|
||||
Name name(qname);
|
||||
assert (name.qname() == "name");
|
||||
assert (name.prefix().empty());
|
||||
assert (name.namespaceURI().empty());
|
||||
assert (name.localName().empty());
|
||||
|
||||
qname.clear();
|
||||
name.assign(qname, "http://www.appinf.com/", "local");
|
||||
assert (name.qname().empty());
|
||||
assert (name.prefix().empty());
|
||||
assert (name.namespaceURI() == "http://www.appinf.com/");
|
||||
assert (name.localName() == "local");
|
||||
|
||||
Name name2("pre:local", "http://www.appinf.com/");
|
||||
assert (name2.qname() == "pre:local");
|
||||
assert (name2.prefix() == "pre");
|
||||
assert (name2.namespaceURI() == "http://www.appinf.com/");
|
||||
assert (name2.localName() == "local");
|
||||
|
||||
name2.assign("PRE:Local", "http://www.appinf.com/");
|
||||
assert (name2.qname() == "PRE:Local");
|
||||
assert (name2.prefix() == "PRE");
|
||||
assert (name2.namespaceURI() == "http://www.appinf.com/");
|
||||
assert (name2.localName() == "Local");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testCompare()
|
||||
{
|
||||
Name n1("pre:local");
|
||||
Name n2(n1);
|
||||
Name n3("pre:local2");
|
||||
|
||||
assert (n1.equals(n2));
|
||||
assert (!n1.equals(n3));
|
||||
|
||||
n1.assign("pre:local", "http://www.appinf.com", "local");
|
||||
n2.assign("pre:local", "http://www.appinf.com", "local");
|
||||
n3.assign("pre:local2", "http://www.appinf.com", "local2");
|
||||
|
||||
assert (n1.equals(n2));
|
||||
assert (!n1.equals(n3));
|
||||
|
||||
assert (n1.equals("pre:local", "http://www.appinf.com", "local"));
|
||||
assert (!n1.equals("pre:local", "", ""));
|
||||
assert (n1.equalsWeakly("pre:local", "", ""));
|
||||
assert (!n1.equalsWeakly("pre:local2", "", ""));
|
||||
assert (!n1.equals("", "http://www.appinf.com", "local"));
|
||||
assert (n1.equalsWeakly("", "http://www.appinf.com", "local"));
|
||||
assert (!n1.equalsWeakly("", "http://www.appinf.com", "local2"));
|
||||
}
|
||||
|
||||
|
||||
void NameTest::testSwap()
|
||||
{
|
||||
Name n1("ns:name1", "http://www.appinf.com");
|
||||
Name n2("ns:name2", "http://www.foobar.com");
|
||||
n1.swap(n2);
|
||||
assert (n1.qname() == "ns:name2");
|
||||
assert (n1.namespaceURI() == "http://www.foobar.com");
|
||||
assert (n1.localName() == "name2");
|
||||
assert (n2.qname() == "ns:name1");
|
||||
assert (n2.namespaceURI() == "http://www.appinf.com");
|
||||
assert (n2.localName() == "name1");
|
||||
}
|
||||
|
||||
|
||||
void NameTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NameTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NameTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NameTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NameTest, testSplit);
|
||||
CppUnit_addTest(pSuite, NameTest, testLocalName);
|
||||
CppUnit_addTest(pSuite, NameTest, testPrefix);
|
||||
CppUnit_addTest(pSuite, NameTest, testName);
|
||||
CppUnit_addTest(pSuite, NameTest, testCompare);
|
||||
CppUnit_addTest(pSuite, NameTest, testSwap);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,65 +1,65 @@
|
||||
//
|
||||
// NameTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NameTest.h#1 $
|
||||
//
|
||||
// Definition of the NameTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NameTest_INCLUDED
|
||||
#define NameTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NameTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NameTest(const std::string& name);
|
||||
~NameTest();
|
||||
|
||||
void testSplit();
|
||||
void testLocalName();
|
||||
void testPrefix();
|
||||
void testName();
|
||||
void testCompare();
|
||||
void testSwap();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NameTest_INCLUDED
|
||||
//
|
||||
// NameTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NameTest.h#1 $
|
||||
//
|
||||
// Definition of the NameTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NameTest_INCLUDED
|
||||
#define NameTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NameTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NameTest(const std::string& name);
|
||||
~NameTest();
|
||||
|
||||
void testSplit();
|
||||
void testLocalName();
|
||||
void testPrefix();
|
||||
void testName();
|
||||
void testCompare();
|
||||
void testSwap();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NameTest_INCLUDED
|
||||
|
@@ -1,212 +1,212 @@
|
||||
//
|
||||
// NamespaceSupportTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NamespaceSupportTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NamespaceSupportTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/SAX/NamespaceSupport.h"
|
||||
|
||||
|
||||
using Poco::XML::NamespaceSupport;
|
||||
|
||||
|
||||
NamespaceSupportTest::NamespaceSupportTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NamespaceSupportTest::~NamespaceSupportTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NamespaceSupportTest::testNamespaceSupport()
|
||||
{
|
||||
NamespaceSupport ns;
|
||||
NamespaceSupport::PrefixSet prefixes;
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("xml") != prefixes.end());
|
||||
assert (prefixes.find("xmlns") != prefixes.end());
|
||||
|
||||
ns.getPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("xml") != prefixes.end());
|
||||
assert (prefixes.find("xmlns") != prefixes.end());
|
||||
|
||||
ns.pushContext();
|
||||
ns.declarePrefix("ns1", "urn:ns1");
|
||||
ns.declarePrefix("ns2", "urn:ns2");
|
||||
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("ns1") != prefixes.end());
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
|
||||
ns.pushContext();
|
||||
ns.declarePrefix("ns3", "urn:ns3");
|
||||
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 1);
|
||||
assert (prefixes.find("ns3") != prefixes.end());
|
||||
|
||||
ns.getPrefixes(prefixes);
|
||||
assert (prefixes.size() == 5);
|
||||
assert (prefixes.find("xml") != prefixes.end());
|
||||
assert (prefixes.find("xmlns") != prefixes.end());
|
||||
assert (prefixes.find("ns1") != prefixes.end());
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
assert (prefixes.find("ns3") != prefixes.end());
|
||||
|
||||
ns.popContext();
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("ns1") != prefixes.end());
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
|
||||
assert (ns.isMapped("urn:ns1"));
|
||||
assert (ns.isMapped("urn:ns2"));
|
||||
assert (ns.isMapped("http://www.w3.org/XML/1998/namespace"));
|
||||
assert (!ns.isMapped("urn:ns3"));
|
||||
|
||||
ns.getPrefixes("urn:ns2", prefixes);
|
||||
assert (prefixes.size() == 1);
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
|
||||
ns.pushContext();
|
||||
ns.declarePrefix("", "urn:ns3");
|
||||
ns.declarePrefix("NS2", "urn:ns2");
|
||||
|
||||
ns.getPrefixes("urn:ns2", prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
assert (prefixes.find("NS2") != prefixes.end());
|
||||
|
||||
ns.getPrefixes(prefixes);
|
||||
assert (prefixes.size() == 5);
|
||||
assert (prefixes.find("xml") != prefixes.end());
|
||||
assert (prefixes.find("xmlns") != prefixes.end());
|
||||
assert (prefixes.find("ns1") != prefixes.end());
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
assert (prefixes.find("NS2") != prefixes.end());
|
||||
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("") != prefixes.end());
|
||||
assert (prefixes.find("NS2") != prefixes.end());
|
||||
|
||||
assert (ns.getPrefix("urn:ns3") == "");
|
||||
assert (ns.getPrefix("urn:ns2") == "NS2");
|
||||
assert (ns.getPrefix("urn:ns4") == "");
|
||||
|
||||
assert (ns.isMapped("urn:ns3"));
|
||||
assert (ns.isMapped("urn:ns2"));
|
||||
assert (!ns.isMapped("urn:ns4"));
|
||||
|
||||
assert (ns.getURI("xml") == "http://www.w3.org/XML/1998/namespace");
|
||||
assert (ns.getURI("ns1") == "urn:ns1");
|
||||
assert (ns.getURI("") == "urn:ns3");
|
||||
assert (ns.getURI("NS2") == "urn:ns2");
|
||||
|
||||
std::string localName;
|
||||
std::string namespaceURI;
|
||||
bool declared = ns.processName("elem", namespaceURI, localName, false);
|
||||
assert (declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "urn:ns3");
|
||||
|
||||
declared = ns.processName("NS2:elem", namespaceURI, localName, false);
|
||||
assert (declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "urn:ns2");
|
||||
|
||||
declared = ns.processName("ns3:elem", namespaceURI, localName, false);
|
||||
assert (!declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "");
|
||||
|
||||
declared = ns.processName("ns2:attr", namespaceURI, localName, true);
|
||||
assert (declared);
|
||||
assert (localName == "attr");
|
||||
assert (namespaceURI == "urn:ns2");
|
||||
|
||||
declared = ns.processName("attr", namespaceURI, localName, true);
|
||||
assert (declared);
|
||||
assert (localName == "attr");
|
||||
assert (namespaceURI == "");
|
||||
|
||||
declared = ns.processName("ns3:attr", namespaceURI, localName, true);
|
||||
assert (!declared);
|
||||
assert (localName == "attr");
|
||||
assert (namespaceURI == "");
|
||||
|
||||
ns.popContext();
|
||||
assert (ns.getURI("xml") == "http://www.w3.org/XML/1998/namespace");
|
||||
assert (ns.getURI("ns1") == "urn:ns1");
|
||||
assert (ns.getURI("") == "");
|
||||
assert (ns.getURI("NS2") == "");
|
||||
|
||||
declared = ns.processName("elem", namespaceURI, localName, false);
|
||||
assert (declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "");
|
||||
|
||||
declared = ns.processName("ns2:elem", namespaceURI, localName, false);
|
||||
assert (declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "urn:ns2");
|
||||
|
||||
declared = ns.processName("ns3:elem", namespaceURI, localName, false);
|
||||
assert (!declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "");
|
||||
}
|
||||
|
||||
|
||||
void NamespaceSupportTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NamespaceSupportTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NamespaceSupportTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NamespaceSupportTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NamespaceSupportTest, testNamespaceSupport);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// NamespaceSupportTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NamespaceSupportTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NamespaceSupportTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/SAX/NamespaceSupport.h"
|
||||
|
||||
|
||||
using Poco::XML::NamespaceSupport;
|
||||
|
||||
|
||||
NamespaceSupportTest::NamespaceSupportTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NamespaceSupportTest::~NamespaceSupportTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NamespaceSupportTest::testNamespaceSupport()
|
||||
{
|
||||
NamespaceSupport ns;
|
||||
NamespaceSupport::PrefixSet prefixes;
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("xml") != prefixes.end());
|
||||
assert (prefixes.find("xmlns") != prefixes.end());
|
||||
|
||||
ns.getPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("xml") != prefixes.end());
|
||||
assert (prefixes.find("xmlns") != prefixes.end());
|
||||
|
||||
ns.pushContext();
|
||||
ns.declarePrefix("ns1", "urn:ns1");
|
||||
ns.declarePrefix("ns2", "urn:ns2");
|
||||
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("ns1") != prefixes.end());
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
|
||||
ns.pushContext();
|
||||
ns.declarePrefix("ns3", "urn:ns3");
|
||||
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 1);
|
||||
assert (prefixes.find("ns3") != prefixes.end());
|
||||
|
||||
ns.getPrefixes(prefixes);
|
||||
assert (prefixes.size() == 5);
|
||||
assert (prefixes.find("xml") != prefixes.end());
|
||||
assert (prefixes.find("xmlns") != prefixes.end());
|
||||
assert (prefixes.find("ns1") != prefixes.end());
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
assert (prefixes.find("ns3") != prefixes.end());
|
||||
|
||||
ns.popContext();
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("ns1") != prefixes.end());
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
|
||||
assert (ns.isMapped("urn:ns1"));
|
||||
assert (ns.isMapped("urn:ns2"));
|
||||
assert (ns.isMapped("http://www.w3.org/XML/1998/namespace"));
|
||||
assert (!ns.isMapped("urn:ns3"));
|
||||
|
||||
ns.getPrefixes("urn:ns2", prefixes);
|
||||
assert (prefixes.size() == 1);
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
|
||||
ns.pushContext();
|
||||
ns.declarePrefix("", "urn:ns3");
|
||||
ns.declarePrefix("NS2", "urn:ns2");
|
||||
|
||||
ns.getPrefixes("urn:ns2", prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
assert (prefixes.find("NS2") != prefixes.end());
|
||||
|
||||
ns.getPrefixes(prefixes);
|
||||
assert (prefixes.size() == 5);
|
||||
assert (prefixes.find("xml") != prefixes.end());
|
||||
assert (prefixes.find("xmlns") != prefixes.end());
|
||||
assert (prefixes.find("ns1") != prefixes.end());
|
||||
assert (prefixes.find("ns2") != prefixes.end());
|
||||
assert (prefixes.find("NS2") != prefixes.end());
|
||||
|
||||
ns.getDeclaredPrefixes(prefixes);
|
||||
assert (prefixes.size() == 2);
|
||||
assert (prefixes.find("") != prefixes.end());
|
||||
assert (prefixes.find("NS2") != prefixes.end());
|
||||
|
||||
assert (ns.getPrefix("urn:ns3") == "");
|
||||
assert (ns.getPrefix("urn:ns2") == "NS2");
|
||||
assert (ns.getPrefix("urn:ns4") == "");
|
||||
|
||||
assert (ns.isMapped("urn:ns3"));
|
||||
assert (ns.isMapped("urn:ns2"));
|
||||
assert (!ns.isMapped("urn:ns4"));
|
||||
|
||||
assert (ns.getURI("xml") == "http://www.w3.org/XML/1998/namespace");
|
||||
assert (ns.getURI("ns1") == "urn:ns1");
|
||||
assert (ns.getURI("") == "urn:ns3");
|
||||
assert (ns.getURI("NS2") == "urn:ns2");
|
||||
|
||||
std::string localName;
|
||||
std::string namespaceURI;
|
||||
bool declared = ns.processName("elem", namespaceURI, localName, false);
|
||||
assert (declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "urn:ns3");
|
||||
|
||||
declared = ns.processName("NS2:elem", namespaceURI, localName, false);
|
||||
assert (declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "urn:ns2");
|
||||
|
||||
declared = ns.processName("ns3:elem", namespaceURI, localName, false);
|
||||
assert (!declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "");
|
||||
|
||||
declared = ns.processName("ns2:attr", namespaceURI, localName, true);
|
||||
assert (declared);
|
||||
assert (localName == "attr");
|
||||
assert (namespaceURI == "urn:ns2");
|
||||
|
||||
declared = ns.processName("attr", namespaceURI, localName, true);
|
||||
assert (declared);
|
||||
assert (localName == "attr");
|
||||
assert (namespaceURI == "");
|
||||
|
||||
declared = ns.processName("ns3:attr", namespaceURI, localName, true);
|
||||
assert (!declared);
|
||||
assert (localName == "attr");
|
||||
assert (namespaceURI == "");
|
||||
|
||||
ns.popContext();
|
||||
assert (ns.getURI("xml") == "http://www.w3.org/XML/1998/namespace");
|
||||
assert (ns.getURI("ns1") == "urn:ns1");
|
||||
assert (ns.getURI("") == "");
|
||||
assert (ns.getURI("NS2") == "");
|
||||
|
||||
declared = ns.processName("elem", namespaceURI, localName, false);
|
||||
assert (declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "");
|
||||
|
||||
declared = ns.processName("ns2:elem", namespaceURI, localName, false);
|
||||
assert (declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "urn:ns2");
|
||||
|
||||
declared = ns.processName("ns3:elem", namespaceURI, localName, false);
|
||||
assert (!declared);
|
||||
assert (localName == "elem");
|
||||
assert (namespaceURI == "");
|
||||
}
|
||||
|
||||
|
||||
void NamespaceSupportTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NamespaceSupportTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NamespaceSupportTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NamespaceSupportTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NamespaceSupportTest, testNamespaceSupport);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,60 +1,60 @@
|
||||
//
|
||||
// NamespaceSupportTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NamespaceSupportTest.h#1 $
|
||||
//
|
||||
// Definition of the NamespaceSupportTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NamespaceSupportTest_INCLUDED
|
||||
#define NamespaceSupportTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NamespaceSupportTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NamespaceSupportTest(const std::string& name);
|
||||
~NamespaceSupportTest();
|
||||
|
||||
void testNamespaceSupport();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NamespaceSupportTest_INCLUDED
|
||||
//
|
||||
// NamespaceSupportTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NamespaceSupportTest.h#1 $
|
||||
//
|
||||
// Definition of the NamespaceSupportTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NamespaceSupportTest_INCLUDED
|
||||
#define NamespaceSupportTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NamespaceSupportTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NamespaceSupportTest(const std::string& name);
|
||||
~NamespaceSupportTest();
|
||||
|
||||
void testNamespaceSupport();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NamespaceSupportTest_INCLUDED
|
||||
|
@@ -1,162 +1,162 @@
|
||||
//
|
||||
// NodeAppenderTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeAppenderTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NodeAppenderTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/NodeAppender.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/DocumentFragment.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::NodeAppender;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::DocumentFragment;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
NodeAppenderTest::NodeAppenderTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NodeAppenderTest::~NodeAppenderTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::testAppendNode()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeAppender appender(pRoot);
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
|
||||
appender.appendChild(pElem1);
|
||||
appender.appendChild(pElem2);
|
||||
appender.appendChild(pElem3);
|
||||
|
||||
assert (pRoot->firstChild() == pElem1);
|
||||
assert (pRoot->lastChild() == pElem3);
|
||||
|
||||
assert (pElem1->nextSibling() == pElem2);
|
||||
assert (pElem2->nextSibling() == pElem3);
|
||||
assert (pElem3->nextSibling() == 0);
|
||||
|
||||
assert (pElem1->previousSibling() == 0);
|
||||
assert (pElem2->previousSibling() == pElem1);
|
||||
assert (pElem3->previousSibling() == pElem2);
|
||||
|
||||
assert (pElem1->parentNode() == pRoot);
|
||||
assert (pElem2->parentNode() == pRoot);
|
||||
assert (pElem3->parentNode() == pRoot);
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::testAppendNodeList()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeAppender appender(pRoot);
|
||||
|
||||
AutoPtr<DocumentFragment> pFrag1 = pDoc->createDocumentFragment();
|
||||
AutoPtr<DocumentFragment> pFrag2 = pDoc->createDocumentFragment();
|
||||
AutoPtr<DocumentFragment> pFrag3 = pDoc->createDocumentFragment();
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem4 = pDoc->createElement("elem");
|
||||
|
||||
pFrag2->appendChild(pElem1);
|
||||
pFrag2->appendChild(pElem2);
|
||||
pFrag2->appendChild(pElem3);
|
||||
|
||||
pFrag3->appendChild(pElem4);
|
||||
|
||||
appender.appendChild(pFrag1);
|
||||
assert (pRoot->firstChild() == 0);
|
||||
|
||||
appender.appendChild(pFrag2);
|
||||
assert (pRoot->firstChild() == pElem1);
|
||||
assert (pRoot->lastChild() == pElem3);
|
||||
|
||||
assert (pElem1->nextSibling() == pElem2);
|
||||
assert (pElem2->nextSibling() == pElem3);
|
||||
assert (pElem3->nextSibling() == 0);
|
||||
|
||||
assert (pElem1->previousSibling() == 0);
|
||||
assert (pElem2->previousSibling() == pElem1);
|
||||
assert (pElem3->previousSibling() == pElem2);
|
||||
|
||||
assert (pElem1->parentNode() == pRoot);
|
||||
assert (pElem2->parentNode() == pRoot);
|
||||
assert (pElem3->parentNode() == pRoot);
|
||||
|
||||
appender.appendChild(pFrag3);
|
||||
assert (pRoot->lastChild() == pElem4);
|
||||
assert (pElem4->parentNode() == pRoot);
|
||||
assert (pElem3->nextSibling() == pElem4);
|
||||
assert (pElem4->previousSibling() == pElem3);
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NodeAppenderTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NodeAppenderTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NodeAppenderTest, testAppendNode);
|
||||
CppUnit_addTest(pSuite, NodeAppenderTest, testAppendNodeList);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// NodeAppenderTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeAppenderTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NodeAppenderTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/NodeAppender.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/DocumentFragment.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::NodeAppender;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::DocumentFragment;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
NodeAppenderTest::NodeAppenderTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NodeAppenderTest::~NodeAppenderTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::testAppendNode()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeAppender appender(pRoot);
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
|
||||
appender.appendChild(pElem1);
|
||||
appender.appendChild(pElem2);
|
||||
appender.appendChild(pElem3);
|
||||
|
||||
assert (pRoot->firstChild() == pElem1);
|
||||
assert (pRoot->lastChild() == pElem3);
|
||||
|
||||
assert (pElem1->nextSibling() == pElem2);
|
||||
assert (pElem2->nextSibling() == pElem3);
|
||||
assert (pElem3->nextSibling() == 0);
|
||||
|
||||
assert (pElem1->previousSibling() == 0);
|
||||
assert (pElem2->previousSibling() == pElem1);
|
||||
assert (pElem3->previousSibling() == pElem2);
|
||||
|
||||
assert (pElem1->parentNode() == pRoot);
|
||||
assert (pElem2->parentNode() == pRoot);
|
||||
assert (pElem3->parentNode() == pRoot);
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::testAppendNodeList()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeAppender appender(pRoot);
|
||||
|
||||
AutoPtr<DocumentFragment> pFrag1 = pDoc->createDocumentFragment();
|
||||
AutoPtr<DocumentFragment> pFrag2 = pDoc->createDocumentFragment();
|
||||
AutoPtr<DocumentFragment> pFrag3 = pDoc->createDocumentFragment();
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem4 = pDoc->createElement("elem");
|
||||
|
||||
pFrag2->appendChild(pElem1);
|
||||
pFrag2->appendChild(pElem2);
|
||||
pFrag2->appendChild(pElem3);
|
||||
|
||||
pFrag3->appendChild(pElem4);
|
||||
|
||||
appender.appendChild(pFrag1);
|
||||
assert (pRoot->firstChild() == 0);
|
||||
|
||||
appender.appendChild(pFrag2);
|
||||
assert (pRoot->firstChild() == pElem1);
|
||||
assert (pRoot->lastChild() == pElem3);
|
||||
|
||||
assert (pElem1->nextSibling() == pElem2);
|
||||
assert (pElem2->nextSibling() == pElem3);
|
||||
assert (pElem3->nextSibling() == 0);
|
||||
|
||||
assert (pElem1->previousSibling() == 0);
|
||||
assert (pElem2->previousSibling() == pElem1);
|
||||
assert (pElem3->previousSibling() == pElem2);
|
||||
|
||||
assert (pElem1->parentNode() == pRoot);
|
||||
assert (pElem2->parentNode() == pRoot);
|
||||
assert (pElem3->parentNode() == pRoot);
|
||||
|
||||
appender.appendChild(pFrag3);
|
||||
assert (pRoot->lastChild() == pElem4);
|
||||
assert (pElem4->parentNode() == pRoot);
|
||||
assert (pElem3->nextSibling() == pElem4);
|
||||
assert (pElem4->previousSibling() == pElem3);
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NodeAppenderTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NodeAppenderTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NodeAppenderTest, testAppendNode);
|
||||
CppUnit_addTest(pSuite, NodeAppenderTest, testAppendNodeList);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,61 +1,61 @@
|
||||
//
|
||||
// NodeAppenderTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeAppenderTest.h#1 $
|
||||
//
|
||||
// Definition of the NodeAppenderTest class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NodeAppenderTest_INCLUDED
|
||||
#define NodeAppenderTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NodeAppenderTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NodeAppenderTest(const std::string& name);
|
||||
~NodeAppenderTest();
|
||||
|
||||
void testAppendNode();
|
||||
void testAppendNodeList();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NodeAppenderTest_INCLUDED
|
||||
//
|
||||
// NodeAppenderTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeAppenderTest.h#1 $
|
||||
//
|
||||
// Definition of the NodeAppenderTest class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NodeAppenderTest_INCLUDED
|
||||
#define NodeAppenderTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NodeAppenderTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NodeAppenderTest(const std::string& name);
|
||||
~NodeAppenderTest();
|
||||
|
||||
void testAppendNode();
|
||||
void testAppendNodeList();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NodeAppenderTest_INCLUDED
|
||||
|
@@ -1,210 +1,210 @@
|
||||
//
|
||||
// NodeIteratorTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeIteratorTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NodeIteratorTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/NodeIterator.h"
|
||||
#include "Poco/DOM/NodeFilter.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Text.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::NodeIterator;
|
||||
using Poco::XML::NodeFilter;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::Text;
|
||||
using Poco::XML::Node;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
class TestNodeFilter: public NodeFilter
|
||||
{
|
||||
short acceptNode(Node* node)
|
||||
{
|
||||
if (node->innerText() == "text1")
|
||||
return NodeFilter::FILTER_ACCEPT;
|
||||
else
|
||||
return NodeFilter::FILTER_REJECT;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
NodeIteratorTest::NodeIteratorTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NodeIteratorTest::~NodeIteratorTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::testShowAll()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeIterator it(pRoot, NodeFilter::SHOW_ALL);
|
||||
|
||||
assert (it.nextNode() == pRoot);
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == pText1);
|
||||
assert (it.nextNode() == pElem2);
|
||||
assert (it.nextNode() == pText2);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == pText2);
|
||||
assert (it.previousNode() == pElem2);
|
||||
assert (it.previousNode() == pText1);
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == pRoot);
|
||||
assert (it.previousNode() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::testShowElements()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeIterator it(pRoot, NodeFilter::SHOW_ELEMENT);
|
||||
|
||||
assert (it.nextNode() == pRoot);
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == pElem2);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == pElem2);
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == pRoot);
|
||||
assert (it.previousNode() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::testFilter()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
TestNodeFilter filter;
|
||||
NodeIterator it(pRoot, NodeFilter::SHOW_ELEMENT, &filter);
|
||||
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::testShowNothing()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeIterator it(pRoot, 0);
|
||||
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NodeIteratorTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NodeIteratorTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NodeIteratorTest, testShowAll);
|
||||
CppUnit_addTest(pSuite, NodeIteratorTest, testShowElements);
|
||||
CppUnit_addTest(pSuite, NodeIteratorTest, testFilter);
|
||||
CppUnit_addTest(pSuite, NodeIteratorTest, testShowNothing);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// NodeIteratorTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeIteratorTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NodeIteratorTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/NodeIterator.h"
|
||||
#include "Poco/DOM/NodeFilter.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Text.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::NodeIterator;
|
||||
using Poco::XML::NodeFilter;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::Text;
|
||||
using Poco::XML::Node;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
class TestNodeFilter: public NodeFilter
|
||||
{
|
||||
short acceptNode(Node* node)
|
||||
{
|
||||
if (node->innerText() == "text1")
|
||||
return NodeFilter::FILTER_ACCEPT;
|
||||
else
|
||||
return NodeFilter::FILTER_REJECT;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
NodeIteratorTest::NodeIteratorTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NodeIteratorTest::~NodeIteratorTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::testShowAll()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeIterator it(pRoot, NodeFilter::SHOW_ALL);
|
||||
|
||||
assert (it.nextNode() == pRoot);
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == pText1);
|
||||
assert (it.nextNode() == pElem2);
|
||||
assert (it.nextNode() == pText2);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == pText2);
|
||||
assert (it.previousNode() == pElem2);
|
||||
assert (it.previousNode() == pText1);
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == pRoot);
|
||||
assert (it.previousNode() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::testShowElements()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeIterator it(pRoot, NodeFilter::SHOW_ELEMENT);
|
||||
|
||||
assert (it.nextNode() == pRoot);
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == pElem2);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == pElem2);
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == pRoot);
|
||||
assert (it.previousNode() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::testFilter()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
TestNodeFilter filter;
|
||||
NodeIterator it(pRoot, NodeFilter::SHOW_ELEMENT, &filter);
|
||||
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::testShowNothing()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeIterator it(pRoot, 0);
|
||||
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == 0);
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeIteratorTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NodeIteratorTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NodeIteratorTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NodeIteratorTest, testShowAll);
|
||||
CppUnit_addTest(pSuite, NodeIteratorTest, testShowElements);
|
||||
CppUnit_addTest(pSuite, NodeIteratorTest, testFilter);
|
||||
CppUnit_addTest(pSuite, NodeIteratorTest, testShowNothing);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,63 +1,63 @@
|
||||
//
|
||||
// NodeIteratorTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeIteratorTest.h#1 $
|
||||
//
|
||||
// Definition of the NodeIteratorTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NodeIteratorTest_INCLUDED
|
||||
#define NodeIteratorTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NodeIteratorTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NodeIteratorTest(const std::string& name);
|
||||
~NodeIteratorTest();
|
||||
|
||||
void testShowAll();
|
||||
void testShowElements();
|
||||
void testFilter();
|
||||
void testShowNothing();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NodeIteratorTest_INCLUDED
|
||||
//
|
||||
// NodeIteratorTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeIteratorTest.h#1 $
|
||||
//
|
||||
// Definition of the NodeIteratorTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NodeIteratorTest_INCLUDED
|
||||
#define NodeIteratorTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NodeIteratorTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NodeIteratorTest(const std::string& name);
|
||||
~NodeIteratorTest();
|
||||
|
||||
void testShowAll();
|
||||
void testShowElements();
|
||||
void testFilter();
|
||||
void testShowNothing();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NodeIteratorTest_INCLUDED
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,72 +1,72 @@
|
||||
//
|
||||
// NodeTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeTest.h#1 $
|
||||
//
|
||||
// Definition of the NodeTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NodeTest_INCLUDED
|
||||
#define NodeTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NodeTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NodeTest(const std::string& name);
|
||||
~NodeTest();
|
||||
|
||||
void testInsert();
|
||||
void testAppend();
|
||||
void testRemove();
|
||||
void testReplace();
|
||||
void testInsertFragment1();
|
||||
void testInsertFragment2();
|
||||
void testInsertFragment3();
|
||||
void testAppendFragment1();
|
||||
void testAppendFragment2();
|
||||
void testAppendFragment3();
|
||||
void testReplaceFragment1();
|
||||
void testReplaceFragment2();
|
||||
void testReplaceFragment3();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NodeTest_INCLUDED
|
||||
//
|
||||
// NodeTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/NodeTest.h#1 $
|
||||
//
|
||||
// Definition of the NodeTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NodeTest_INCLUDED
|
||||
#define NodeTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NodeTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NodeTest(const std::string& name);
|
||||
~NodeTest();
|
||||
|
||||
void testInsert();
|
||||
void testAppend();
|
||||
void testRemove();
|
||||
void testReplace();
|
||||
void testInsertFragment1();
|
||||
void testInsertFragment2();
|
||||
void testInsertFragment3();
|
||||
void testAppendFragment1();
|
||||
void testAppendFragment2();
|
||||
void testAppendFragment3();
|
||||
void testReplaceFragment1();
|
||||
void testReplaceFragment2();
|
||||
void testReplaceFragment3();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NodeTest_INCLUDED
|
||||
|
@@ -1,191 +1,191 @@
|
||||
//
|
||||
// ParserWriterTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ParserWriterTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "ParserWriterTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/DOMParser.h"
|
||||
#include "Poco/DOM/DOMWriter.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
#include "Poco/SAX/InputSource.h"
|
||||
#include "Poco/XML/XMLWriter.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using Poco::XML::DOMParser;
|
||||
using Poco::XML::DOMWriter;
|
||||
using Poco::XML::XMLReader;
|
||||
using Poco::XML::XMLWriter;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::InputSource;
|
||||
|
||||
|
||||
ParserWriterTest::ParserWriterTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ParserWriterTest::~ParserWriterTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testParseWriteXHTML()
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||
DOMWriter writer;
|
||||
AutoPtr<Document> pDoc = parser.parseString(XHTML);
|
||||
writer.writeNode(ostr, pDoc);
|
||||
|
||||
std::string xml = ostr.str();
|
||||
assert (xml == XHTML);
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testParseWriteXHTML2()
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
|
||||
DOMWriter writer;
|
||||
AutoPtr<Document> pDoc = parser.parseString(XHTML2);
|
||||
writer.writeNode(ostr, pDoc);
|
||||
|
||||
std::string xml = ostr.str();
|
||||
assert (xml == XHTML2);
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testParseWriteSimple()
|
||||
{
|
||||
static const std::string simple =
|
||||
"<config>\n"
|
||||
"\t<prop1>value1</prop1>\n"
|
||||
"\t<prop2>value2</prop2>\n"
|
||||
"</config>\n";
|
||||
|
||||
std::istringstream istr(simple);
|
||||
std::ostringstream ostr;
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(DOMParser::FEATURE_FILTER_WHITESPACE, true);
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||
DOMWriter writer;
|
||||
writer.setNewLine("\n");
|
||||
writer.setOptions(XMLWriter::PRETTY_PRINT);
|
||||
InputSource source(istr);
|
||||
AutoPtr<Document> pDoc = parser.parse(&source);
|
||||
writer.writeNode(ostr, pDoc);
|
||||
|
||||
unsigned int numChildren = 0;
|
||||
Poco::XML::Node* child = pDoc->documentElement()->firstChild();
|
||||
while (child) {
|
||||
numChildren++;
|
||||
child = child->nextSibling();
|
||||
}
|
||||
assert (numChildren == 2);
|
||||
|
||||
std::string xml = ostr.str();
|
||||
assert (xml == simple);
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* ParserWriterTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ParserWriterTest");
|
||||
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML2);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteSimple);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
|
||||
const std::string ParserWriterTest::XHTML =
|
||||
"<!--\n"
|
||||
"\tThis is a comment.\n"
|
||||
"-->"
|
||||
"<ns1:html xml:lang=\"en\" xmlns:ns1=\"http://www.w3.org/1999/xhtml\">\n"
|
||||
"\t<ns1:head>\n"
|
||||
"\t\t<ns1:link href=\"styles.css\" rel=\"stylesheet\" type=\"text/css\"/>\n"
|
||||
"\t\t<?xml-stylesheet href=\"styles.css\" type=\"text/css\"?>\n"
|
||||
"\t\t<ns1:title>A XHTML Example</ns1:title>\n"
|
||||
"\t</ns1:head>\n"
|
||||
"\t<ns1:body>\n"
|
||||
"\t\t<ns1:h1>XHTML Example</ns1:h1>\n"
|
||||
"\t\t<ns1:p>This is a XHTML example page.</ns1:p>\n"
|
||||
"\t\t<ns1:img alt=\"Example Picture\" border=\"0\" height=\"192\" src=\"example.gif\" width=\"256\"/>\n"
|
||||
"\t\t<![CDATA[\n"
|
||||
"\t\tThe following <tag attr=\"value\">is inside a CDATA section</tag>.\n"
|
||||
"\t\t]]>\n"
|
||||
"\t</ns1:body>\n"
|
||||
"</ns1:html>";
|
||||
|
||||
|
||||
const std::string ParserWriterTest::XHTML2 =
|
||||
"<!--\n"
|
||||
"\tThis is a comment.\n"
|
||||
"-->"
|
||||
"<xns:html xml:lang=\"en\" xmlns:xns=\"http://www.w3.org/1999/xhtml\">\n"
|
||||
"\t<xns:head>\n"
|
||||
"\t\t<xns:link href=\"styles.css\" rel=\"stylesheet\" type=\"text/css\"/>\n"
|
||||
"\t\t<?xml-stylesheet href=\"styles.css\" type=\"text/css\"?>\n"
|
||||
"\t\t<xns:title>A XHTML Example</xns:title>\n"
|
||||
"\t</xns:head>\n"
|
||||
"\t<xns:body>\n"
|
||||
"\t\t<xns:h1>XHTML Example</xns:h1>\n"
|
||||
"\t\t<xns:p>This is a XHTML example page.</xns:p>\n"
|
||||
"\t\t<xns:img alt=\"Example Picture\" border=\"0\" height=\"192\" src=\"example.gif\" width=\"256\"/>\n"
|
||||
"\t\t<![CDATA[\n"
|
||||
"\t\tThe following <tag attr=\"value\">is inside a CDATA section</tag>.\n"
|
||||
"\t\t]]>\n"
|
||||
"\t</xns:body>\n"
|
||||
"</xns:html>";
|
||||
|
||||
//
|
||||
// ParserWriterTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ParserWriterTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "ParserWriterTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/DOMParser.h"
|
||||
#include "Poco/DOM/DOMWriter.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
#include "Poco/SAX/InputSource.h"
|
||||
#include "Poco/XML/XMLWriter.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using Poco::XML::DOMParser;
|
||||
using Poco::XML::DOMWriter;
|
||||
using Poco::XML::XMLReader;
|
||||
using Poco::XML::XMLWriter;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::InputSource;
|
||||
|
||||
|
||||
ParserWriterTest::ParserWriterTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ParserWriterTest::~ParserWriterTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testParseWriteXHTML()
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||
DOMWriter writer;
|
||||
AutoPtr<Document> pDoc = parser.parseString(XHTML);
|
||||
writer.writeNode(ostr, pDoc);
|
||||
|
||||
std::string xml = ostr.str();
|
||||
assert (xml == XHTML);
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testParseWriteXHTML2()
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
|
||||
DOMWriter writer;
|
||||
AutoPtr<Document> pDoc = parser.parseString(XHTML2);
|
||||
writer.writeNode(ostr, pDoc);
|
||||
|
||||
std::string xml = ostr.str();
|
||||
assert (xml == XHTML2);
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testParseWriteSimple()
|
||||
{
|
||||
static const std::string simple =
|
||||
"<config>\n"
|
||||
"\t<prop1>value1</prop1>\n"
|
||||
"\t<prop2>value2</prop2>\n"
|
||||
"</config>\n";
|
||||
|
||||
std::istringstream istr(simple);
|
||||
std::ostringstream ostr;
|
||||
|
||||
DOMParser parser;
|
||||
parser.setFeature(DOMParser::FEATURE_FILTER_WHITESPACE, true);
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||
DOMWriter writer;
|
||||
writer.setNewLine("\n");
|
||||
writer.setOptions(XMLWriter::PRETTY_PRINT);
|
||||
InputSource source(istr);
|
||||
AutoPtr<Document> pDoc = parser.parse(&source);
|
||||
writer.writeNode(ostr, pDoc);
|
||||
|
||||
unsigned int numChildren = 0;
|
||||
Poco::XML::Node* child = pDoc->documentElement()->firstChild();
|
||||
while (child) {
|
||||
numChildren++;
|
||||
child = child->nextSibling();
|
||||
}
|
||||
assert (numChildren == 2);
|
||||
|
||||
std::string xml = ostr.str();
|
||||
assert (xml == simple);
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* ParserWriterTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ParserWriterTest");
|
||||
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML2);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteSimple);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
|
||||
const std::string ParserWriterTest::XHTML =
|
||||
"<!--\n"
|
||||
"\tThis is a comment.\n"
|
||||
"-->"
|
||||
"<ns1:html xml:lang=\"en\" xmlns:ns1=\"http://www.w3.org/1999/xhtml\">\n"
|
||||
"\t<ns1:head>\n"
|
||||
"\t\t<ns1:link href=\"styles.css\" rel=\"stylesheet\" type=\"text/css\"/>\n"
|
||||
"\t\t<?xml-stylesheet href=\"styles.css\" type=\"text/css\"?>\n"
|
||||
"\t\t<ns1:title>A XHTML Example</ns1:title>\n"
|
||||
"\t</ns1:head>\n"
|
||||
"\t<ns1:body>\n"
|
||||
"\t\t<ns1:h1>XHTML Example</ns1:h1>\n"
|
||||
"\t\t<ns1:p>This is a XHTML example page.</ns1:p>\n"
|
||||
"\t\t<ns1:img alt=\"Example Picture\" border=\"0\" height=\"192\" src=\"example.gif\" width=\"256\"/>\n"
|
||||
"\t\t<![CDATA[\n"
|
||||
"\t\tThe following <tag attr=\"value\">is inside a CDATA section</tag>.\n"
|
||||
"\t\t]]>\n"
|
||||
"\t</ns1:body>\n"
|
||||
"</ns1:html>";
|
||||
|
||||
|
||||
const std::string ParserWriterTest::XHTML2 =
|
||||
"<!--\n"
|
||||
"\tThis is a comment.\n"
|
||||
"-->"
|
||||
"<xns:html xml:lang=\"en\" xmlns:xns=\"http://www.w3.org/1999/xhtml\">\n"
|
||||
"\t<xns:head>\n"
|
||||
"\t\t<xns:link href=\"styles.css\" rel=\"stylesheet\" type=\"text/css\"/>\n"
|
||||
"\t\t<?xml-stylesheet href=\"styles.css\" type=\"text/css\"?>\n"
|
||||
"\t\t<xns:title>A XHTML Example</xns:title>\n"
|
||||
"\t</xns:head>\n"
|
||||
"\t<xns:body>\n"
|
||||
"\t\t<xns:h1>XHTML Example</xns:h1>\n"
|
||||
"\t\t<xns:p>This is a XHTML example page.</xns:p>\n"
|
||||
"\t\t<xns:img alt=\"Example Picture\" border=\"0\" height=\"192\" src=\"example.gif\" width=\"256\"/>\n"
|
||||
"\t\t<![CDATA[\n"
|
||||
"\t\tThe following <tag attr=\"value\">is inside a CDATA section</tag>.\n"
|
||||
"\t\t]]>\n"
|
||||
"\t</xns:body>\n"
|
||||
"</xns:html>";
|
||||
|
||||
|
@@ -1,65 +1,65 @@
|
||||
//
|
||||
// ParserWriterTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ParserWriterTest.h#1 $
|
||||
//
|
||||
// Definition of the ParserWriterTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef ParserWriterTest_INCLUDED
|
||||
#define ParserWriterTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class ParserWriterTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ParserWriterTest(const std::string& name);
|
||||
~ParserWriterTest();
|
||||
|
||||
void testParseWriteXHTML();
|
||||
void testParseWriteXHTML2();
|
||||
void testParseWriteWSDL();
|
||||
void testParseWriteSimple();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
static const std::string XHTML;
|
||||
static const std::string XHTML2;
|
||||
};
|
||||
|
||||
|
||||
#endif // ParserWriterTest_INCLUDED
|
||||
//
|
||||
// ParserWriterTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/ParserWriterTest.h#1 $
|
||||
//
|
||||
// Definition of the ParserWriterTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef ParserWriterTest_INCLUDED
|
||||
#define ParserWriterTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class ParserWriterTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ParserWriterTest(const std::string& name);
|
||||
~ParserWriterTest();
|
||||
|
||||
void testParseWriteXHTML();
|
||||
void testParseWriteXHTML2();
|
||||
void testParseWriteWSDL();
|
||||
void testParseWriteSimple();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
static const std::string XHTML;
|
||||
static const std::string XHTML2;
|
||||
};
|
||||
|
||||
|
||||
#endif // ParserWriterTest_INCLUDED
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,104 +1,104 @@
|
||||
//
|
||||
// SAXParserTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/SAXParserTest.h#1 $
|
||||
//
|
||||
// Definition of the SAXParserTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAXParserTest_INCLUDED
|
||||
#define SAXParserTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "Poco/SAX/XMLReader.h"
|
||||
|
||||
|
||||
class SAXParserTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
SAXParserTest(const std::string& name);
|
||||
~SAXParserTest();
|
||||
|
||||
void testSimple1();
|
||||
void testSimple2();
|
||||
void testAttributes();
|
||||
void testCDATA();
|
||||
void testComment();
|
||||
void testPI();
|
||||
void testDTD();
|
||||
void testInternalEntity();
|
||||
void testNotation();
|
||||
void testExternalUnparsed();
|
||||
void testExternalParsed();
|
||||
void testDefaultNamespace();
|
||||
void testNamespaces();
|
||||
void testNamespacesNoPrefixes();
|
||||
void testNoNamespaces();
|
||||
void testUndeclaredNamespace();
|
||||
void testUndeclaredNamespaceNoPrefixes();
|
||||
void testUndeclaredNoNamespace();
|
||||
void testRSS();
|
||||
void testEncoding();
|
||||
void testParseMemory();
|
||||
void testCharacters();
|
||||
void testParsePartialReads();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
std::string parse(Poco::XML::XMLReader& reader, int options, const std::string& data);
|
||||
std::string parseMemory(Poco::XML::XMLReader& reader, int options, const std::string& data);
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
static const std::string SIMPLE1;
|
||||
static const std::string SIMPLE2;
|
||||
static const std::string ATTRIBUTES;
|
||||
static const std::string CDATA;
|
||||
static const std::string COMMENT;
|
||||
static const std::string PROCESSING_INSTRUCTION;
|
||||
static const std::string DTD;
|
||||
static const std::string INTERNAL_ENTITY;
|
||||
static const std::string NOTATION;
|
||||
static const std::string EXTERNAL_UNPARSED;
|
||||
static const std::string EXTERNAL_PARSED;
|
||||
static const std::string INCLUDE;
|
||||
static const std::string DEFAULT_NAMESPACE;
|
||||
static const std::string NAMESPACES;
|
||||
static const std::string UNDECLARED_NAMESPACE;
|
||||
static const std::string XHTML_LATIN1_ENTITIES;
|
||||
static const std::string RSS;
|
||||
static const std::string ENCODING;
|
||||
static const std::string WSDL;
|
||||
};
|
||||
|
||||
|
||||
#endif // SAXParserTest_INCLUDED
|
||||
//
|
||||
// SAXParserTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/SAXParserTest.h#1 $
|
||||
//
|
||||
// Definition of the SAXParserTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAXParserTest_INCLUDED
|
||||
#define SAXParserTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "Poco/SAX/XMLReader.h"
|
||||
|
||||
|
||||
class SAXParserTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
SAXParserTest(const std::string& name);
|
||||
~SAXParserTest();
|
||||
|
||||
void testSimple1();
|
||||
void testSimple2();
|
||||
void testAttributes();
|
||||
void testCDATA();
|
||||
void testComment();
|
||||
void testPI();
|
||||
void testDTD();
|
||||
void testInternalEntity();
|
||||
void testNotation();
|
||||
void testExternalUnparsed();
|
||||
void testExternalParsed();
|
||||
void testDefaultNamespace();
|
||||
void testNamespaces();
|
||||
void testNamespacesNoPrefixes();
|
||||
void testNoNamespaces();
|
||||
void testUndeclaredNamespace();
|
||||
void testUndeclaredNamespaceNoPrefixes();
|
||||
void testUndeclaredNoNamespace();
|
||||
void testRSS();
|
||||
void testEncoding();
|
||||
void testParseMemory();
|
||||
void testCharacters();
|
||||
void testParsePartialReads();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
std::string parse(Poco::XML::XMLReader& reader, int options, const std::string& data);
|
||||
std::string parseMemory(Poco::XML::XMLReader& reader, int options, const std::string& data);
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
static const std::string SIMPLE1;
|
||||
static const std::string SIMPLE2;
|
||||
static const std::string ATTRIBUTES;
|
||||
static const std::string CDATA;
|
||||
static const std::string COMMENT;
|
||||
static const std::string PROCESSING_INSTRUCTION;
|
||||
static const std::string DTD;
|
||||
static const std::string INTERNAL_ENTITY;
|
||||
static const std::string NOTATION;
|
||||
static const std::string EXTERNAL_UNPARSED;
|
||||
static const std::string EXTERNAL_PARSED;
|
||||
static const std::string INCLUDE;
|
||||
static const std::string DEFAULT_NAMESPACE;
|
||||
static const std::string NAMESPACES;
|
||||
static const std::string UNDECLARED_NAMESPACE;
|
||||
static const std::string XHTML_LATIN1_ENTITIES;
|
||||
static const std::string RSS;
|
||||
static const std::string ENCODING;
|
||||
static const std::string WSDL;
|
||||
};
|
||||
|
||||
|
||||
#endif // SAXParserTest_INCLUDED
|
||||
|
@@ -1,48 +1,48 @@
|
||||
//
|
||||
// SAXTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/SAXTestSuite.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "SAXTestSuite.h"
|
||||
#include "AttributesImplTest.h"
|
||||
#include "NamespaceSupportTest.h"
|
||||
#include "SAXParserTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* SAXTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SAXTestSuite");
|
||||
|
||||
pSuite->addTest(AttributesImplTest::suite());
|
||||
pSuite->addTest(NamespaceSupportTest::suite());
|
||||
pSuite->addTest(SAXParserTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// SAXTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/SAXTestSuite.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "SAXTestSuite.h"
|
||||
#include "AttributesImplTest.h"
|
||||
#include "NamespaceSupportTest.h"
|
||||
#include "SAXParserTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* SAXTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SAXTestSuite");
|
||||
|
||||
pSuite->addTest(AttributesImplTest::suite());
|
||||
pSuite->addTest(NamespaceSupportTest::suite());
|
||||
pSuite->addTest(SAXParserTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,49 +1,49 @@
|
||||
//
|
||||
// SAXTestSuite.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/SAXTestSuite.h#1 $
|
||||
//
|
||||
// Definition of the SAXTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAXTestSuite_INCLUDED
|
||||
#define SAXTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class SAXTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // SAXTestSuite_INCLUDED
|
||||
//
|
||||
// SAXTestSuite.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/SAXTestSuite.h#1 $
|
||||
//
|
||||
// Definition of the SAXTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAXTestSuite_INCLUDED
|
||||
#define SAXTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class SAXTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // SAXTestSuite_INCLUDED
|
||||
|
@@ -1,189 +1,189 @@
|
||||
//
|
||||
// TextTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/TextTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "TextTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/Text.h"
|
||||
#include "Poco/DOM/CDATASection.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::Text;
|
||||
using Poco::XML::CDATASection;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
TextTest::TextTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TextTest::~TextTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testLength()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("");
|
||||
assert (pText1->length() == 0);
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("foo bar");
|
||||
assert (pText2->length() == 7);
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testSubstring()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foo bar");
|
||||
XMLString str = pText1->substringData(0, 3);
|
||||
assert (str == "foo");
|
||||
str = pText1->substringData(4, 3);
|
||||
assert (str == "bar");
|
||||
str = pText1->substringData(3, 0);
|
||||
assert (str == "");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testAppend()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foo");
|
||||
pText1->appendData("bar");
|
||||
assert (pText1->data() == "foobar");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testInsert()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("bar");
|
||||
pText1->insertData(0, "foo");
|
||||
assert (pText1->data() == "foobar");
|
||||
pText1->insertData(pText1->length(), "!");
|
||||
assert (pText1->data() == "foobar!");
|
||||
pText1->insertData(3, " ");
|
||||
assert (pText1->data() == "foo bar!");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testDelete()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foo bar");
|
||||
pText1->deleteData(3, 1);
|
||||
assert (pText1->data() == "foobar");
|
||||
pText1->deleteData(0, 3);
|
||||
assert (pText1->data() == "bar");
|
||||
pText1->deleteData(1, 0);
|
||||
assert (pText1->data() == "bar");
|
||||
pText1->deleteData(0, pText1->length());
|
||||
assert (pText1->data() == "");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testReplace()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foo bar");
|
||||
pText1->replaceData(0, 3, "FOO");
|
||||
assert (pText1->data() == "FOO bar");
|
||||
pText1->replaceData(4, 3, "BAR!!!");
|
||||
assert (pText1->data() == "FOO BAR!!!");
|
||||
pText1->replaceData(3, 1, "-");
|
||||
assert (pText1->data() == "FOO-BAR!!!");
|
||||
pText1->replaceData(3, 1, "---");
|
||||
assert (pText1->data() == "FOO---BAR!!!");
|
||||
pText1->replaceData(3, 3, " ");
|
||||
assert (pText1->data() == "FOO BAR!!!");
|
||||
pText1->replaceData(0, pText1->length(), "foo bar");
|
||||
assert (pText1->data() == "foo bar");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testSplit()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pElem = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createCDATASection("foobar");
|
||||
pElem->appendChild(pText1);
|
||||
pText1->splitText(3);
|
||||
assert (pElem->firstChild()->nodeValue() == "foo");
|
||||
assert (pElem->lastChild()->nodeValue() == "bar");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testSplitCDATA()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pElem = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foobar");
|
||||
pElem->appendChild(pText1);
|
||||
pText1->splitText(3);
|
||||
assert (pElem->firstChild()->nodeValue() == "foo");
|
||||
assert (pElem->lastChild()->nodeValue() == "bar");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TextTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TextTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* TextTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TextTest");
|
||||
|
||||
CppUnit_addTest(pSuite, TextTest, testLength);
|
||||
CppUnit_addTest(pSuite, TextTest, testSubstring);
|
||||
CppUnit_addTest(pSuite, TextTest, testAppend);
|
||||
CppUnit_addTest(pSuite, TextTest, testInsert);
|
||||
CppUnit_addTest(pSuite, TextTest, testDelete);
|
||||
CppUnit_addTest(pSuite, TextTest, testReplace);
|
||||
CppUnit_addTest(pSuite, TextTest, testSplit);
|
||||
CppUnit_addTest(pSuite, TextTest, testSplitCDATA);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// TextTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/TextTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "TextTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/Text.h"
|
||||
#include "Poco/DOM/CDATASection.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::Text;
|
||||
using Poco::XML::CDATASection;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
TextTest::TextTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TextTest::~TextTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testLength()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("");
|
||||
assert (pText1->length() == 0);
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("foo bar");
|
||||
assert (pText2->length() == 7);
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testSubstring()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foo bar");
|
||||
XMLString str = pText1->substringData(0, 3);
|
||||
assert (str == "foo");
|
||||
str = pText1->substringData(4, 3);
|
||||
assert (str == "bar");
|
||||
str = pText1->substringData(3, 0);
|
||||
assert (str == "");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testAppend()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foo");
|
||||
pText1->appendData("bar");
|
||||
assert (pText1->data() == "foobar");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testInsert()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("bar");
|
||||
pText1->insertData(0, "foo");
|
||||
assert (pText1->data() == "foobar");
|
||||
pText1->insertData(pText1->length(), "!");
|
||||
assert (pText1->data() == "foobar!");
|
||||
pText1->insertData(3, " ");
|
||||
assert (pText1->data() == "foo bar!");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testDelete()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foo bar");
|
||||
pText1->deleteData(3, 1);
|
||||
assert (pText1->data() == "foobar");
|
||||
pText1->deleteData(0, 3);
|
||||
assert (pText1->data() == "bar");
|
||||
pText1->deleteData(1, 0);
|
||||
assert (pText1->data() == "bar");
|
||||
pText1->deleteData(0, pText1->length());
|
||||
assert (pText1->data() == "");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testReplace()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foo bar");
|
||||
pText1->replaceData(0, 3, "FOO");
|
||||
assert (pText1->data() == "FOO bar");
|
||||
pText1->replaceData(4, 3, "BAR!!!");
|
||||
assert (pText1->data() == "FOO BAR!!!");
|
||||
pText1->replaceData(3, 1, "-");
|
||||
assert (pText1->data() == "FOO-BAR!!!");
|
||||
pText1->replaceData(3, 1, "---");
|
||||
assert (pText1->data() == "FOO---BAR!!!");
|
||||
pText1->replaceData(3, 3, " ");
|
||||
assert (pText1->data() == "FOO BAR!!!");
|
||||
pText1->replaceData(0, pText1->length(), "foo bar");
|
||||
assert (pText1->data() == "foo bar");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testSplit()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pElem = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createCDATASection("foobar");
|
||||
pElem->appendChild(pText1);
|
||||
pText1->splitText(3);
|
||||
assert (pElem->firstChild()->nodeValue() == "foo");
|
||||
assert (pElem->lastChild()->nodeValue() == "bar");
|
||||
}
|
||||
|
||||
|
||||
void TextTest::testSplitCDATA()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pElem = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("foobar");
|
||||
pElem->appendChild(pText1);
|
||||
pText1->splitText(3);
|
||||
assert (pElem->firstChild()->nodeValue() == "foo");
|
||||
assert (pElem->lastChild()->nodeValue() == "bar");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TextTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TextTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* TextTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TextTest");
|
||||
|
||||
CppUnit_addTest(pSuite, TextTest, testLength);
|
||||
CppUnit_addTest(pSuite, TextTest, testSubstring);
|
||||
CppUnit_addTest(pSuite, TextTest, testAppend);
|
||||
CppUnit_addTest(pSuite, TextTest, testInsert);
|
||||
CppUnit_addTest(pSuite, TextTest, testDelete);
|
||||
CppUnit_addTest(pSuite, TextTest, testReplace);
|
||||
CppUnit_addTest(pSuite, TextTest, testSplit);
|
||||
CppUnit_addTest(pSuite, TextTest, testSplitCDATA);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,67 +1,67 @@
|
||||
//
|
||||
// TextTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/TextTest.h#1 $
|
||||
//
|
||||
// Definition of the TextTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef TextTest_INCLUDED
|
||||
#define TextTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class TextTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
TextTest(const std::string& name);
|
||||
~TextTest();
|
||||
|
||||
void testLength();
|
||||
void testSubstring();
|
||||
void testAppend();
|
||||
void testInsert();
|
||||
void testDelete();
|
||||
void testReplace();
|
||||
void testSplit();
|
||||
void testSplitCDATA();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // TextTest_INCLUDED
|
||||
//
|
||||
// TextTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/TextTest.h#1 $
|
||||
//
|
||||
// Definition of the TextTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef TextTest_INCLUDED
|
||||
#define TextTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class TextTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
TextTest(const std::string& name);
|
||||
~TextTest();
|
||||
|
||||
void testLength();
|
||||
void testSubstring();
|
||||
void testAppend();
|
||||
void testInsert();
|
||||
void testDelete();
|
||||
void testReplace();
|
||||
void testSplit();
|
||||
void testSplitCDATA();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // TextTest_INCLUDED
|
||||
|
@@ -1,329 +1,329 @@
|
||||
//
|
||||
// TreeWalkerTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/TreeWalkerTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "TreeWalkerTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/TreeWalker.h"
|
||||
#include "Poco/DOM/NodeFilter.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Text.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::TreeWalker;
|
||||
using Poco::XML::NodeFilter;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::Text;
|
||||
using Poco::XML::Node;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
class RejectNodeFilter: public NodeFilter
|
||||
{
|
||||
short acceptNode(Node* node)
|
||||
{
|
||||
if (node->nodeType() != Node::ELEMENT_NODE || node->innerText() == "text1" || node->nodeName() == "root")
|
||||
return NodeFilter::FILTER_ACCEPT;
|
||||
else
|
||||
return NodeFilter::FILTER_REJECT;
|
||||
}
|
||||
};
|
||||
|
||||
class SkipNodeFilter: public NodeFilter
|
||||
{
|
||||
short acceptNode(Node* node)
|
||||
{
|
||||
if (node->nodeType() != Node::ELEMENT_NODE || node->innerText() == "text1")
|
||||
return NodeFilter::FILTER_ACCEPT;
|
||||
else
|
||||
return NodeFilter::FILTER_SKIP;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
TreeWalkerTest::TreeWalkerTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TreeWalkerTest::~TreeWalkerTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::testShowAll()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
TreeWalker it(pRoot, NodeFilter::SHOW_ALL);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == pText1);
|
||||
assert (it.nextNode() == pElem2);
|
||||
assert (it.nextNode() == pText2);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pText2);
|
||||
assert (it.previousNode() == pElem2);
|
||||
assert (it.previousNode() == pText1);
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == pRoot);
|
||||
assert (it.previousNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.parentNode() == 0);
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.firstChild() == pElem1);
|
||||
assert (it.parentNode() == pRoot);
|
||||
assert (it.lastChild() == pElem2);
|
||||
assert (it.previousSibling() == pElem1);
|
||||
assert (it.previousSibling() == 0);
|
||||
assert (it.currentNode() == pElem1);
|
||||
assert (it.nextSibling() == pElem2);
|
||||
assert (it.nextSibling() == 0);
|
||||
assert (it.currentNode() == pElem2);
|
||||
assert (it.firstChild() == pText2);
|
||||
assert (it.nextSibling() == 0);
|
||||
assert (it.previousSibling() == 0);
|
||||
assert (it.parentNode() == pElem2);
|
||||
assert (it.lastChild() == pText2);
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::testShowElements()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
TreeWalker it(pRoot, NodeFilter::SHOW_ELEMENT);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == pElem2);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pElem2);
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == pRoot);
|
||||
assert (it.previousNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.parentNode() == 0);
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.firstChild() == pElem1);
|
||||
assert (it.parentNode() == pRoot);
|
||||
assert (it.lastChild() == pElem2);
|
||||
assert (it.firstChild() == 0);
|
||||
assert (it.currentNode() == pElem2);
|
||||
assert (it.lastChild() == 0);
|
||||
assert (it.currentNode() == pElem2);
|
||||
assert (it.previousSibling() == pElem1);
|
||||
assert (it.firstChild() == 0);
|
||||
assert (it.lastChild() == 0);
|
||||
assert (it.parentNode() == pRoot);
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::testFilter()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
SkipNodeFilter skipFilter;
|
||||
TreeWalker it1(pRoot, NodeFilter::SHOW_ELEMENT, &skipFilter);
|
||||
|
||||
assert (it1.nextNode() == pElem1);
|
||||
assert (it1.nextNode() == 0);
|
||||
|
||||
assert (it1.currentNode() == pElem1);
|
||||
assert (it1.previousNode() == 0);
|
||||
|
||||
assert (it1.parentNode() == 0);
|
||||
assert (it1.firstChild() == 0);
|
||||
assert (it1.lastChild() == 0);
|
||||
assert (it1.nextSibling() == 0);
|
||||
assert (it1.previousSibling() == 0);
|
||||
|
||||
TreeWalker it2(pRoot, NodeFilter::SHOW_ALL, &skipFilter);
|
||||
|
||||
assert (it2.nextNode() == pElem1);
|
||||
assert (it2.nextNode() == pText1);
|
||||
assert (it2.nextNode() == pText2);
|
||||
assert (it2.nextNode() == 0);
|
||||
|
||||
assert (it2.currentNode() == pText2);
|
||||
assert (it2.previousNode() == pText1);
|
||||
assert (it2.previousNode() == pElem1);
|
||||
assert (it2.previousNode() == 0);
|
||||
|
||||
assert (it2.currentNode() == pElem1);
|
||||
assert (it2.parentNode() == 0);
|
||||
assert (it2.nextSibling() == 0);
|
||||
assert (it2.previousSibling() == 0);
|
||||
assert (it2.firstChild() == pText1);
|
||||
assert (it2.nextSibling() == 0);
|
||||
assert (it2.previousSibling() == 0);
|
||||
assert (it2.parentNode() == pElem1);
|
||||
|
||||
RejectNodeFilter rejectFilter;
|
||||
TreeWalker it3(pRoot, NodeFilter::SHOW_ELEMENT, &rejectFilter);
|
||||
|
||||
assert (it3.nextNode() == pElem1);
|
||||
assert (it3.nextNode() == 0);
|
||||
|
||||
assert (it3.currentNode() == pElem1);
|
||||
assert (it3.previousNode() == pRoot);
|
||||
assert (it3.previousNode() == 0);
|
||||
|
||||
assert (it3.currentNode() == pRoot);
|
||||
assert (it3.parentNode() == 0);
|
||||
assert (it3.firstChild() == pElem1);
|
||||
assert (it3.nextSibling() == 0);
|
||||
assert (it3.previousSibling() == 0);
|
||||
assert (it3.parentNode() == pRoot);
|
||||
assert (it3.lastChild() == pElem1);
|
||||
|
||||
TreeWalker it4(pRoot, NodeFilter::SHOW_ALL, &rejectFilter);
|
||||
|
||||
assert (it4.nextNode() == pElem1);
|
||||
assert (it4.nextNode() == pText1);
|
||||
assert (it4.nextNode() == 0);
|
||||
|
||||
assert (it4.currentNode() == pText1);
|
||||
assert (it4.previousNode() == pElem1);
|
||||
assert (it4.previousNode() == pRoot);
|
||||
assert (it4.previousNode() == 0);
|
||||
|
||||
assert (it4.currentNode() == pRoot);
|
||||
assert (it4.parentNode() == 0);
|
||||
assert (it4.firstChild() == pElem1);
|
||||
assert (it4.firstChild() == pText1);
|
||||
assert (it4.nextSibling() == 0);
|
||||
assert (it4.previousSibling() == 0);
|
||||
assert (it4.parentNode() == pElem1);
|
||||
assert (it4.lastChild() == pText1);
|
||||
assert (it4.parentNode() == pElem1);
|
||||
assert (it4.nextSibling() == 0);
|
||||
assert (it4.previousSibling() == 0);
|
||||
assert (it4.parentNode() == pRoot);
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::testShowNothing()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
TreeWalker it(pRoot, 0);
|
||||
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.firstChild() == 0);
|
||||
assert (it.lastChild() == 0);
|
||||
assert (it.nextSibling() == 0);
|
||||
assert (it.previousSibling() == 0);
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* TreeWalkerTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TreeWalkerTest");
|
||||
|
||||
CppUnit_addTest(pSuite, TreeWalkerTest, testShowAll);
|
||||
CppUnit_addTest(pSuite, TreeWalkerTest, testShowElements);
|
||||
CppUnit_addTest(pSuite, TreeWalkerTest, testFilter);
|
||||
CppUnit_addTest(pSuite, TreeWalkerTest, testShowNothing);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// TreeWalkerTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/TreeWalkerTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "TreeWalkerTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/TreeWalker.h"
|
||||
#include "Poco/DOM/NodeFilter.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Text.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::TreeWalker;
|
||||
using Poco::XML::NodeFilter;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::Text;
|
||||
using Poco::XML::Node;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
class RejectNodeFilter: public NodeFilter
|
||||
{
|
||||
short acceptNode(Node* node)
|
||||
{
|
||||
if (node->nodeType() != Node::ELEMENT_NODE || node->innerText() == "text1" || node->nodeName() == "root")
|
||||
return NodeFilter::FILTER_ACCEPT;
|
||||
else
|
||||
return NodeFilter::FILTER_REJECT;
|
||||
}
|
||||
};
|
||||
|
||||
class SkipNodeFilter: public NodeFilter
|
||||
{
|
||||
short acceptNode(Node* node)
|
||||
{
|
||||
if (node->nodeType() != Node::ELEMENT_NODE || node->innerText() == "text1")
|
||||
return NodeFilter::FILTER_ACCEPT;
|
||||
else
|
||||
return NodeFilter::FILTER_SKIP;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
TreeWalkerTest::TreeWalkerTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TreeWalkerTest::~TreeWalkerTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::testShowAll()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
TreeWalker it(pRoot, NodeFilter::SHOW_ALL);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == pText1);
|
||||
assert (it.nextNode() == pElem2);
|
||||
assert (it.nextNode() == pText2);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pText2);
|
||||
assert (it.previousNode() == pElem2);
|
||||
assert (it.previousNode() == pText1);
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == pRoot);
|
||||
assert (it.previousNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.parentNode() == 0);
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.firstChild() == pElem1);
|
||||
assert (it.parentNode() == pRoot);
|
||||
assert (it.lastChild() == pElem2);
|
||||
assert (it.previousSibling() == pElem1);
|
||||
assert (it.previousSibling() == 0);
|
||||
assert (it.currentNode() == pElem1);
|
||||
assert (it.nextSibling() == pElem2);
|
||||
assert (it.nextSibling() == 0);
|
||||
assert (it.currentNode() == pElem2);
|
||||
assert (it.firstChild() == pText2);
|
||||
assert (it.nextSibling() == 0);
|
||||
assert (it.previousSibling() == 0);
|
||||
assert (it.parentNode() == pElem2);
|
||||
assert (it.lastChild() == pText2);
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::testShowElements()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
TreeWalker it(pRoot, NodeFilter::SHOW_ELEMENT);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.nextNode() == pElem1);
|
||||
assert (it.nextNode() == pElem2);
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pElem2);
|
||||
assert (it.previousNode() == pElem1);
|
||||
assert (it.previousNode() == pRoot);
|
||||
assert (it.previousNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.parentNode() == 0);
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.firstChild() == pElem1);
|
||||
assert (it.parentNode() == pRoot);
|
||||
assert (it.lastChild() == pElem2);
|
||||
assert (it.firstChild() == 0);
|
||||
assert (it.currentNode() == pElem2);
|
||||
assert (it.lastChild() == 0);
|
||||
assert (it.currentNode() == pElem2);
|
||||
assert (it.previousSibling() == pElem1);
|
||||
assert (it.firstChild() == 0);
|
||||
assert (it.lastChild() == 0);
|
||||
assert (it.parentNode() == pRoot);
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::testFilter()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
SkipNodeFilter skipFilter;
|
||||
TreeWalker it1(pRoot, NodeFilter::SHOW_ELEMENT, &skipFilter);
|
||||
|
||||
assert (it1.nextNode() == pElem1);
|
||||
assert (it1.nextNode() == 0);
|
||||
|
||||
assert (it1.currentNode() == pElem1);
|
||||
assert (it1.previousNode() == 0);
|
||||
|
||||
assert (it1.parentNode() == 0);
|
||||
assert (it1.firstChild() == 0);
|
||||
assert (it1.lastChild() == 0);
|
||||
assert (it1.nextSibling() == 0);
|
||||
assert (it1.previousSibling() == 0);
|
||||
|
||||
TreeWalker it2(pRoot, NodeFilter::SHOW_ALL, &skipFilter);
|
||||
|
||||
assert (it2.nextNode() == pElem1);
|
||||
assert (it2.nextNode() == pText1);
|
||||
assert (it2.nextNode() == pText2);
|
||||
assert (it2.nextNode() == 0);
|
||||
|
||||
assert (it2.currentNode() == pText2);
|
||||
assert (it2.previousNode() == pText1);
|
||||
assert (it2.previousNode() == pElem1);
|
||||
assert (it2.previousNode() == 0);
|
||||
|
||||
assert (it2.currentNode() == pElem1);
|
||||
assert (it2.parentNode() == 0);
|
||||
assert (it2.nextSibling() == 0);
|
||||
assert (it2.previousSibling() == 0);
|
||||
assert (it2.firstChild() == pText1);
|
||||
assert (it2.nextSibling() == 0);
|
||||
assert (it2.previousSibling() == 0);
|
||||
assert (it2.parentNode() == pElem1);
|
||||
|
||||
RejectNodeFilter rejectFilter;
|
||||
TreeWalker it3(pRoot, NodeFilter::SHOW_ELEMENT, &rejectFilter);
|
||||
|
||||
assert (it3.nextNode() == pElem1);
|
||||
assert (it3.nextNode() == 0);
|
||||
|
||||
assert (it3.currentNode() == pElem1);
|
||||
assert (it3.previousNode() == pRoot);
|
||||
assert (it3.previousNode() == 0);
|
||||
|
||||
assert (it3.currentNode() == pRoot);
|
||||
assert (it3.parentNode() == 0);
|
||||
assert (it3.firstChild() == pElem1);
|
||||
assert (it3.nextSibling() == 0);
|
||||
assert (it3.previousSibling() == 0);
|
||||
assert (it3.parentNode() == pRoot);
|
||||
assert (it3.lastChild() == pElem1);
|
||||
|
||||
TreeWalker it4(pRoot, NodeFilter::SHOW_ALL, &rejectFilter);
|
||||
|
||||
assert (it4.nextNode() == pElem1);
|
||||
assert (it4.nextNode() == pText1);
|
||||
assert (it4.nextNode() == 0);
|
||||
|
||||
assert (it4.currentNode() == pText1);
|
||||
assert (it4.previousNode() == pElem1);
|
||||
assert (it4.previousNode() == pRoot);
|
||||
assert (it4.previousNode() == 0);
|
||||
|
||||
assert (it4.currentNode() == pRoot);
|
||||
assert (it4.parentNode() == 0);
|
||||
assert (it4.firstChild() == pElem1);
|
||||
assert (it4.firstChild() == pText1);
|
||||
assert (it4.nextSibling() == 0);
|
||||
assert (it4.previousSibling() == 0);
|
||||
assert (it4.parentNode() == pElem1);
|
||||
assert (it4.lastChild() == pText1);
|
||||
assert (it4.parentNode() == pElem1);
|
||||
assert (it4.nextSibling() == 0);
|
||||
assert (it4.previousSibling() == 0);
|
||||
assert (it4.parentNode() == pRoot);
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::testShowNothing()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
||||
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
||||
|
||||
pElem1->appendChild(pText1);
|
||||
pElem2->appendChild(pText2);
|
||||
pRoot->appendChild(pElem1);
|
||||
pRoot->appendChild(pElem2);
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
TreeWalker it(pRoot, 0);
|
||||
|
||||
assert (it.nextNode() == 0);
|
||||
|
||||
assert (it.previousNode() == 0);
|
||||
|
||||
assert (it.currentNode() == pRoot);
|
||||
assert (it.firstChild() == 0);
|
||||
assert (it.lastChild() == 0);
|
||||
assert (it.nextSibling() == 0);
|
||||
assert (it.previousSibling() == 0);
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TreeWalkerTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* TreeWalkerTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TreeWalkerTest");
|
||||
|
||||
CppUnit_addTest(pSuite, TreeWalkerTest, testShowAll);
|
||||
CppUnit_addTest(pSuite, TreeWalkerTest, testShowElements);
|
||||
CppUnit_addTest(pSuite, TreeWalkerTest, testFilter);
|
||||
CppUnit_addTest(pSuite, TreeWalkerTest, testShowNothing);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,63 +1,63 @@
|
||||
//
|
||||
// TreeWalkerTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/TreeWalkerTest.h#1 $
|
||||
//
|
||||
// Definition of the TreeWalkerTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef TreeWalkerTest_INCLUDED
|
||||
#define TreeWalkerTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class TreeWalkerTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
TreeWalkerTest(const std::string& name);
|
||||
~TreeWalkerTest();
|
||||
|
||||
void testShowAll();
|
||||
void testShowElements();
|
||||
void testFilter();
|
||||
void testShowNothing();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // TreeWalkerTest_INCLUDED
|
||||
//
|
||||
// TreeWalkerTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/TreeWalkerTest.h#1 $
|
||||
//
|
||||
// Definition of the TreeWalkerTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef TreeWalkerTest_INCLUDED
|
||||
#define TreeWalkerTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class TreeWalkerTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
TreeWalkerTest(const std::string& name);
|
||||
~TreeWalkerTest();
|
||||
|
||||
void testShowAll();
|
||||
void testShowElements();
|
||||
void testFilter();
|
||||
void testShowNothing();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // TreeWalkerTest_INCLUDED
|
||||
|
@@ -1,50 +1,50 @@
|
||||
//
|
||||
// WinDriver.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/WinDriver.cpp#1 $
|
||||
//
|
||||
// Windows test driver for Poco XML.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "WinTestRunner/WinTestRunner.h"
|
||||
#include "XMLTestSuite.h"
|
||||
|
||||
|
||||
class TestDriver: public CppUnit::WinTestRunnerApp
|
||||
{
|
||||
void TestMain()
|
||||
{
|
||||
CppUnit::WinTestRunner runner;
|
||||
runner.addTest(XMLTestSuite::suite());
|
||||
runner.run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TestDriver theDriver;
|
||||
//
|
||||
// WinDriver.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/WinDriver.cpp#1 $
|
||||
//
|
||||
// Windows test driver for Poco XML.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "WinTestRunner/WinTestRunner.h"
|
||||
#include "XMLTestSuite.h"
|
||||
|
||||
|
||||
class TestDriver: public CppUnit::WinTestRunnerApp
|
||||
{
|
||||
void TestMain()
|
||||
{
|
||||
CppUnit::WinTestRunner runner;
|
||||
runner.addTest(XMLTestSuite::suite());
|
||||
runner.run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TestDriver theDriver;
|
||||
|
@@ -1,52 +1,52 @@
|
||||
//
|
||||
// XMLTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/XMLTestSuite.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "XMLTestSuite.h"
|
||||
#include "NameTest.h"
|
||||
#include "NamePoolTest.h"
|
||||
#include "XMLWriterTest.h"
|
||||
#include "SAXTestSuite.h"
|
||||
#include "DOMTestSuite.h"
|
||||
|
||||
|
||||
CppUnit::Test* XMLTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("XMLTestSuite");
|
||||
|
||||
pSuite->addTest(NameTest::suite());
|
||||
pSuite->addTest(NamePoolTest::suite());
|
||||
pSuite->addTest(XMLWriterTest::suite());
|
||||
pSuite->addTest(SAXTestSuite::suite());
|
||||
pSuite->addTest(DOMTestSuite::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// XMLTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/XMLTestSuite.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "XMLTestSuite.h"
|
||||
#include "NameTest.h"
|
||||
#include "NamePoolTest.h"
|
||||
#include "XMLWriterTest.h"
|
||||
#include "SAXTestSuite.h"
|
||||
#include "DOMTestSuite.h"
|
||||
|
||||
|
||||
CppUnit::Test* XMLTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("XMLTestSuite");
|
||||
|
||||
pSuite->addTest(NameTest::suite());
|
||||
pSuite->addTest(NamePoolTest::suite());
|
||||
pSuite->addTest(XMLWriterTest::suite());
|
||||
pSuite->addTest(SAXTestSuite::suite());
|
||||
pSuite->addTest(DOMTestSuite::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,49 +1,49 @@
|
||||
//
|
||||
// XMLTestSuite.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/XMLTestSuite.h#1 $
|
||||
//
|
||||
// Definition of the XMLTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XMLTestSuite_INCLUDED
|
||||
#define XMLTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class XMLTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // XMLTestSuite_INCLUDED
|
||||
//
|
||||
// XMLTestSuite.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/XMLTestSuite.h#1 $
|
||||
//
|
||||
// Definition of the XMLTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XMLTestSuite_INCLUDED
|
||||
#define XMLTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class XMLTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // XMLTestSuite_INCLUDED
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,93 +1,93 @@
|
||||
//
|
||||
// XMLWriterTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.h#1 $
|
||||
//
|
||||
// Definition of the XMLWriterTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XMLWriterTest_INCLUDED
|
||||
#define XMLWriterTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class XMLWriterTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
XMLWriterTest(const std::string& name);
|
||||
~XMLWriterTest();
|
||||
|
||||
void testTrivial();
|
||||
void testTrivialCanonical();
|
||||
void testTrivialDecl();
|
||||
void testTrivialDeclPretty();
|
||||
void testTrivialFragment();
|
||||
void testTrivialFragmentPretty();
|
||||
void testDTDPretty();
|
||||
void testDTD();
|
||||
void testDTDNotation();
|
||||
void testDTDEntity();
|
||||
void testAttributes();
|
||||
void testAttributesPretty();
|
||||
void testData();
|
||||
void testEmptyData();
|
||||
void testDataPretty();
|
||||
void testEmptyDataPretty();
|
||||
void testComment();
|
||||
void testPI();
|
||||
void testCharacters();
|
||||
void testEmptyCharacters();
|
||||
void testCDATA();
|
||||
void testRawCharacters();
|
||||
void testAttributeCharacters();
|
||||
void testDefaultNamespace();
|
||||
void testQNamespaces();
|
||||
void testQNamespacesNested();
|
||||
void testNamespaces();
|
||||
void testNamespacesNested();
|
||||
void testExplicitNamespaces();
|
||||
void testWellformed();
|
||||
void testWellformedNested();
|
||||
void testWellformedNamespace();
|
||||
void testAttributeNamespaces();
|
||||
void testEmpty();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // XMLWriterTest_INCLUDED
|
||||
//
|
||||
// XMLWriterTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.h#1 $
|
||||
//
|
||||
// Definition of the XMLWriterTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XMLWriterTest_INCLUDED
|
||||
#define XMLWriterTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class XMLWriterTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
XMLWriterTest(const std::string& name);
|
||||
~XMLWriterTest();
|
||||
|
||||
void testTrivial();
|
||||
void testTrivialCanonical();
|
||||
void testTrivialDecl();
|
||||
void testTrivialDeclPretty();
|
||||
void testTrivialFragment();
|
||||
void testTrivialFragmentPretty();
|
||||
void testDTDPretty();
|
||||
void testDTD();
|
||||
void testDTDNotation();
|
||||
void testDTDEntity();
|
||||
void testAttributes();
|
||||
void testAttributesPretty();
|
||||
void testData();
|
||||
void testEmptyData();
|
||||
void testDataPretty();
|
||||
void testEmptyDataPretty();
|
||||
void testComment();
|
||||
void testPI();
|
||||
void testCharacters();
|
||||
void testEmptyCharacters();
|
||||
void testCDATA();
|
||||
void testRawCharacters();
|
||||
void testAttributeCharacters();
|
||||
void testDefaultNamespace();
|
||||
void testQNamespaces();
|
||||
void testQNamespacesNested();
|
||||
void testNamespaces();
|
||||
void testNamespacesNested();
|
||||
void testExplicitNamespaces();
|
||||
void testWellformed();
|
||||
void testWellformedNested();
|
||||
void testWellformedNamespace();
|
||||
void testAttributeNamespaces();
|
||||
void testEmpty();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // XMLWriterTest_INCLUDED
|
||||
|
Reference in New Issue
Block a user