mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-14 23:07:56 +02:00
committed latest 1.3 snapshot
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DOMTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/testsuite/src/DOMTestSuite.cpp#8 $
|
||||
// $Id: //poco/Main/XML/testsuite/src/DOMTestSuite.cpp#9 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "NodeIteratorTest.h"
|
||||
#include "TreeWalkerTest.h"
|
||||
#include "ParserWriterTest.h"
|
||||
#include "NodeAppenderTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* DOMTestSuite::suite()
|
||||
@@ -57,6 +58,7 @@ CppUnit::Test* DOMTestSuite::suite()
|
||||
pSuite->addTest(NodeIteratorTest::suite());
|
||||
pSuite->addTest(TreeWalkerTest::suite());
|
||||
pSuite->addTest(ParserWriterTest::suite());
|
||||
pSuite->addTest(NodeAppenderTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
162
XML/testsuite/src/NodeAppenderTest.cpp
Normal file
162
XML/testsuite/src/NodeAppenderTest.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// NodeAppenderTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/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;
|
||||
}
|
61
XML/testsuite/src/NodeAppenderTest.h
Normal file
61
XML/testsuite/src/NodeAppenderTest.h
Normal file
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// NodeAppenderTest.h
|
||||
//
|
||||
// $Id: //poco/Main/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,7 +1,7 @@
|
||||
//
|
||||
// ParserWriterTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/testsuite/src/ParserWriterTest.cpp#11 $
|
||||
// $Id: //poco/Main/XML/testsuite/src/ParserWriterTest.cpp#12 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "Poco/SAX/InputSource.h"
|
||||
#include "Poco/XML/XMLWriter.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using Poco::XML::DOMParser;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SAXParserTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/testsuite/src/SAXParserTest.cpp#9 $
|
||||
// $Id: //poco/Main/XML/testsuite/src/SAXParserTest.cpp#10 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@@ -40,8 +40,8 @@
|
||||
#include "Poco/SAX/WhitespaceFilter.h"
|
||||
#include "Poco/XML/XMLWriter.h"
|
||||
#include "Poco/Latin9Encoding.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using Poco::XML::SAXParser;
|
||||
@@ -277,7 +277,7 @@ void SAXParserTest::testRSS()
|
||||
parser.setFeature(XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES, true);
|
||||
|
||||
std::istringstream istr(RSS);
|
||||
std::ofstream ostr("rss.xml", std::ios::binary);
|
||||
Poco::FileOutputStream ostr("rss.xml");
|
||||
XMLWriter writer(ostr, XMLWriter::CANONICAL | XMLWriter::PRETTY_PRINT);
|
||||
filter.setContentHandler(&writer);
|
||||
filter.setDTDHandler(&writer);
|
||||
|
Reference in New Issue
Block a user