You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2002/05/21 20:46:31 UTC
cvs commit: xml-xerces/c/tests/DOM/DOMTest DTest.cpp
tng 02/05/21 11:46:31
Modified: c/tests/DOM/DOMTest DTest.cpp
Log:
Test case update: this is original tests/IDom/IDTest/IDTest.cpp
Revision Changes Path
1.18 +971 -991 xml-xerces/c/tests/DOM/DOMTest/DTest.cpp
Index: DTest.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/tests/DOM/DOMTest/DTest.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DTest.cpp 1 Apr 2002 21:03:44 -0000 1.17
+++ DTest.cpp 21 May 2002 18:46:31 -0000 1.18
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation-> All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
- * distribution.
+ * distribution->
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
@@ -25,12 +25,12 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission-> For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
+ * permission of the Apache Software Foundation->
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -48,7 +48,7 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
- * originally based on software copyright (c) 1999, International
+ * originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
@@ -56,84 +56,39 @@
/*
* $Log: DTest.cpp,v $
- * Revision 1.17 2002/04/01 21:03:44 tng
+ * Revision 1.18 2002/05/21 18:46:31 tng
+ * Test case update: this is original tests/IDom/IDTest/IDTest.cpp
+ *
+ * Revision 1.6 2002/04/01 21:04:00 tng
* According to DOM spec, setNodeValue by default is no-op.
*
- * Revision 1.16 2002/02/01 22:43:17 peiyongz
+ * Revision 1.5 2002/03/14 21:59:29 tng
+ * Run methods test[NodeType] in the IDOMTest and other fixes.
+ *
+ * Revision 1.4 2002/02/01 22:44:24 peiyongz
* sane_include
*
- * Revision 1.15 2001/12/07 01:46:40 tng
+ * Revision 1.3 2001/12/07 01:48:27 tng
* [Bug 1959] setNodeValue throws exception when spec specifies NOP.
*
- * Revision 1.14 2001/11/23 20:44:10 tng
- * Solaris Forte C++ core dump when handling this long condition check; so break it into smaller check to bypass this compiler problem.
- *
- * Revision 1.13 2000/08/30 22:21:44 andyh
- * Unix Build script fixes. Clean up some UNIX compiler warnings.
- *
- * Revision 1.12 2000/05/15 23:08:59 andyh
- * Remove entity tests, which failed because entity nodes are (correctly)
- * read-only.
- *
- * Revision 1.11 2000/04/19 02:25:18 aruna1
- * Full support for DOM_EntityReference, DOM_Entity and DOM_DocumentType introduced
- *
- * Revision 1.10 2000/03/11 03:00:24 chchou
- * Fix bug # 18, remove set method of readonly attributes.
- * As a result, remove related test cases
- *
- * Revision 1.9 2000/03/02 19:55:45 roddey
- * This checkin includes many changes done while waiting for the
- * 1.1.0 code to be finished. I can't list them all here, but a list is
- * available elsewhere.
- *
- * Revision 1.8 2000/02/29 02:19:13 rahulj
- * No more compilation errors under HPUX 11.0. We do not build
- * DOMMemTest as it crashes the aCC compiler.
- *
- * Revision 1.7 2000/02/06 07:48:36 rahulj
- * Year 2K copyright swat.
- *
- * Revision 1.6 2000/02/04 05:46:31 andyh
- * Change offsets and lengths form signed to unsigned
- *
- * Revision 1.5 2000/02/04 01:50:13 aruna1
- * TreeWalker and NodeIterator changes
- *
- * Revision 1.4 2000/01/29 00:39:09 andyh
- * Redo synchronization in DOMStringHandle allocator. There
- * was a bug in the use of Compare and Swap. Switched to mutexes.
- *
- * Changed a few plain deletes to delete [].
- *
- * Revision 1.3 2000/01/19 21:40:58 andyh
- * Remove a few remaining dependencies on the (now defunct)
- * XML StdOut stream.
- *
- * Revision 1.2 1999/12/03 00:02:25 andyh
- * DOM tests updated to catch DOMException by ref.
- * Added tests of DOMString::transcode() and append()
- *
- * Revision 1.1.1.1 1999/11/09 01:02:34 twl
- * Initial checkin
+ * Revision 1.2 2001/11/23 16:16:52 tng
+ * Elimiate compiler warning Warning: String literal converted to char* in initialization.
*
- * Revision 1.2 1999/11/08 20:42:24 rahul
- * Swat for adding in Product name and CVS comment log variable.
+ * Revision 1.1 2001/08/09 19:28:47 tng
+ * Port test case DOMTest to IDOMTest
*
*/
/**
- * This class tests methods for XML DOM implementation
- * version 2.0 10/12/98
- *
- * DOM_DOMException errors are tested by calls to DOMExceptionsTest from: Main, docBuilder...
+ * This class tests methods for XML IDOM implementation
+ * IDOM_DOMException errors are tested by calls to DOMExceptionsTest from: Main, docBuilder...
*
*/
#include <stdio.h>
-#include "DTest.h"
+#include "IDTest.h"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/XMLString.hpp>
@@ -144,286 +99,394 @@
try \
{ \
operation; \
- fprintf(stderr, "Exceptions Test # %d: no Exception thrown.\n", testNum); \
+ fprintf(stderr, "Exceptions Test # %d: no Exception thrown->\n", testNum); \
} \
- catch (DOM_DOMException &e) \
+ catch (IDOM_DOMException &e) \
{ \
if (e.code != expectedException) { \
- fprintf(stderr, "Exceptions Test # %d: wrong DOM_DOMException thrown.\n", \
+ fprintf(stderr, "Exceptions Test # %d: wrong IDOM_DOMException thrown->\n", \
testNum); \
resultFlag = false; \
} \
} \
catch (...) \
{ \
- fprintf(stderr, "Exceptions Test # %d: unknown exception thrown.\n", \
+ fprintf(stderr, "Exceptions Test # %d: unknown exception thrown->\n", \
testNum); \
resultFlag = false; \
} \
}
+//temp XMLCh String Buffer
+XMLCh tempStr[4000];
+XMLCh tempStr2[4000];
+XMLCh tempStr3[4000];
-#define LEAKTEST(operation) \
-{ \
- operation; /* Precondition */ \
- DomMemDebug entryMemState; \
- { \
- operation; \
- } \
- DomMemDebug exitMemState; \
- if (entryMemState != exitMemState) \
- { \
- printf("Memory Leak at line %d\n", __LINE__); \
- exitMemState.printDifference(entryMemState); \
- } \
-}
-
-
-
-
-DOM_Element DTest::testElementNode;
-DOM_Attr DTest::testAttributeNode;
-DOM_Text DTest::testTextNode;
-DOM_CDATASection DTest::testCDATASectionNode;
-DOM_EntityReference DTest::testEntityReferenceNode;
-DOM_Entity DTest::testEntityNode;
-DOM_ProcessingInstruction DTest::testProcessingInstructionNode;
-DOM_Comment DTest::testCommentNode;
-DOM_Document DTest::testDocumentNode;
-DOM_DocumentType DTest::testDocumentTypeNode;
-DOM_DocumentFragment DTest::testDocumentFragmentNode;
-DOM_Notation DTest::testNotationNode;
+IDOM_Element* IDTest::testElementNode;
+IDOM_Attr* IDTest::testAttributeNode;
+IDOM_Text* IDTest::testTextNode;
+IDOM_CDATASection* IDTest::testCDATASectionNode;
+IDOM_EntityReference* IDTest::testEntityReferenceNode;
+IDOM_Entity* IDTest::testEntityNode;
+IDOM_ProcessingInstruction* IDTest::testProcessingInstructionNode;
+IDOM_Comment* IDTest::testCommentNode;
+IDOM_Document* IDTest::testDocumentNode;
+IDOM_DocumentType* IDTest::testDocumentTypeNode;
+IDOM_DocumentFragment* IDTest::testDocumentFragmentNode;
+IDOM_Notation* IDTest::testNotationNode;
/**
*
- * version 2.0 10/12/98
*
*/
-DTest::DTest()
+IDTest::IDTest()
{
};
/**
- * version 3.0 01/25/99
*
- * @return DOM_Document
+ * @return IDOM_Document
*
*/
-DOM_Document DTest::createDocument() {
- return DOM_Document::createDocument();
+IDOM_Document* IDTest::createDocument() {
+ IDOM_DOMImplementation* impl = IDOM_DOMImplementation::getImplementation();
+ return impl->createDocument();
};
/**
- * version 3.0 01/25/99
*
- * @return DOM_DocumentType
- * @param name DOMString
+ * @return IDOM_DocumentType
+ * @param name XMLCh*
*
*/
-DOM_DocumentType DTest::createDocumentType(DOM_Document doc, DOMString name) {
- return doc.createDocumentType(name); //Replace with a DOM_DocumentType creator
+IDOM_DocumentType* IDTest::createDocumentType(IDOM_Document* doc, XMLCh* name) {
+ return doc->createDocumentType(name); //Replace with a IDOM_DocumentType* creator
};
/**
- * version 3.0 01/25/99
*
- * @return org.w3c.dom.DOM_Entity
- * @param doc org.w3c.dom.DOM_Document
- * @param name DOMString
+ * @return org.w3c.dom.IDOM_Entity
+ * @param doc org.w3c.dom.IDOM_Document
+ * @param name XMLCh*
*
*/
-DOM_Entity DTest::createEntity(DOM_Document doc, DOMString name) {
- return doc.createEntity(name);
+IDOM_Entity* IDTest::createEntity(IDOM_Document* doc, XMLCh* name) {
+ return doc->createEntity(name);
};
/**
- * version 3.0 01/25/99
*
- * @return org.w3c.dom.DOM_Notation
- * @param doc org.w3c.dom.DOM_Document
- * @param name DOMString
+ * @return org.w3c.dom.IDOM_Notation
+ * @param doc org.w3c.dom.IDOM_Document
+ * @param name XMLCh*
*
*/
-DOM_Notation DTest::createNotation(DOM_Document doc, DOMString name) {
- return doc.createNotation(name);
+IDOM_Notation* IDTest::createNotation(IDOM_Document* doc, XMLCh* name) {
+ return doc->createNotation(name);
};
/**
- * This method builds test documents for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method builds test documents for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
* @param name document's name
* @param type document's type
*
*/
-void DTest::docBuilder(DOM_Document document, DOMString name)
+bool IDTest::docBuilder(IDOM_Document* document, XMLCh* nameIn)
{
- DOM_Document doc = document;
+ XMLCh* name = XMLString::replicate(nameIn);
+
+ IDOM_Document* doc = document;
bool OK = true;
- DOM_Element docFirstElement = doc.createElement(name + "FirstElement");
- doc.appendChild(docFirstElement);
- docFirstElement.setAttribute(name + "FirstElement", name + "firstElement");
-
- DOM_ProcessingInstruction docProcessingInstruction = doc.createProcessingInstruction(name +
- "TargetProcessorChannel", DOMString("This is ") + doc.getNodeName() + "'s processing instruction");
- docFirstElement.appendChild(docProcessingInstruction);
-
- DOM_Element docBody = doc.createElement(name + "TestBody");
- docFirstElement.appendChild(docBody);
-
- DOM_Element docBodyLevel21 = doc.createElement(name + "BodyLevel21");
- DOM_Element docBodyLevel22 = doc.createElement(name + "BodyLevel22");
- DOM_Element docBodyLevel23 = doc.createElement(name + "BodyLevel23");
- DOM_Element docBodyLevel24 = doc.createElement(name + "BodyLevel24");
- docBody.appendChild(docBodyLevel21);
- docBody.appendChild(docBodyLevel22);
- docBody.appendChild(docBodyLevel23);
- docBody.appendChild(docBodyLevel24);
-
- DOM_Element docBodyLevel31 = doc.createElement(name + "BodyLevel31");
- DOM_Element docBodyLevel32 = doc.createElement(name + "BodyLevel32");
- DOM_Element docBodyLevel33 = doc.createElement(name + "BodyLevel33");
- DOM_Element docBodyLevel34 = doc.createElement(name + "BodyLevel34");
- docBodyLevel21.appendChild(docBodyLevel31);
- docBodyLevel21.appendChild(docBodyLevel32);
- docBodyLevel22.appendChild(docBodyLevel33);
- docBodyLevel22.appendChild(docBodyLevel34);
-
- DOM_Text docTextNode11 = doc.createTextNode(name + "BodyLevel31'sChildTextNode11");
- DOM_Text docTextNode12 = doc.createTextNode(name + "BodyLevel31'sChildTextNode12");
- DOM_Text docTextNode13 = doc.createTextNode(name + "BodyLevel31'sChildTextNode13");
- DOM_Text docTextNode2 = doc.createTextNode(name + "TextNode2");
- DOM_Text docTextNode3 = doc.createTextNode(name + "TextNode3");
- DOM_Text docTextNode4 = doc.createTextNode(name + "TextNode4");
- docBodyLevel31.appendChild(docTextNode11);
- docBodyLevel31.appendChild(docTextNode12);
- docBodyLevel31.appendChild(docTextNode13);
- docBodyLevel32.appendChild(docTextNode2);
- docBodyLevel33.appendChild(docTextNode3);
- docBodyLevel34.appendChild(docTextNode4);
-
- DOM_CDATASection docCDATASection = doc.createCDATASection("<![CDATA[<greeting>Hello, world!</greeting>]]>");
- docBodyLevel23.appendChild(docCDATASection);
-
- DOM_Comment docComment = doc.createComment("This should be a comment of some kind ");
- docBodyLevel23.appendChild(docComment);
-
- DOM_EntityReference docReferenceEntity = doc.createEntityReference("ourEntityNode");
- docBodyLevel24.appendChild(docReferenceEntity);
-
- DTest make;
- DOM_Notation docNotation = make.createNotation(doc, "ourNotationNode");
- DOM_Node abc1 = doc.getFirstChild();
- DOM_DocumentType docType = (DOM_DocumentType &) abc1;
- docType.getNotations().setNamedItem(docNotation);
+ //name + "FirstElement"
+ XMLString::transcode("FirstElement", tempStr2, 3999);
+ XMLString::copyString(tempStr, name);
+ XMLString::catString(tempStr, tempStr2);
+
+ IDOM_Element* docFirstElement = doc->createElement(tempStr);
+ doc->appendChild(docFirstElement);
+
+ //name + "FirstElement", name + "firstElement"
+ XMLString::catString(tempStr, name);
+ XMLString::transcode("FirstElement", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ XMLString::catString(tempStr2, name);
+ XMLString::transcode("firstElement", tempStr3, 3999);
+ XMLString::catString(tempStr2, tempStr3);
+ docFirstElement->setAttribute(tempStr, tempStr2);
+
+ //name + "TargetProcessorChannel" + "This is " + doc->getNodeName() + "'s processing instruction");
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("TargetProcessorChannel", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ XMLString::transcode("This is ", tempStr2, 3999);
+ XMLString::catString(tempStr2, doc->getNodeName());
+ XMLString::transcode("'s processing instruction", tempStr3, 3999);
+ XMLString::catString(tempStr2, tempStr3);
+
+ IDOM_ProcessingInstruction* docProcessingInstruction = doc->createProcessingInstruction(tempStr, tempStr2);
+ docFirstElement->appendChild(docProcessingInstruction);
+
+ //name + "TestBody"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("TestBody", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBody = doc->createElement(tempStr);
+ docFirstElement->appendChild(docBody);
+
+ //name + "BodyLevel21"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel21", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBodyLevel21 = doc->createElement(tempStr);
+
+ //name + "BodyLevel22"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel22", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBodyLevel22 = doc->createElement(tempStr);
+
+ //name + "BodyLevel23"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel23", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBodyLevel23 = doc->createElement(tempStr);
+
+ //name + "BodyLevel24"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel24", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBodyLevel24 = doc->createElement(tempStr);
+
+ docBody->appendChild(docBodyLevel21);
+ docBody->appendChild(docBodyLevel22);
+ docBody->appendChild(docBodyLevel23);
+ docBody->appendChild(docBodyLevel24);
+
+ //name + "BodyLevel31"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel31", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBodyLevel31 = doc->createElement(tempStr);
+
+ //name + "BodyLevel32"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel32", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBodyLevel32 = doc->createElement(tempStr);
+
+ //name + "BodyLevel33"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel33", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBodyLevel33 = doc->createElement(tempStr);
+
+ //name + "BodyLevel34"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel34", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Element* docBodyLevel34 = doc->createElement(tempStr);
+
+ docBodyLevel21->appendChild(docBodyLevel31);
+ docBodyLevel21->appendChild(docBodyLevel32);
+ docBodyLevel22->appendChild(docBodyLevel33);
+ docBodyLevel22->appendChild(docBodyLevel34);
+
+ //name + "BodyLevel31'sChildTextNode11"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel31'sChildTextNode11", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Text* docTextNode11 = doc->createTextNode(tempStr);
+
+ //name + "BodyLevel31'sChildTextNode12"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel31'sChildTextNode12", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Text* docTextNode12 = doc->createTextNode(tempStr);
+
+ //name + "BodyLevel31'sChildTextNode13"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("BodyLevel31'sChildTextNode13", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Text* docTextNode13 = doc->createTextNode(tempStr);
+
+ //name + "TextNode2"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("TextNode2", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Text* docTextNode2 = doc->createTextNode(tempStr);
+
+ //name + "TextNode3"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("TextNode3", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Text* docTextNode3 = doc->createTextNode(tempStr);
+
+ //name + "TextNode4"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("TextNode4", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Text* docTextNode4 = doc->createTextNode(tempStr);
+
+ docBodyLevel31->appendChild(docTextNode11);
+ docBodyLevel31->appendChild(docTextNode12);
+ docBodyLevel31->appendChild(docTextNode13);
+ docBodyLevel32->appendChild(docTextNode2);
+ docBodyLevel33->appendChild(docTextNode3);
+ docBodyLevel34->appendChild(docTextNode4);
+
+ //"<![CDATA[<greeting>Hello, world!</greeting>]]>"
+ XMLString::transcode("<![CDATA[<greeting>Hello, world!</greeting>]]>", tempStr, 3999);
+ IDOM_CDATASection* docCDATASection = doc->createCDATASection(tempStr);
+ docBodyLevel23->appendChild(docCDATASection);
+
+ //"This should be a comment of some kind "
+ XMLString::transcode("This should be a comment of some kind ", tempStr, 3999);
+ IDOM_Comment* docComment = doc->createComment(tempStr);
+ docBodyLevel23->appendChild(docComment);
+
+ //"ourEntityNode"
+ XMLString::transcode("ourEntityNode", tempStr, 3999);
+ IDOM_EntityReference* docReferenceEntity = doc->createEntityReference(tempStr);
+ docBodyLevel24->appendChild(docReferenceEntity);
+
+ IDTest make;
+
+ //"ourNotationNode"
+ XMLString::transcode("ourNotationNode", tempStr, 3999);
+ IDOM_Notation* docNotation = make.createNotation(doc, tempStr);
+ IDOM_Node* abc1 = doc->getFirstChild();
+ IDOM_DocumentType* docType = (IDOM_DocumentType*) abc1;
+ docType->getNotations()->setNamedItem(docNotation);
- DOM_DocumentFragment docDocFragment = doc.createDocumentFragment();
+ IDOM_DocumentFragment* docDocFragment = doc->createDocumentFragment();
-// printf("This document's first element name is " + docFirstElement.getTagName() + "\n");
+// printf("This document's first element name is " + docFirstElement->getTagName() + "\n");
//***********Following are for errorTests
- DOM_Text docNode3 = doc.createTextNode(name + "docTextNode3");
- DOM_Text docNode4 = doc.createTextNode(name + "docTextNode4");
- DOM_Node abc2 = doc.getDoctype().getEntities().getNamedItem("ourEntityNode"); // Get the DOM_Entity node
- DOM_Entity docEntity = (DOM_Entity &) abc2;
- DOM_Node abc3 = doc.getFirstChild(); // Get the DOM_DocumentType node
- DOM_DocumentType docDocType = (DOM_DocumentType &) abc3;
- DOM_Node abc4 = doc.getLastChild().getLastChild().getLastChild().getFirstChild();
- DOM_EntityReference & entityReferenceText = (DOM_EntityReference &) abc4;
- DOM_Text entityReferenceText2 = doc.createTextNode("entityReferenceText information");
+ //name + "docTextNode3"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("docTextNode3", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Text* docNode3 = doc->createTextNode(tempStr);
+
+ //name + "docTextNode4"
+ XMLString::copyString(tempStr, name);
+ XMLString::transcode("docTextNode4", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ IDOM_Text* docNode4 = doc->createTextNode(tempStr);
+
+ //"ourEntityNode"
+ XMLString::transcode("ourEntityNode", tempStr, 3999);
+ IDOM_Node* abc2 = doc->getDoctype()->getEntities()->getNamedItem(tempStr); // Get the IDOM_Entity* node
+ IDOM_Entity* docEntity = (IDOM_Entity*) abc2;
+ IDOM_Node* abc3 = doc->getFirstChild(); // Get the IDOM_DocumentType* node
+ IDOM_DocumentType* docDocType = (IDOM_DocumentType*) abc3;
+ IDOM_Node* abc4 = doc->getLastChild()->getLastChild()->getLastChild()->getFirstChild();
+ IDOM_EntityReference* entityReferenceText = (IDOM_EntityReference*) abc4;
+
+ //"entityReferenceText information"
+ XMLString::transcode("entityReferenceText information", tempStr, 3999);
+ IDOM_Text* entityReferenceText2 = doc->createTextNode(tempStr);
//************************************************* ERROR TESTS
- DTest tests;
+ IDTest tests;
- EXCEPTIONSTEST(document.appendChild(docBody), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 1);
+ EXCEPTIONSTEST(document->appendChild(docBody), IDOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 1);
- EXCEPTIONSTEST(document.appendChild(docBody), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 2);
- EXCEPTIONSTEST(docNode3.appendChild(docNode4), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 3);
- // EXCEPTIONSTEST(doc.insertBefore(docEntity, docFirstElement), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 4);
- EXCEPTIONSTEST(doc.replaceChild(docCDATASection, docFirstElement), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 5);
+ EXCEPTIONSTEST(document->appendChild(docBody), IDOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 2);
+ EXCEPTIONSTEST(docNode3->appendChild(docNode4), IDOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 3);
+ // EXCEPTIONSTEST(doc->insertBefore(docEntity, docFirstElement), IDOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 4);
+ EXCEPTIONSTEST(doc->replaceChild(docCDATASection, docFirstElement), IDOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 5);
+
+ //"This shouldn't work!"
+ XMLString::transcode("entityReferenceText information", tempStr, 3999);
// The following setNodeValue tests are not invalid
// According to DOM spec, if the node value is defined to be null in the DOM spec, setting it has no effect.
// Only those node type that are supposed to have node value, exception will be raised if the node is readonly.
- // EXCEPTIONSTEST(docFirstElement.setNodeValue("This shouldn't work!" ), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 6);
- // EXCEPTIONSTEST(docReferenceEntity.setNodeValue("This shouldn't work!" ), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 7);
- // EXCEPTIONSTEST(docEntity.setNodeValue("This shouldn't work!" ), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 8);
- // EXCEPTIONSTEST(doc.setNodeValue("This shouldn't work!" ), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 9);
- // EXCEPTIONSTEST(docDocType.setNodeValue("This shouldn't work!" ), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 10);
- // EXCEPTIONSTEST(docDocFragment.setNodeValue("This shouldn't work!" ), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 11);
- // EXCEPTIONSTEST(docNotation.setNodeValue("This shouldn't work!" ), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 12);
-
- EXCEPTIONSTEST(docReferenceEntity.appendChild(entityReferenceText2 ), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR , OK, 13);
- EXCEPTIONSTEST(docBodyLevel32.insertBefore(docTextNode11,docBody ), DOM_DOMException::NOT_FOUND_ERR, OK, 14);
- EXCEPTIONSTEST(docBodyLevel32.removeChild(docFirstElement), DOM_DOMException::NOT_FOUND_ERR, OK, 15);
- EXCEPTIONSTEST(docBodyLevel32.replaceChild(docTextNode11,docFirstElement ), DOM_DOMException::NOT_FOUND_ERR, OK, 16);
+ // EXCEPTIONSTEST(docFirstElement->setNodeValue(tempStr), IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 6);
+ // EXCEPTIONSTEST(docReferenceEntity->setNodeValue(tempStr), IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 7);
+ // EXCEPTIONSTEST(docEntity->setNodeValue(tempStr), IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 8);
+ // EXCEPTIONSTEST(doc->setNodeValue(tempStr), IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 9);
+ // EXCEPTIONSTEST(docDocType->setNodeValue(tempStr), IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 10);
+ // EXCEPTIONSTEST(docDocFragment->setNodeValue(tempStr), IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 11);
+ // EXCEPTIONSTEST(docNotation->setNodeValue(tempStr), IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 12);
+ EXCEPTIONSTEST(docReferenceEntity->appendChild(entityReferenceText2 ), IDOM_DOMException::NO_MODIFICATION_ALLOWED_ERR , OK, 13);
+ EXCEPTIONSTEST(docBodyLevel32->insertBefore(docTextNode11,docBody ), IDOM_DOMException::NOT_FOUND_ERR, OK, 14);
+ EXCEPTIONSTEST(docBodyLevel32->removeChild(docFirstElement), IDOM_DOMException::NOT_FOUND_ERR, OK, 15);
+ EXCEPTIONSTEST(docBodyLevel32->replaceChild(docTextNode11,docFirstElement ), IDOM_DOMException::NOT_FOUND_ERR, OK, 16);
+
+ delete [] name;
+
+ return OK;
//!! Throws a NOT_FOUND_ERR ********
- // docBodyLevel32.getAttributes().removeNamedItem(testAttribute.getName()); 16 // To test removeNamedItem
+ // docBodyLevel32->getAttributes()->removeNamedItem(testAttribute->getName()); 16 // To test removeNamedItem
}; //END OF DOCBUILDER
/**
- * @param document org.w3c.dom.DOM_Document
+ * @param document org.w3c.dom.IDOM_Document
*/
- void DTest::findTestNodes(DOM_Document document) {
- DOM_Node node = document;
+void IDTest::findTestNodes(IDOM_Document* document) {
+ IDOM_Node* node = document;
int nodeCount = 0;
// Walk the tree until you find and assign all node types needed that exist.
- while (node != null && nodeCount < 12)
+ while (node != 0 && nodeCount < 12)
{
- switch (node.getNodeType())
+ switch (node->getNodeType())
{
- case DOM_Node::ELEMENT_NODE :
- if (testElementNode == null) {testElementNode = (DOM_Element &)node; nodeCount++;}
+ case IDOM_Node::ELEMENT_NODE :
+ if (testElementNode == 0) {testElementNode = (IDOM_Element*)node; nodeCount++;}
break;
- case DOM_Node::ATTRIBUTE_NODE :
- if (testAttributeNode == null) {testAttributeNode = (DOM_Attr &)node; nodeCount++;}
+ case IDOM_Node::ATTRIBUTE_NODE :
+ if (testAttributeNode == 0) {testAttributeNode = (IDOM_Attr*)node; nodeCount++;}
break;
- case DOM_Node::TEXT_NODE :
- if (testTextNode == null) {testTextNode = (DOM_Text &)node; nodeCount++;}
+ case IDOM_Node::TEXT_NODE :
+ if (testTextNode == 0) {testTextNode = (IDOM_Text*)node; nodeCount++;}
break;
- case DOM_Node::CDATA_SECTION_NODE :
- if (testCDATASectionNode == null) {testCDATASectionNode = (DOM_CDATASection &)node; nodeCount++;}
+ case IDOM_Node::CDATA_SECTION_NODE :
+ if (testCDATASectionNode == 0) {testCDATASectionNode = (IDOM_CDATASection*)node; nodeCount++;}
break;
- case DOM_Node::ENTITY_REFERENCE_NODE :
- if (testEntityReferenceNode == null) {testEntityReferenceNode = (DOM_EntityReference &)node; nodeCount++;}
+ case IDOM_Node::ENTITY_REFERENCE_NODE :
+ if (testEntityReferenceNode == 0) {testEntityReferenceNode = (IDOM_EntityReference*)node; nodeCount++;}
break;
- case DOM_Node::ENTITY_NODE :
- if (testEntityNode == null) {testEntityNode = (DOM_Entity &)node; nodeCount++;}
+ case IDOM_Node::ENTITY_NODE :
+ if (testEntityNode == 0) {testEntityNode = (IDOM_Entity*)node; nodeCount++;}
break;
- case DOM_Node::PROCESSING_INSTRUCTION_NODE :
- if (testProcessingInstructionNode == null) {testProcessingInstructionNode = (DOM_ProcessingInstruction &)node; nodeCount++;}
+ case IDOM_Node::PROCESSING_INSTRUCTION_NODE :
+ if (testProcessingInstructionNode == 0) {testProcessingInstructionNode = (IDOM_ProcessingInstruction*)node; nodeCount++;}
break;
- case DOM_Node::COMMENT_NODE :
- if (testCommentNode == null) {testCommentNode = (DOM_Comment &)node; nodeCount++;}
+ case IDOM_Node::COMMENT_NODE :
+ if (testCommentNode == 0) {testCommentNode = (IDOM_Comment*)node; nodeCount++;}
break;
- case DOM_Node::DOCUMENT_TYPE_NODE :
- if (testDocumentTypeNode == null) {testDocumentTypeNode = (DOM_DocumentType &)node; nodeCount++;}
+ case IDOM_Node::DOCUMENT_TYPE_NODE :
+ if (testDocumentTypeNode == 0) {testDocumentTypeNode = (IDOM_DocumentType*)node; nodeCount++;}
break;
- case DOM_Node::DOCUMENT_FRAGMENT_NODE :
- if (testDocumentFragmentNode == null) {testDocumentFragmentNode = (DOM_DocumentFragment &)node; nodeCount++;}
+ case IDOM_Node::DOCUMENT_FRAGMENT_NODE :
+ if (testDocumentFragmentNode == 0) {testDocumentFragmentNode = (IDOM_DocumentFragment*)node; nodeCount++;}
break;
- case DOM_Node::NOTATION_NODE :
- if (testNotationNode == null) {testNotationNode = (DOM_Notation &)node; nodeCount++;}
+ case IDOM_Node::NOTATION_NODE :
+ if (testNotationNode == 0) {testNotationNode = (IDOM_Notation*)node; nodeCount++;}
break;
- case DOM_Node::DOCUMENT_NODE :
- if (testDocumentNode == null) {testDocumentNode = (DOM_Document &)node; nodeCount++;}
+ case IDOM_Node::DOCUMENT_NODE :
+ if (testDocumentNode == 0) {testDocumentNode = (IDOM_Document*)node; nodeCount++;}
break;
default:
;
@@ -434,65 +497,65 @@
/**
- * @param document org.w3c.dom.DOM_Document
+ * @param document org.w3c.dom.IDOM_Document
*/
- void DTest::findTestNodes(DOM_Node node) {
- DTest test;
- DOM_Node kid;
+void IDTest::findTestNodes(IDOM_Node* node) {
+ IDTest test;
+ IDOM_Node* kid;
// Walk the tree until you find and assign all node types needed that exist.
- if (node.getFirstChild() != null)
+ if (node->getFirstChild() != 0)
{
- kid = node.getFirstChild();
+ kid = node->getFirstChild();
test.findTestNodes(kid);
}
- if (node.getNextSibling() != null)
+ if (node->getNextSibling() != 0)
{
- kid = node.getNextSibling();
+ kid = node->getNextSibling();
test.findTestNodes(kid);
}
- switch (node.getNodeType())
+ switch (node->getNodeType())
{
- case DOM_Node::ELEMENT_NODE :
- if (testElementNode == null) {testElementNode = (DOM_Element &)node; }
+ case IDOM_Node::ELEMENT_NODE :
+ if (testElementNode == 0) {testElementNode = (IDOM_Element*)node; }
break;
- case DOM_Node::ATTRIBUTE_NODE :
- if (testAttributeNode == null) {testAttributeNode = (DOM_Attr &)node; }
+ case IDOM_Node::ATTRIBUTE_NODE :
+ if (testAttributeNode == 0) {testAttributeNode = (IDOM_Attr*)node; }
break;
- case DOM_Node::TEXT_NODE :
- if (testTextNode == null) {testTextNode = (DOM_Text &)node; }
+ case IDOM_Node::TEXT_NODE :
+ if (testTextNode == 0) {testTextNode = (IDOM_Text*)node; }
break;
- case DOM_Node::CDATA_SECTION_NODE :
- if (testCDATASectionNode == null) {testCDATASectionNode = (DOM_CDATASection &)node; }
+ case IDOM_Node::CDATA_SECTION_NODE :
+ if (testCDATASectionNode == 0) {testCDATASectionNode = (IDOM_CDATASection*)node; }
break;
- case DOM_Node::ENTITY_REFERENCE_NODE :
- if (testEntityReferenceNode == null) {testEntityReferenceNode = (DOM_EntityReference &)node;}
+ case IDOM_Node::ENTITY_REFERENCE_NODE :
+ if (testEntityReferenceNode == 0) {testEntityReferenceNode = (IDOM_EntityReference*)node;}
break;
- case DOM_Node::ENTITY_NODE :
- if (testEntityNode == null) {testEntityNode = (DOM_Entity &)node;}
+ case IDOM_Node::ENTITY_NODE :
+ if (testEntityNode == 0) {testEntityNode = (IDOM_Entity*)node;}
break;
- case DOM_Node::PROCESSING_INSTRUCTION_NODE :
- if (testProcessingInstructionNode == null) {testProcessingInstructionNode = (DOM_ProcessingInstruction &)node;}
+ case IDOM_Node::PROCESSING_INSTRUCTION_NODE :
+ if (testProcessingInstructionNode == 0) {testProcessingInstructionNode = (IDOM_ProcessingInstruction*)node;}
break;
- case DOM_Node::COMMENT_NODE :
- if (testCommentNode == null) {testCommentNode = (DOM_Comment &)node;}
+ case IDOM_Node::COMMENT_NODE :
+ if (testCommentNode == 0) {testCommentNode = (IDOM_Comment*)node;}
break;
- case DOM_Node::DOCUMENT_TYPE_NODE :
- if (testDocumentTypeNode == null) {testDocumentTypeNode = (DOM_DocumentType &)node; }
+ case IDOM_Node::DOCUMENT_TYPE_NODE :
+ if (testDocumentTypeNode == 0) {testDocumentTypeNode = (IDOM_DocumentType*)node; }
break;
- case DOM_Node::DOCUMENT_FRAGMENT_NODE :
- if (testDocumentFragmentNode == null) {testDocumentFragmentNode = (DOM_DocumentFragment &)node;}
+ case IDOM_Node::DOCUMENT_FRAGMENT_NODE :
+ if (testDocumentFragmentNode == 0) {testDocumentFragmentNode = (IDOM_DocumentFragment*)node;}
break;
- case DOM_Node::NOTATION_NODE :
- if (testNotationNode == null) {testNotationNode = (DOM_Notation &)node;}
+ case IDOM_Node::NOTATION_NODE :
+ if (testNotationNode == 0) {testNotationNode = (IDOM_Notation*)node;}
break;
- case DOM_Node::DOCUMENT_NODE :
- if (testDocumentNode == null) {testDocumentNode = (DOM_Document &)node;}
+ case IDOM_Node::DOCUMENT_NODE :
+ if (testDocumentNode == 0) {testDocumentNode = (IDOM_Document*)node;}
break;
default:
;
@@ -501,18 +564,18 @@
/**
*
- * version 2.0 10/12/98
*
*/
- int main(int argc, char **argv)
+int main(int argc, char **argv)
{
+ bool OK = true;
{
// Nest entire test in an inner block.
// Reference counting should recover all document
// storage when this block exits.
- DTest test;
+ IDTest test;
try {
XMLPlatformUtils::Initialize();
}
@@ -524,8 +587,7 @@
}
long avgTime = 0;
- bool OK = true;
- long startTime = 0;//****************Time the whole thing for efficiency of DOM implementation
+ long startTime = 0;//****************Time the whole thing for efficiency of IDOM implementation
// for (int i=0; i< 1000; i++)
// {
@@ -533,270 +595,201 @@
// if(!OK)
// break;
- DOM_Document d = test.createDocument();
- // DOM_Document z = test.createDocument();
+ IDOM_Document* d = test.createDocument();
- DOM_DocumentType docDocType = test.createDocumentType(d,"testDocument1");
- d.appendChild(docDocType);
+ XMLString::transcode("testDocument1", tempStr, 3999);
+ IDOM_DocumentType* docDocType = test.createDocumentType(d,tempStr);
+ d->appendChild(docDocType);
- DOM_Entity docEntity = test.createEntity( d, "ourEntityNode");
+ XMLString::transcode("ourEntityNode", tempStr, 3999);
+ IDOM_Entity* docEntity = test.createEntity( d, tempStr);
//Build a branch for entityReference tests
- // DOM_Text entityChildText = d.createTextNode("entityChildText information"); //
- // docEntity.appendChild(entityChildText);
- // docDocType.getEntities().setNamedItem(docEntity);
-
- test.docBuilder(d, "d");
-
- test.findTestNodes((DOM_Node)d);
- // test.docBuilder(z, "z");
- // try {
- LEAKTEST(test.testAttr(d););
- LEAKTEST(test.testCDATASection(d););
- LEAKTEST(test.testCharacterData(d););
- LEAKTEST(test.testChildNodeList(d););
- LEAKTEST(test.testComment(d););
- LEAKTEST(test.testDeepNodeList(d););
- LEAKTEST(test.testDocument(d););
- LEAKTEST(test.testDocumentFragment(d););
- LEAKTEST(test.testDocumentType(d););
- LEAKTEST(test.testDOMImplementation(d););
- LEAKTEST(test.testElement(d););
-// LEAKTEST(test.testEntity(d);); // Can not test entities; only parser can create them.
- LEAKTEST(test.testEntityReference(d););
- LEAKTEST(test.testNode(d););
- LEAKTEST(test.testNotation(d););
- LEAKTEST(test.testPI(d););
- LEAKTEST(test.testText(d););
- LEAKTEST(test.testDOMerrors(d););
-
- //!! Throws WRONG_DOCUMENT_ERR **********
-
- // z.appendChild(d.createComment("Test doc d comment"));// Tries to append z document with document d comment
- // d.getDocumentElement().appendChild(z.createElement("newZdocElement"));// Tries to append d document with document z DOM_Element
- // d.getLastChild().getLastChild().insertBefore(z.createElement("newZdocElement"),d.getLastChild().getLastChild().getFirstChild());// Tries to insert into d document with document z DOM_Element
- // d.replaceChild(z.createElement("newZdocElement"),d.getLastChild().getLastChild().getFirstChild()); // Tries to replace in d document with document z DOM_Element
-
- /* Attribute newAttribute = d.createAttribute("newAttribute");
- d.getDocumentElement().setAttributeNode(newAttribute);
- d.getDocumentElement().getAttributes().setNamedItem(z.createAttribute("newzAttribute"));
- */
-
- //!! Throws INVALID_CHARACTER_ERR **********
- // ******This just gets us through each method. JKess has a comprehensive test of Invalid Names******
- // d.createAttribute("Invalid Name"); // Name with blank space
- // d.createElement("5InvalidName"); // Name starts with numeric
- // d.createProcessingInstruction("This is the target processor channel","InvalidName>");// Name ends with >
- // d.getDocumentElement().setAttribute("Invalid%Name",""); // Name contains %
-
-
- //!! ******** NO_DATA_ALLOWED_ERR ********No cases to test as of 9/15
-
-
- //!! ******** NO_MODIFICATION_ALLOWED_ERR ******** When read only exists
- /*
-
-
-
- // **** FOR DOM_Element when read only exists********
- .removeAttribute("aString"); // ***** Not until read only exists.
- .removeAttributeNode(Attribute); // ***** Not until read only exists.
- .setAttribute("aString", "anotherString"); // ***** Not until read only exists.
-
-
- // **** FOR DOM_Node when read only exists********
- .appendChild(aNode); // ***** Not until read only exists.
- .insertBefore(aNode, AnotherNode); // ***** Not until read only exists.
- .removeChild(aNode); // ***** Not until read only exists.
- .replaceChild(aNode); // ***** Not until read only exists.
-
- .splitText(2); // ***** Not until read only exists.
-
- .setNamedItem(DOM_Node); // ***** Not until read only exists.
- */
-
-
- //!!******** NOT_SUPPORTED_ERR ********For HTML when implemented
- /*
- .createCDATASection("String stuff");
- .createEntityReference("String stuff");
- .createProcessingInstruction("String stuff", "Some more String stuff");
- */
-
- // } catch (DOM_DOMException &e) {
- // fprintf(stderr, "Unexpected DOM Exception caught. Code is: %d\n", e.code);
- // OK = false;
- // }
- // catch (...) {
- // fprintf(stderr, "Unexpected non-DOM exception caught.");
- // };
-
-
- //System.err.println("Elapsed time (measured in seconds): " + ((System.currentTimeMillis() - startTime) / 1000.0));
- // AH revisit avgTime += System.currentTimeMillis() - startTime;
- // }//END OF FOR
-
-
- // System.err.println("Elapsed time (measured in seconds): " +
- // ((System.currentTimeMillis() - startTime) / 1000.0));
- // System.err.println("Elapsed time (measured in mili-seconds): " +
- // ((System.currentTimeMillis() - startTime)));
-
-
- // System.err.println("Average Elapsed time (measured in seconds): " + (avgTime/10000000.0) );
-
- // Null out the static object references in class DTest,
- // which will recover their storage. Part of testing for memory leaks.
- DTest::testElementNode = null;
- DTest::testAttributeNode = null;
- DTest::testTextNode = null;
- DTest::testCDATASectionNode = null;
- DTest::testEntityReferenceNode = null;
- DTest::testEntityNode = null;
- DTest::testProcessingInstructionNode = null;
- DTest::testCommentNode = null;
- DTest::testDocumentNode = null;
- DTest::testDocumentTypeNode = null;
- DTest::testDocumentFragmentNode = null;
- DTest::testNotationNode = null;
+ // IDOM_Text* entityChildText = d.createTextNode("entityChildText information"); //
+ // docEntity->appendChild(entityChildText);
+ // docDocType->getEntities()->setNamedItem(docEntity);
+
+ XMLString::transcode("d", tempStr3, 3999);
+ OK = test.docBuilder(d, tempStr3);
+
+ test.findTestNodes((IDOM_Node*)d);
+
+ OK = test.testAttr(d);
+ OK = test.testCDATASection(d);
+ OK = test.testCharacterData(d);
+ OK = test.testChildNodeList(d);
+ OK = test.testComment(d);
+ OK = test.testDeepNodeList(d);
+ OK = test.testDocument(d);
+ OK = test.testDocumentFragment(d);
+ OK = test.testDocumentType(d);
+ OK = test.testIDOMImplementation(d);
+ OK = test.testElement(d);
+// OK = test.testEntity(d); // Can not test entities; only parser can create them.
+ OK = test.testEntityReference(d);
+ OK = test.testNode(d);
+ OK = test.testNotation(d);
+ OK = test.testPI(d);
+ OK = test.testText(d);
+ OK = test.testIDOMerrors(d);
+
+ // Null out the static object references in class IDTest,
+ // which will recover their storage.
+ IDTest::testElementNode = 0;
+ IDTest::testAttributeNode = 0;
+ IDTest::testTextNode = 0;
+ IDTest::testCDATASectionNode = 0;
+ IDTest::testEntityReferenceNode = 0;
+ IDTest::testEntityNode = 0;
+ IDTest::testProcessingInstructionNode = 0;
+ IDTest::testCommentNode = 0;
+ IDTest::testDocumentNode = 0;
+ IDTest::testDocumentTypeNode = 0;
+ IDTest::testDocumentFragmentNode = 0;
+ IDTest::testNotationNode = 0;
+
+ delete d;
};
XMLPlatformUtils::Terminate();
- DomMemDebug().print();
+
+ if (OK) printf("Test Run Successfully\n");
return 0;
};
/**
- * This method tests DOM_Attr methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_Attr* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testAttr(DOM_Document document)
+bool IDTest::testAttr(IDOM_Document* document)
{
- DOM_Node node;
- DOM_Attr attributeNode, attribute2;
- DOMString compare;
+ IDOM_Node* node;
+ IDOM_Attr* attributeNode;
bool T = true;
bool F = false;
bool OK = true;
// For debugging***** printf("\n testAttr's outputs:\n\n");
- DOM_Attr testAttribute = document.createAttribute("testAttribute");
- testAttribute.setValue("testAttribute's value");
- node = document.getDocumentElement(); // node gets first element
+ XMLString::transcode("testAttribute", tempStr, 3999);
+ IDOM_Attr* testAttribute = document->createAttribute(tempStr);
+
+ XMLString::transcode("testAttribute's value", tempStr, 3999);
+ testAttribute->setValue(tempStr);
+ node = document->getDocumentElement(); // node gets first element
- // ((DOM_Element &)node).setAttributeNode(testAttribute);
- // attributeNode = ((DOM_Element &)node).getAttributeNode("testAttribute");
- DOM_Element el = (DOM_Element &)node;
- el.setAttributeNode(testAttribute);
- attributeNode = el.getAttributeNode("testAttribute");
+ // ((IDOM_Element*)node)->setAttributeNode(testAttribute);
+ // attributeNode = ((IDOM_Element*)node)->getAttributeNode("testAttribute");
+ IDOM_Element* el = (IDOM_Element*)node;
+ el->setAttributeNode(testAttribute);
- compare = "testAttribute";
- if (!compare.equals(attributeNode.getName()))
+ XMLString::transcode("testAttribute", tempStr, 3999);
+ attributeNode = el->getAttributeNode(tempStr);
+
+ if (XMLString::compareString(tempStr, attributeNode->getName()))
{
- printf("Warning!!! DOM_Attr's 'getName' method failed to work properly!\n");
+ printf("Warning!!! IDOM_Attr's 'getName' method failed to work properly!\n");
OK = false;
}
- compare = "testAttribute's value";
- if (!compare.equals(attributeNode.getNodeValue()))
+
+ XMLString::transcode("testAttribute's value", tempStr, 3999);
+ if (XMLString::compareString(tempStr, attributeNode->getNodeValue()))
{
- printf("Warning!!! DOM_Attr's 'getNodeValue' method failed to work properly!\n");
+ printf("Warning!!! IDOM_Attr's 'getNodeValue' method failed to work properly!\n");
OK = false;
}
- if (! T ==attributeNode.getSpecified())
+ if (! T ==attributeNode->getSpecified())
{
- printf("Warning!!! DOM_Attr's 'getSpecified' method failed to work properly!\n");
+ printf("Warning!!! IDOM_Attr's 'getSpecified' method failed to work properly!\n");
OK = false;
}
- if (!compare.equals(attributeNode.getValue()))
+ if (XMLString::compareString(tempStr, attributeNode->getValue()))
{
- printf("Warning!!! DOM_Attr's 'getValue' method failed to work properly!\n");
+ printf("Warning!!! IDOM_Attr's 'getValue' method failed to work properly!\n");
OK = false;
}
- attributeNode.setNodeValue("Reset Value"); /// LEAK!!!!!
- compare = "Reset Value";
- if (!compare.equals(attributeNode.getNodeValue()))
+ XMLString::transcode("Reset Value", tempStr, 3999);
+ attributeNode->setNodeValue(tempStr); /// LEAK!!!!!
+ if (XMLString::compareString(tempStr, attributeNode->getNodeValue()))
{
- printf("Warning!!! DOM_Attr's 'setNodeValue' method failed to work properly!\n");
+ printf("Warning!!! IDOM_Attr's 'setNodeValue' method failed to work properly!\n");
OK = false;
}
- attributeNode.setValue(null);
- if (! attributeNode.getValue().equals(""))
+ attributeNode->setValue(XMLUni::fgZeroLenString);
+ if (XMLString::compareString(XMLUni::fgZeroLenString, attributeNode->getValue()))
{
- printf("Warning!!! DOM_Attr's 'setValue' to 'null' method failed to work properly!\n");
+ printf("Warning!!! IDOM_Attr's 'setValue' to '0' method failed to work properly!\n");
OK = false;
}
- attributeNode.setValue("Another value ");
- compare = "Another value ";
- if (!compare.equals(attributeNode.getValue()))
+ XMLString::transcode("Another value ", tempStr, 3999);
+ attributeNode->setValue(tempStr);
+ if (XMLString::compareString(tempStr, attributeNode->getValue()))
{
- printf("Warning!!! DOM_Attr's 'setValue' method failed to work properly!");
+ printf("Warning!!! IDOM_Attr's 'setValue' method failed to work properly!");
OK = false;
}
- node = attributeNode.cloneNode(T);
+ node = attributeNode->cloneNode(T);
// Check nodes for equality, both their name and value or lack thereof
bool cloneOK = true;
- if (!(node.getNodeName().equals(attributeNode.getNodeName())))
+ if (XMLString::compareString(node->getNodeName(), attributeNode->getNodeName()))
cloneOK = false;
- if (node.getNodeValue() == null &&
- attributeNode.getNodeValue() != null)
+ if (node->getNodeValue() == 0 &&
+ attributeNode->getNodeValue() != 0)
{
- attributeNode.getNodeValue().print();
cloneOK = false;
}
- if (node.getNodeValue() != null && attributeNode.getNodeValue() == null)
+ if (node->getNodeValue() != 0 && attributeNode->getNodeValue() == 0)
{
cloneOK = false;
- node.getNodeValue().print();
};
- if (node.getNodeValue() != null && attributeNode.getNodeValue() != null)
+ if (node->getNodeValue() != 0 && attributeNode->getNodeValue() != 0)
{
- if (!(node.getNodeValue().equals(attributeNode.getNodeValue())))
+ if (XMLString::compareString(node->getNodeValue(),attributeNode->getNodeValue()))
cloneOK = false;
}
/*
- if (! (node.getNodeName().equals(attributeNode.getNodeName()) && // Compares node names for equality
- (node.getNodeValue() != null && attributeNode.getNodeValue() != null) // Checks to make sure each node has a value node
- ? node.getNodeValue().equals(attributeNode.getNodeValue()) // If both have value nodes test those value nodes for equality
- : (node.getNodeValue() == null && attributeNode.getNodeValue() == null)))// If one node doesn't have a value node make sure both don't
+ if (! (node->getNodeName(), attributeNode->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && attributeNode->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? node->getNodeValue(), attributeNode->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && attributeNode->getNodeValue() == 0)))// If one node doesn't have a value node make sure both don't
*/
if (cloneOK == false)
{
- printf("'cloneNode' did not clone the Attribute node correctly\n");
+ fprintf(stderr, "'cloneNode' did not clone the Attribute node correctly\n");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
//************************************************* ERROR TESTS
- DTest tests;
+ IDTest tests;
//!! Throws HIERARCHY_REQUEST_ERR ****************
- // doc.getDocumentElement().appendChild(attributeNode);
+ // doc->getDocumentElement()->appendChild(attributeNode);
//!! Throws a NOT_FOUND_ERR ********
- // attribute2 = doc.createAttribute("testAttribute2");
- // doc.getDocumentElement().removeAttributeNode(attribute2);
+ // attribute2 = doc->createAttribute("testAttribute2");
+ // doc->getDocumentElement()->removeAttributeNode(attribute2);
//!! Throws an INUSE_ATTRIBUTE_ERR ******
- // DOM_Element element = (DOM_Element &)doc.getLastChild().getLastChild();
- // element.setAttributeNode(testAttribute );// Tests setNamedItem which generates error through justSetNamedItem.
+ // IDOM_Element* element = (IDOM_Element*)doc->getLastChild()->getLastChild();
+ // element->setAttributeNode(testAttribute );// Tests setNamedItem which generates error through justSetNamedItem.
-// For debugging***** printf("All DOM_Attr method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_Attr* method calls worked correctly.\n");
if (! OK)
- printf("\n*****The DOM_Attr method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_Attr* method calls listed above failed, all others worked correctly.*****\n");
// printf("");
+ return OK;
};
@@ -804,273 +797,281 @@
/**
- * This method tests DOM_CDATASection methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_CDATASection* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testCDATASection(DOM_Document document)
+bool IDTest::testCDATASection(IDOM_Document* document)
{
- DOM_Node node, node2;
+ IDOM_Node* node;
+ IDOM_Node* node2;
bool T = true;
bool OK = true;
// For debugging***** printf("\n testCDATASection's outputs:\n");
- node = document.getDocumentElement().getElementsByTagName("dBodyLevel23").item(0).getFirstChild(); // node gets DOM_CDATASection node
+ XMLString::transcode("dBodyLevel23", tempStr, 3999);
+ node = document->getDocumentElement()->getElementsByTagName(tempStr)->item(0)->getFirstChild(); // node gets IDOM_CDATASection* node
- node2 = node.cloneNode(T);//*****?
+ node2 = node->cloneNode(T);//*****?
// Check nodes for equality, both their name and value or lack thereof
- if (! (node.getNodeName().equals(node2.getNodeName()) && // Compares node names for equality
- (node.getNodeValue() != null && node2.getNodeValue() != null) // Checks to make sure each node has a value node
- ? node.getNodeValue().equals(node2.getNodeValue()) // If both have value nodes test those value nodes for equality
- : (node.getNodeValue() == null && node2.getNodeValue() == null))) // If one node doesn't have a value node make sure both don't
+ if (!(!XMLString::compareString(node->getNodeName(), node2->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && node2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(node->getNodeValue(), node2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && node2->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
{
- printf("'cloneNode' did not clone the DOM_CDATASection node correctly\n");
+ fprintf(stderr, "'cloneNode' did not clone the IDOM_CDATASection* node correctly\n");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
-// For debugging***** printf("All DOM_CDATASection method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_CDATASection* method calls worked correctly.\n");
if (! OK)
- printf("\n*****The DOM_CDATASection method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_CDATASection* method calls listed above failed, all others worked correctly.*****\n");
// printf("");
+ return OK;
};
/**
- * This method tests DOM_CharacterData methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_CharacterData methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testCharacterData(DOM_Document document)
+bool IDTest::testCharacterData(IDOM_Document* document)
{
- DOM_CharacterData charData;
- DOMString compareData, newData, resetData;
+ IDOM_CharacterData* charData;
+ XMLCh resetData[3999];
bool OK = true;
// For debugging***** printf("\n testCharacterData's outputs:\n");
- DOM_Node abc1 = document.getDocumentElement().getElementsByTagName("dBodyLevel31").item(0).getFirstChild(); // charData gets textNode11
- charData = (DOM_CharacterData &) abc1;
- compareData = "dBodyLevel31'sChildTextNode11";
- if (!compareData.equals(charData.getData()))
+ XMLString::transcode("dBodyLevel31", tempStr, 3999);
+ IDOM_Node* abc1 = document->getDocumentElement()->getElementsByTagName(tempStr)->item(0)->getFirstChild(); // charData gets textNode11
+
+ charData = (IDOM_CharacterData *) abc1;
+
+ XMLString::transcode("dBodyLevel31'sChildTextNode11", tempStr, 3999);
+ if (XMLString::compareString(tempStr, charData->getData()))
{
- printf("Warning!!! DOM_CharacterData's 'getData' failed to work properly!\n This may corrupt other DOM_CharacterData tests!!!*****\n");
+ printf("Warning!!! IDOM_CharacterData's 'getData' failed to work properly!\n This may corrupt other IDOM_CharacterData tests!!!*****\n");
OK = false;
}
- resetData = charData.getData();
- // printf("This node's original data is: " + charData.getData());
+ XMLString::copyString(resetData,charData->getData());
+ // printf("This node's original data is: " + charData->getData());
+
+ XMLString::transcode(" This is new data for this node", tempStr2, 3999);
+
+ XMLString::copyString(tempStr, charData->getData());
+ XMLString::catString(tempStr, tempStr2);
+
+ charData->appendData(tempStr2);
- newData = " This is new data for this node";
- compareData = charData.getData() + newData;
- charData.appendData(newData);
- if (!compareData.equals(charData.getData()))
+
+ if (XMLString::compareString(tempStr, charData->getData()))
{
- printf("Warning!!! DOM_CharacterData's 'appendData' failed to work properly!\n");
+ printf("Warning!!! IDOM_CharacterData's 'appendData' failed to work properly!\n");
OK = false;
}
- // printf("This node's appended data is: " + charData.getData());
+ // printf("This node's appended data is: " + charData->getData());
- compareData = "dBodyLevel";
- charData.deleteData(10, 100);
- if (!compareData.equals(charData.getData()))
+ XMLString::transcode("dBodyLevel", tempStr, 3999);
+ charData->deleteData(10, 100);
+ if (XMLString::compareString(tempStr, charData->getData()))
{
- printf("Warning!!! DOM_CharacterData's 'deleteData' failed to work properly!\n");
+ printf("Warning!!! IDOM_CharacterData's 'deleteData' failed to work properly!\n");
OK = false;
}
- // printf("This node's partially deleted data is: " + charData.getData());
+ // printf("This node's partially deleted data is: " + charData->getData());
unsigned int length = 10;
- if (!(length == charData.getLength()))
+ if (!(length == charData->getLength()))
{
- printf("Warning!!! DOM_CharacterData's 'getLength' failed to work properly!\n");
+ printf("Warning!!! IDOM_CharacterData's 'getLength' failed to work properly!\n");
OK = false;
}
- // printf("This node's data length is: " + charData.getLength());
+ // printf("This node's data length is: " + charData->getLength());
- compareData = "dBody' This is data inserted into this node'Level";
- charData.insertData(5, "' This is data inserted into this node'");
- if (!compareData.equals(charData.getData()))
+ XMLString::transcode("dBody' This is data inserted into this node'Level", tempStr, 3999);
+ XMLString::transcode("' This is data inserted into this node'", tempStr2, 3999);
+ charData->insertData(5, tempStr2);
+ if (XMLString::compareString(tempStr, charData->getData()))
{
- printf("Warning!!! DOM_CharacterData's 'insertData' failed to work properly!\n");
+ printf("Warning!!! IDOM_CharacterData's 'insertData' failed to work properly!\n");
OK = false;
}
- // printf("This node's updated with insert data is: " + charData.getData());
+ // printf("This node's updated with insert data is: " + charData->getData());
- compareData = "dBody' This is ' replacement data'ted into this node'Level";
- charData.replaceData(15, 10, "' replacement data'");
- if (!compareData.equals(charData.getData()))
+ XMLString::transcode("dBody' This is ' replacement data'ted into this node'Level", tempStr, 3999);
+ XMLString::transcode("' replacement data'", tempStr2, 3999);
+ charData->replaceData(15, 10, tempStr2);
+ if (XMLString::compareString(tempStr, charData->getData()))
{
- printf("Warning!!! DOM_CharacterData's 'replaceData' failed to work properly!\n");
+ printf("Warning!!! IDOM_CharacterData's 'replaceData' failed to work properly!\n");
OK = false;
}
- // printf("This node's updated with replacement data is: " +charData.getData());
+ // printf("This node's updated with replacement data is: " +charData->getData());
- compareData = "New data A123456789B123456789C123456789D123456789E123456789";
- charData.setData("New data A123456789B123456789C123456789D123456789E123456789");
- if (!compareData.equals(charData.getData()))
+ XMLString::transcode("New data A123456789B123456789C123456789D123456789E123456789", tempStr, 3999);
+ charData->setData(tempStr);
+ if (XMLString::compareString(tempStr, charData->getData()))
{
- printf("Warning!!! DOM_CharacterData's 'setData' failed to work properly!");
+ printf("Warning!!! IDOM_CharacterData's 'setData' failed to work properly!");
OK = false;
}
- // printf("This node's new data via setData: " + charData.getData());
+ // printf("This node's new data via setData: " + charData->getData());
- compareData = "123456789D123456789E123456789";
- if (!compareData.equals(charData.substringData(30, 30)))
+ XMLString::transcode("123456789D123456789E123456789", tempStr, 3999);
+ if (XMLString::compareString(tempStr, charData->substringData(30, 30)))
{
- printf("Warning!!! DOM_CharacterData's 'substringData' failed to work properly!\n");
+ printf("Warning!!! IDOM_CharacterData's 'substringData' failed to work properly!\n");
OK = false;
}
- // printf("Using subString 30,30 you get:"); charData.substringData(30,30)).print();
+ // printf("Using subString 30,30 you get:"); charData->substringData(30,30)).print();
- compareData = "New data A123456789B12345";
- if (!compareData.equals(charData.substringData(0, 25)))
+ XMLString::transcode("New data A123456789B12345", tempStr, 3999);
+ if (XMLString::compareString(tempStr, charData->substringData(0, 25)))
{
- printf("Warning!!! DOM_CharacterData's 'substringData' failed to work properly!\n");
+ printf("Warning!!! IDOM_CharacterData's 'substringData' failed to work properly!\n");
OK = false;
}
- // printf("Using subString 0,25 you get: "); charData.substringData(0,25)).print();
+ // printf("Using subString 0,25 you get: "); charData->substringData(0,25)).print();
//************************************************* ERROR TESTS
- DTest tests; // What is this for? 'tests' is never used.
+ IDTest tests; // What is this for? 'tests' is never used.
//!! Throws INDEX_SIZE_ERR ********************
- EXCEPTIONSTEST(charData.deleteData(-1, 5), DOM_DOMException::INDEX_SIZE_ERR, OK, 101 );
+ EXCEPTIONSTEST(charData->deleteData(-1, 5), IDOM_DOMException::INDEX_SIZE_ERR, OK, 101 );
// Test 102 is not an error because the -1 parameter is an unsigned value, and counts
// that exceed the length of the string are allowed.
-// EXCEPTIONSTEST(charData.deleteData(2, -1), DOM_DOMException::INDEX_SIZE_ERR, OK, 102 );
- EXCEPTIONSTEST(charData.deleteData(100, 5), DOM_DOMException::INDEX_SIZE_ERR, OK,103 );
+// EXCEPTIONSTEST(charData->deleteData(2, -1), IDOM_DOMException::INDEX_SIZE_ERR, OK, 102 );
+ EXCEPTIONSTEST(charData->deleteData(100, 5), IDOM_DOMException::INDEX_SIZE_ERR, OK,103 );
//can't set negative unsigned int in c++ compiler
- // EXCEPTIONSTEST(charData.insertData(-1, "Stuff inserted"), DOM_DOMException::INDEX_SIZE_ERR, OK, 104 );
- EXCEPTIONSTEST(charData.insertData(100,"Stuff inserted"), DOM_DOMException::INDEX_SIZE_ERR, OK, 105 );
+ // EXCEPTIONSTEST(charData->insertData(-1, "Stuff inserted"), IDOM_DOMException::INDEX_SIZE_ERR, OK, 104 );
+ XMLString::transcode("Stuff inserted", tempStr, 3999);
+ EXCEPTIONSTEST(charData->insertData(100, tempStr), IDOM_DOMException::INDEX_SIZE_ERR, OK, 105 );
- // EXCEPTIONSTEST(charData.replaceData(-1, 5, "Replacement stuff") , DOM_DOMException::INDEX_SIZE_ERR, OK, 106 );
- EXCEPTIONSTEST(charData.replaceData(100, 5 ,"Replacement stuff"), DOM_DOMException::INDEX_SIZE_ERR, OK, 107 );
- // EXCEPTIONSTEST(charData.replaceData(2, -1, "Replacement stuff"), DOM_DOMException::INDEX_SIZE_ERR, OK, 108 );
-
- EXCEPTIONSTEST(charData.substringData(-1, 5), DOM_DOMException::INDEX_SIZE_ERR, OK, 109 );
- EXCEPTIONSTEST(charData.substringData(100, 5), DOM_DOMException::INDEX_SIZE_ERR, OK, 110 );
- // EXCEPTIONSTEST(charData.substringData(2, -1), DOM_DOMException::INDEX_SIZE_ERR, OK, 111 );
-
-
-//!! Throws NO_MODIFICATION_ALLOWED_ERR ********
-// Since user cannot add children to Entity and EntityReference Nodes this test can't be done.
-#if 0
-
- DOM_Node abc8 = document.getDocumentElement().getElementsByTagName("dBodyLevel24").
- item(0).getFirstChild().getChildNodes().item(0); // node gets ourEntityReference node's child text
- DOM_Text node = (DOM_Text &) abc8;
-
- EXCEPTIONSTEST(node.appendData("new data"), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 112 );
- EXCEPTIONSTEST(node.deleteData(5, 10), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 113 );
- EXCEPTIONSTEST(node.insertData(5, "Stuff inserted"), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 114 );
- EXCEPTIONSTEST(node.replaceData(5, 10, "Replacementstuff"), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 115 );
- EXCEPTIONSTEST(node.setData("New setdata stuff"), DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 116 );
+ // EXCEPTIONSTEST(charData->replaceData(-1, 5, "Replacement stuff") , IDOM_DOMException::INDEX_SIZE_ERR, OK, 106 );
+ XMLString::transcode("Replacement stuff", tempStr, 3999);
+ EXCEPTIONSTEST(charData->replaceData(100, 5 ,tempStr), IDOM_DOMException::INDEX_SIZE_ERR, OK, 107 );
+ // EXCEPTIONSTEST(charData->replaceData(2, -1, "Replacement stuff"), IDOM_DOMException::INDEX_SIZE_ERR, OK, 108 );
-#endif
+ EXCEPTIONSTEST(charData->substringData(-1, 5), IDOM_DOMException::INDEX_SIZE_ERR, OK, 109 );
+ EXCEPTIONSTEST(charData->substringData(100, 5), IDOM_DOMException::INDEX_SIZE_ERR, OK, 110 );
+ // EXCEPTIONSTEST(charData->substringData(2, -1), IDOM_DOMException::INDEX_SIZE_ERR, OK, 111 );
-// For debugging***** printf("All DOM_CharacterData method calls worked correctly.\n");
+
+// For debugging***** printf("All IDOM_CharacterData method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_CharacterData method calls listed above failed, all others worked correctly.*****\n");
- charData.setData(resetData); // reset node to original data
+ printf("\n*****The IDOM_CharacterData method calls listed above failed, all others worked correctly.*****\n");
+ charData->setData(resetData); // reset node to original data
// printf(""\n);
+ return OK;
};
/**
- * This method tests ChildNodeList methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests ChildNodeList methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testChildNodeList(DOM_Document document)
+bool IDTest::testChildNodeList(IDOM_Document* document)
{
- DOM_Node node, node2;
+ IDOM_Node* node;
+ IDOM_Node* node2;
bool OK = true;
// For debugging***** printf("\n testChildNodeList's outputs:\n");
- node = document.getDocumentElement().getLastChild(); // node gets doc's testBody element
+ node = document->getDocumentElement()->getLastChild(); // node gets doc's testBody element
- if (!(node.getChildNodes().getLength()== 4))
+ if (!(node->getChildNodes()->getLength()== 4))
OK = false;
- node2 = node.getChildNodes().item(2);
- if (! node2.getNodeName().equals("dBodyLevel23"))
+ node2 = node->getChildNodes()->item(2);
+ XMLString::transcode("dBodyLevel23", tempStr, 3999);
+ if (XMLString::compareString(tempStr, node2->getNodeName()))
OK = false;
// For debugging***** printf("All ChildNodeList method calls worked correctly.\n");
if (!OK)
printf("\n*****The ChildNodeList method calls listed above failed, all others worked correctly.*****\n");
// printf("");
+ return OK;
};
/**
- * This method tests DOM_Comment methods for the XML DOM implementation
- * version 1.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_Comment* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testComment(DOM_Document document)
+bool IDTest::testComment(IDOM_Document* document)
{
- DOM_Node node, node2;
+ IDOM_Node* node;
+ IDOM_Node* node2;
bool T = true;
bool OK = true;
// For debugging***** printf("\n testComment's outputs:\n");
- node = document.getDocumentElement().getElementsByTagName("dBodyLevel31").item(0).getFirstChild(); // node gets textNode11
- node2 = node.cloneNode(T);
+ XMLString::transcode("dBodyLevel31", tempStr, 3999);
+ node = document->getDocumentElement()->getElementsByTagName(tempStr)->item(0)->getFirstChild(); // node gets textNode11
+ node2 = node->cloneNode(T);
// Check nodes for equality, both their name and value or lack thereof
- if (!(node.getNodeName().equals(node2.getNodeName()) && // Compares node names for equality
- (node.getNodeValue() != null && node2.getNodeValue() != null) // Checks to make sure each node has a value node
- ? node.getNodeValue().equals(node2.getNodeValue()) // If both have value nodes test those value nodes for equality
- : (node.getNodeValue() == null && node2.getNodeValue() == null))) // If one node doesn't have a value node make sure both don't
- //printf("'cloneNode' did not clone the DOM_Comment node correctly\n");
+ if (!(!XMLString::compareString(node->getNodeName(), node2->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && node2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(node->getNodeValue(), node2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && node2->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
+ {
+ fprintf(stderr, "'cloneNode' did not clone the IDOM_Comment* node correctly\n");
OK = false;
+ }
// Deep clone test comparison is in testNode & testDocument
if (OK)
-// For debugging***** printf("All DOM_Comment method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_Comment* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_Comment method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_Comment* method calls listed above failed, all others worked correctly.*****\n");
// printf("\n");
+ return OK;
};
/**
- * This method tests DeepNodeList methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests DeepNodeList methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testDeepNodeList(DOM_Document document)
+bool IDTest::testDeepNodeList(IDOM_Document* document)
{
- DOM_Node node, node2;
+ IDOM_Node* node;
+ IDOM_Node* node2;
bool OK = true;
// For debugging***** printf("\n testDeepNodeList's outputs:\n\n");
- node = document.getLastChild().getLastChild(); // node gets docBody element
-// DOM_Element el = (DOM_Element &)node;
-// DOM_NodeList nl = el.getElementsByTagName("*");
-// int len = nl.getLength();
+ node = document->getLastChild()->getLastChild(); // node gets docBody element
+// IDOM_Element* el = (IDOM_Element*)node;
+// IDOM_NodeList nl = el->getElementsByTagName("*");
+// int len = nl->getLength();
// if (len != 8)
- if (!(8 == ((DOM_Element &) node).getElementsByTagName("*").getLength()))
+ XMLString::transcode("*",tempStr, 3999);
+ if (!(8 == ((IDOM_Element*) node)->getElementsByTagName(tempStr)->getLength()))
{
printf ("Warning!!! DeepNodeList's 'getLength' failed to work properly!\n");
OK = false;
}
- node2 = ((DOM_Element &) node).getElementsByTagName("*").item(2); //This also runs through 'nextMatchingElementAfter"
- if (! node2.getNodeName().equals("dBodyLevel32"))
+ node2 = ((IDOM_Element*) node)->getElementsByTagName(tempStr)->item(2); //This also runs through 'nextMatchingElementAfter"
+
+ XMLString::transcode("dBodyLevel32", tempStr, 3999);
+ if (XMLString::compareString(tempStr, node2->getNodeName()))
{
- printf ("Warning!!! DeepNodeList's 'item' (or DOM_Element's 'getElementsBy TagName)failed to work properly!\n");
+ printf ("Warning!!! DeepNodeList's 'item' (or IDOM_Element's 'getElementsBy TagName)failed to work properly!\n");
OK = false;
}
- node2 = document.getLastChild();
- if (! ((DOM_Element &) node2).getElementsByTagName("dTestBody").item(0).getNodeName().equals("dTestBody"))//This also runs through 'nextMatchingElementAfter"
+ node2 = document->getLastChild();
+ XMLString::transcode("dTestBody", tempStr, 3999);
+ if (XMLString::compareString(tempStr, ((IDOM_Element*) node2)->getElementsByTagName(tempStr)->item(0)->getNodeName()))//This also runs through 'nextMatchingElementAfter"
{
- printf ("Warning!!! DeepNodeList's 'item' (or DOM_Element's 'getElementsBy TagName)failed to work properly!\n");
+ printf ("Warning!!! DeepNodeList's 'item' (or IDOM_Element's 'getElementsBy TagName)failed to work properly!\n");
OK = false;
}
@@ -1079,79 +1080,83 @@
if (!OK)
printf("\n*****The DeepNodeList method calls listed above failed, all others worked correctly.*****\n");
// printf("");
+ return OK;
};
/**
- * This method tests DOM_Document methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_Document* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*
- **** ALL DOM_Document create methods are run in docBuilder except createAttribute which is in testAttribute**
+ **** ALL IDOM_Document* create methods are run in docBuilder except createAttribute which is in testAttribute**
*/
-void DTest::testDocument(DOM_Document document)
+bool IDTest::testDocument(IDOM_Document* document)
{
- DTest make;
- DOM_DocumentFragment docFragment, docFragment2;
- DOM_Element newElement;
- DOM_Node node, node2;
- DOMString elementNames[] = {"dFirstElement", "dTestBody", "dBodyLevel21","dBodyLevel31","dBodyLevel32",
+ IDTest make;
+ IDOM_DocumentFragment* docFragment, *docFragment2;
+ IDOM_Element* newElement;
+ IDOM_Node* node, *node2;
+
+ const char* elementNames[] = {"dFirstElement", "dTestBody", "dBodyLevel21","dBodyLevel31","dBodyLevel32",
"dBodyLevel22","dBodyLevel33","dBodyLevel34","dBodyLevel23","dBodyLevel24"};
- DOMString newElementNames[] = {"dFirstElement", "dTestBody", "dBodyLevel22","dBodyLevel33","dBodyLevel34","dBodyLevel23"};
+ const char* newElementNames[] = {"dFirstElement", "dTestBody", "dBodyLevel22","dBodyLevel33","dBodyLevel34","dBodyLevel23"};
+
+
bool result;
bool OK = true;
// For debugging***** printf("\n testDocument's outputs:\n \n");
- DOM_DocumentType checkDocType = make.createDocumentType(document,"testDocument1");
- DOM_DocumentType docType = document.getDoctype();
+ XMLString::transcode("testDocument1", tempStr, 3999);
+ IDOM_DocumentType* checkDocType = make.createDocumentType(document,tempStr);
+ IDOM_DocumentType* docType = document->getDoctype();
- if (! checkDocType.getNodeName().equals(docType.getNodeName() ))
+ if (XMLString::compareString(checkDocType->getNodeName(),docType->getNodeName() ))
{
- printf("Warning!!! DOM_Document's 'getDocType method failed!\n" );
+ printf("Warning!!! IDOM_Document's 'getDocType method failed!\n" );
OK = false;
}
- if (!checkDocType.getNodeValue().equals(docType.getNodeValue()))
+ if (XMLString::compareString(checkDocType->getNodeValue(), docType->getNodeValue()))
{
- printf("Warning!!! DOM_Document's 'getDocType method failed!\n" );
+ printf("Warning!!! IDOM_Document's 'getDocType method failed!\n" );
OK = false;
}
/*
- if (! (checkDocType.getNodeName().equals(docType.getNodeName()) && // Compares node names for equality
- (checkDocType.getNodeValue() != null && docType.getNodeValue() != null) // Checks to make sure each node has a value node
- ? checkDocType.getNodeValue().equals(docType.getNodeValue()) // If both have value nodes test those value nodes for equality
- : (checkDocType.getNodeValue() == null && docType.getNodeValue() == null))) // If one node doesn't have a value node make sure both don't
+ if (! (checkDocType->getNodeName(), docType->getNodeName()) && // Compares node names for equality
+ (checkDocType->getNodeValue() != 0 && docType->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? checkDocType->getNodeValue(), docType->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (checkDocType->getNodeValue() == 0 && docType->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
{
- printf("Warning!!! DOM_Document's 'getDocType method failed!\n" );
+ printf("Warning!!! IDOM_Document's 'getDocType method failed!\n" );
OK = false;
}
*/
- DOM_Node rootElement = document.getLastChild();
+ IDOM_Node* rootElement = document->getLastChild();
- bool check = (rootElement.getNodeValue() != null && document.getDocumentElement().getNodeValue() != null) // Checks to make sure each node has a value node
- ? rootElement.getNodeValue().equals(document.getDocumentElement().getNodeValue()) // If both have value nodes test those value nodes for equality
- : (rootElement.getNodeValue() == null && document.getDocumentElement().getNodeValue() == null); // If one node doesn't have a value node make sure both don't
- if (! (rootElement.getNodeName().equals(document.getDocumentElement().getNodeName()) && // Compares node names for equality
+ bool check = (rootElement->getNodeValue() && document->getDocumentElement()->getNodeValue()) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(rootElement->getNodeValue(), document->getDocumentElement()->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (rootElement->getNodeValue() == 0 && document->getDocumentElement()->getNodeValue() == 0); // If one node doesn't have a value node make sure both don't
+ if (!(!XMLString::compareString(rootElement->getNodeName(), document->getDocumentElement()->getNodeName()) && // Compares node names for equality
check))
{
- printf("Warning!!! DOM_Document's 'getDocumentElement' method failed!\n" );
+ printf("Warning!!! IDOM_Document's 'getDocumentElement' method failed!\n" );
OK = false;
}
- DOM_NodeList docElements = document.getElementsByTagName("*");
- int docSize = docElements.getLength();
+ XMLString::transcode("*", tempStr, 3999);
+ IDOM_NodeList* docElements = document->getElementsByTagName(tempStr);
+ int docSize = docElements->getLength();
int i;
for (i = 0; i < docSize; i++)
{
- DOM_Node n = (DOM_Node) docElements.item(i);
- if (! (elementNames[i].equals(n.getNodeName())))
+ IDOM_Node* n = (IDOM_Node*) docElements->item(i);
+ if (XMLString::compareString(XMLString::transcode(elementNames[i]), n->getNodeName()))
{
- printf("Comparison of this document's elements failed at element number %d : ", i);
- n.getNodeName().print();
+ printf("Comparison of this document's elements failed at element number %d at line %i \n", i, __LINE__);
OK = false;
break;
}
@@ -1159,71 +1164,72 @@
// What is this supposed to be doing?
//
- //if (document.equals(document.getImplementation()))
+ //if (document->equals(document->getImplementation()))
//{
- // printf("Warning!!! DOM_Document's 'getImplementation' method failed!\n" );
+ // printf("Warning!!! IDOM_Document's 'getImplementation' method failed!\n" );
// OK = false;
//}
- newElement = document.createElement("NewElementTestsInsertBefore");
- // doc.insertBefore(newElement,null);//!! Throws a HIERARCHY_REQUEST_ERR *******
- // doc.removeChild(docElements.item(9));//!! Throws a NOT_FOUND_ERR ********
+ XMLString::transcode("NewElementTestsInsertBefore", tempStr, 3999);
+ newElement = document->createElement(tempStr);
+ // doc->insertBefore(newElement,0);//!! Throws a HIERARCHY_REQUEST_ERR *******
+ // doc->removeChild(docElements->item(9));//!! Throws a NOT_FOUND_ERR ********
- docFragment = document.createDocumentFragment();
+ docFragment = document->createDocumentFragment();
//Tests removeChild and stores removed branch for tree reconstruction
- docFragment.appendChild(docElements.item(1).removeChild(docElements.item(9)));
- docFragment2 = document.createDocumentFragment();
+ docFragment->appendChild(docElements->item(1)->removeChild(docElements->item(9)));
+ docFragment2 = document->createDocumentFragment();
//Tests removeChild and stores removed branch for tree reconstruction
- docFragment2.appendChild(docElements.item(1).removeChild(docElements.item(2)));
- docSize = docElements.getLength();
+ docFragment2->appendChild(docElements->item(1)->removeChild(docElements->item(2)));
+ docSize = docElements->getLength();
for (i = 0; i < docSize; i++)
{
- DOM_Node n = (DOM_Node) docElements.item(i);
- if (! (newElementNames[i].equals(n.getNodeName())))
+ IDOM_Node* n = (IDOM_Node*) docElements->item(i);
+ XMLString::transcode(newElementNames[i], tempStr, 3999);
+ if (XMLString::compareString(tempStr, n->getNodeName()))
{
- printf("Comparison of new document's elements failed at element number %d : ", i);
- n.getNodeName().print();
+ printf("Comparison of new document's elements failed at element number %d at line %i \n", i, __LINE__);
OK = false;
break;
}
}
- docElements.item(1).insertBefore(docFragment, DOM_Node()); //Reattaches removed branch to restore tree to the original
+ docElements->item(1)->insertBefore(docFragment, 0); //Reattaches removed branch to restore tree to the original
// AH Revist. Note: insertBefore should be able to take
- // a null as its second parameter.
- docElements.item(1).insertBefore(docFragment2, docElements.item(2)); //Reattaches removed branch to restore tree to the original
+ // a 0 as its second parameter.
+ docElements->item(1)->insertBefore(docFragment2, docElements->item(2)); //Reattaches removed branch to restore tree to the original
- // printf(docElements.item(2).getNodeName());
+ // printf(docElements->item(2)->getNodeName());
- docSize = docElements.getLength();
+ docSize = docElements->getLength();
for (i = 0; i < docSize; i++)
{
- DOM_Node n = (DOM_Node) docElements.item(i);
- if (! (elementNames[i].equals(n.getNodeName())))
+ IDOM_Node* n = (IDOM_Node*) docElements->item(i);
+ XMLString::transcode(elementNames[i], tempStr, 3999);
+ if (XMLString::compareString(tempStr, n->getNodeName()))
{
- printf("Comparison of restored document's elements failed at element number %d : ", i);
- n.getNodeName().print();
+ printf("Comparison of restored document's elements failed at element number %d at line %i \n", i, __LINE__);
OK = false;
break;
}
}
- DTest tests;
+ IDTest tests;
-// DOM_Document z = tests.createDocument();
+// IDOM_Document* z = tests.createDocument();
// tests.docBuilder(z, "z");
//!! Throws WRONG_DOCUMENT_ERR **********
-// EXCEPTIONSTEST(z.appendChild(
- // z.appendChild(d.createComment("Test doc d comment"));// Tries to append z document with document d comment
- // d.getDocumentElement().appendChild(z.createElement("newZdocElement"));// Tries to append d document with document z DOM_Element
- // d.getLastChild().getLastChild().insertBefore(z.createElement("newZdocElement"),d.getLastChild().getLastChild().getFirstChild());// Tries to insert into d document with document z DOM_Element
- // d.replaceChild(z.createElement("newZdocElement"),d.getLastChild().getLastChild().getFirstChild()); // Tries to replace in d document with document z DOM_Element
+// EXCEPTIONSTEST(z->appendChild(
+ // z->appendChild(d.createComment("Test doc d comment"));// Tries to append z document with document d comment
+ // d->getDocumentElement()->appendChild(z.createElement("newZdocElement"));// Tries to append d document with document z IDOM_Element
+ // d->getLastChild()->getLastChild()->insertBefore(z.createElement("newZdocElement"),d->getLastChild()->getLastChild()->getFirstChild());// Tries to insert into d document with document z IDOM_Element
+ // d->replaceChild(z.createElement("newZdocElement"),d->getLastChild()->getLastChild()->getFirstChild()); // Tries to replace in d document with document z IDOM_Element
- // doc.setNodeValue("This shouldn't work");//!! Throws a NO_MODIFICATION_ALLOWED_ERR ********
+ // doc->setNodeValue("This shouldn't work");//!! Throws a NO_MODIFICATION_ALLOWED_ERR ********
node = document;
- node2 = document.cloneNode(true);
+ node2 = document->cloneNode(true);
result = treeCompare(node, node2); // Deep clone test comparison of document cloneNode
if (!result)
{
@@ -1234,329 +1240,301 @@
// Deep clone test comparison is also in testNode
-// For debugging***** printf("All DOM_Document method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_Document* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_Document method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_Document* method calls listed above failed, all others worked correctly.*****\n");
// printf("\n");
+ return OK;
};
/**
- * This method tests DOM_DocumentFragment methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_DocumentFragment* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*
*
********This really isn't needed, only exists to throw NO_MODIFICATION_ALLOWED_ERR ********
*/
-void DTest::testDocumentFragment(DOM_Document document)
+bool IDTest::testDocumentFragment(IDOM_Document* document)
{
bool OK = true;
// For debugging***** printf("\n testDocumentFragment's outputs:\n");
- DOM_DocumentFragment testDocFragment = document.createDocumentFragment();
+ IDOM_DocumentFragment* testDocFragment = document->createDocumentFragment();
- // testDocFragment.setNodeValue("This is a document fragment!");//!! Throws a NO_MODIFICATION_ALLOWED_ERR ********
+ // testDocFragment->setNodeValue("This is a document fragment!");//!! Throws a NO_MODIFICATION_ALLOWED_ERR ********
-// For debugging***** printf("All DOM_DocumentFragment method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_DocumentFragment* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_DocumentFragment method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_DocumentFragment* method calls listed above failed, all others worked correctly.*****\n");
// printf("\n");
+ return OK;
};
/**
- * This method tests DOM_DocumentType methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_DocumentType* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testDocumentType(DOM_Document document)
+bool IDTest::testDocumentType(IDOM_Document* document)
{
- DTest test;
- DOM_DocumentType docType, holdDocType;
- DOM_NamedNodeMap docEntityMap, docNotationMap;
- DOM_Node node, node2;
- DOMString compare;
+ IDTest test;
+ IDOM_DocumentType* docType, *holdDocType;
+ IDOM_NamedNodeMap* docNotationMap;
+ IDOM_Node* node, *node2;
bool OK = true;
// For debugging***** printf("\n testDocumentType's outputs:\n");
- DOM_DocumentType newDocumentType = test.createDocumentType(document, "TestDocument");
- node = document.getFirstChild(); // node gets doc's docType node
- node2 = node.cloneNode(true);
+ XMLString::transcode("TestDocument", tempStr, 3999);
+ IDOM_DocumentType* newDocumentType = test.createDocumentType(document, tempStr);
+ node = document->getFirstChild(); // node gets doc's docType node
+ node2 = node->cloneNode(true);
// Check nodes for equality, both their name and value or lack thereof
- bool check = (node.getNodeValue() != null && node2.getNodeValue() != null) // Checks to make sure each node has a value node
- ? node.getNodeValue().equals(node2.getNodeValue()) // If both have value nodes test those value nodes for equality
- : (node.getNodeValue() == null && node2.getNodeValue() == null);// If one node doesn't have a value node make sure both don't
- if (! (node.getNodeName().equals(node2.getNodeName()) && // Compares node names for equality
- check))
+ if (!(!XMLString::compareString(node->getNodeName(), node2->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && node2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(node->getNodeValue(), node2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && node2->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
{
- printf("'cloneNode' did not clone the DOM_DocumentType node correctly\n");
+ fprintf(stderr, "'cloneNode' did not clone the IDOM_DocumentType* node correctly\n");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
- DOM_Node abc9 = document.getFirstChild();
- docType = (DOM_DocumentType &) abc9;
- compare = "ourEntityNode";
-
-#if 0
- // Entity tests omitted; can not create entity nodes outside of the Parser.
- docEntityMap = docType.getEntities();
- if (! compare.equals(docEntityMap.item(0).getNodeName()))
- {
- printf("Warning!!! DOM_DocumentType's 'getEntities' failed!\n" );
- OK = false;
- }
-#endif
+ IDOM_Node* abc9 = document->getFirstChild();
+ docType = (IDOM_DocumentType*) abc9;
- docNotationMap = docType.getNotations();
- compare = "ourNotationNode";
- if (! compare.equals(docNotationMap.item(0).getNodeName()))
+ XMLString::transcode("ourNotationNode", tempStr, 3999);
+ docNotationMap = docType->getNotations();
+ if (XMLString::compareString(tempStr, docNotationMap->item(0)->getNodeName()))
{
- printf("Warning!!! DOM_DocumentType's 'getNotations' failed!\n");
+ printf("Warning!!! IDOM_DocumentType's 'getNotations' failed!\n");
OK = false;
}
- // doc.appendChild(newDocumentTypeImpl);//!! Throws a HIERARCHY_REQUEST_ERR *******
- DOM_Node abc10 = document.removeChild(document.getFirstChild()); //Tests removeChild and stores removed branch for tree reconstruction
- holdDocType = (DOM_DocumentType &) abc10;
- document.insertBefore(newDocumentType, document.getDocumentElement());
+ // doc->appendChild(newDocumentTypeImpl);//!! Throws a HIERARCHY_REQUEST_ERR *******
+ IDOM_Node* abc10 = document->removeChild(document->getFirstChild()); //Tests removeChild and stores removed branch for tree reconstruction
+ holdDocType = (IDOM_DocumentType*) abc10;
+ document->insertBefore(newDocumentType, document->getDocumentElement());
//** Other aspects of insertBefore are tested in docBuilder through appendChild*
- document.removeChild(document.getFirstChild()); //Removes newDocumentType for tree restoral
- document.insertBefore(holdDocType, document.getFirstChild()); //Reattaches removed branch to restore tree to the original
+ document->removeChild(document->getFirstChild()); //Removes newDocumentType for tree restoral
+ document->insertBefore(holdDocType, document->getFirstChild()); //Reattaches removed branch to restore tree to the original
-// For debugging***** printf("All DOM_DocumentType method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_DocumentType* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_DocumentType method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_DocumentType* method calls listed above failed, all others worked correctly.*****\n");
// printf("");
+ return OK;
};
/**
- * @param document org.w3c.dom.DOM_Document
+ * @param document org.w3c.dom.IDOM_Document
*/
-void DTest::testDOMerrors(DOM_Document document) {
+bool IDTest::testIDOMerrors(IDOM_Document* document) {
bool OK = true;
- DTest tests;
-
- EXCEPTIONSTEST(document.appendChild(testElementNode), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 201 );
- EXCEPTIONSTEST(testTextNode.appendChild(testTextNode), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 202 );
-#ifdef skipthese
- EXCEPTIONSTEST(document.insertBefore(document.getElementsByTagName("docEntity").item(0),
- document.getElementsByTagName("docFirstElement").item(0)), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 203 );
- EXCEPTIONSTEST(document.replaceChild(document.getElementsByTagName("docCDATASection").item(0),
- document.getElementsByTagName("docFirstElement").item(0)), DOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 204 );
-
- EXCEPTIONSTEST(document.getElementsByTagName("docFirstElement").item(0).setNodeValue("This shouldn't work!" ),
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 205 );
- EXCEPTIONSTEST(docReferenceEntity.setNodeValue("This shouldn't work!"),
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 206 );
- EXCEPTIONSTEST(docEntity.setNodeValue("This shouldn't work!"),
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 207 );
- EXCEPTIONSTEST(document.setNodeValue("This shouldn't work!"),
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 208 );
- EXCEPTIONSTEST(docDocType.setNodeValue("This shouldn't work!"),
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 209 );
- EXCEPTIONSTEST(docDocFragment.setNodeValue("This shouldn't work!"),
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 210 );
- EXCEPTIONSTEST(docNotation.setNodeValue("This shouldn't work!"),
- DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 211 );
- EXCEPTIONSTEST(docReferenceEntity.appendChild(entityReferenceText2)
- , DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, OK, 212 );
-
-
- EXCEPTIONSTEST(docBodyLevel32.insertBefore(docTextNode11,docBody), DOM_DOMException::NOT_FOUND_ERR, OK, 213 );
- EXCEPTIONSTEST(docBodyLevel32.removeChild(docFirstElement), DOM_DOMException::NOT_FOUND_ERR, OK, 214 );
- EXCEPTIONSTEST(docBodyLevel32.replaceChild(docTextNode11,docFirstElement), DOM_DOMException::NOT_FOUND_ERR );
-
-#endif
-
-//!! Throws a NOT_FOUND_ERR ********
-
- // docBodyLevel32.getAttributes().removeNamedItem(testAttribute.getName()); 16 // To test removeNamedItem
+ IDTest tests;
+ EXCEPTIONSTEST(document->appendChild(testElementNode), IDOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 201 );
+ EXCEPTIONSTEST(testTextNode->appendChild(testTextNode), IDOM_DOMException::HIERARCHY_REQUEST_ERR, OK, 202 );
+ return OK;
};
/**
- * This method tests DOM_DOMImplementation methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_IDOMImplementation methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testDOMImplementation(DOM_Document document)
+bool IDTest::testIDOMImplementation(IDOM_Document* document)
{
- DOM_DOMImplementation implementation;
+ IDOM_DOMImplementation* implementation;
bool result = false;
bool OK = true;
-// For debugging***** printf("\n testDOMImplementation's outputs:\n");
- implementation = document.getImplementation(); //Uses getDOMImplementation to obtain implementation
+// For debugging***** printf("\n testIDOMImplementation's outputs:\n");
+ implementation = document->getImplementation(); //Uses getIDOMImplementation to obtain implementation
- result = implementation.hasFeature("XML", "1.0");
+ XMLString::transcode("XML", tempStr, 3999);
+ XMLString::transcode("1.0", tempStr2, 3999);
+ result = implementation->hasFeature(tempStr, tempStr2);
if(!result)
{
- fprintf(stderr, "Warning!!! DOM_DOMImplementation's 'hasFeature' that should be 'true' failed!");
+ fprintf(stderr, "Warning!!! IDOM_IDOMImplementation's 'hasFeature' that should be 'true' failed!");
OK = false;
}
- result = implementation.hasFeature("HTML", "4.0");
+ XMLString::transcode("HTML", tempStr, 3999);
+ XMLString::transcode("4.0", tempStr2, 3999);
+ result = implementation->hasFeature(tempStr, tempStr2);
if(result)
{
- fprintf(stderr, "Warning!!! DOM_DOMImplementation's 'hasFeature' that should be 'false' failed!");
+ fprintf(stderr, "Warning!!! IDOM_IDOMImplementation's 'hasFeature' that should be 'false' failed!");
OK = false;
}
-// For debugging***** printf("All DOM_DOMImplementation method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_IDOMImplementation method calls worked correctly.\n");
if (!OK)
- fprintf(stderr, "\n*****The DOM_DOMImplementation method calls listed above failed, all others worked correctly.*****\n");
+ fprintf(stderr, "\n*****The IDOM_IDOMImplementation method calls listed above failed, all others worked correctly.*****\n");
// printf("");
+ return OK;
};
/**
- * This method tests DOM_Element methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_Element* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testElement(DOM_Document document)
+bool IDTest::testElement(IDOM_Document* document)
{
- DOM_Attr attributeNode, newAttributeNode;
- DOM_Element element, element2;
- DOM_Node node, node2;
- DOMString attribute, compare;
- DOMString attributeCompare[] = {"AnotherFirstElementAttribute", "dFirstElement", "testAttribute"};
- DOMString elementNames[] = {"dFirstElement", "dTestBody", "dBodyLevel21","dBodyLevel31","dBodyLevel32",
+ IDOM_Attr* attributeNode, *newAttributeNode;
+ IDOM_Element* element, *element2;
+ IDOM_Node* node, *node2;
+
+ const char* attributeCompare[] = {"AnotherFirstElementAttribute", "dFirstElement", "testAttribute"};
+ const char* elementNames[] = {"dFirstElement", "dTestBody", "dBodyLevel21","dBodyLevel31","dBodyLevel32",
"dBodyLevel22","dBodyLevel33","dBodyLevel34","dBodyLevel23","dBodyLevel24"};
- DOMString textCompare[] = {"dBodyLevel31'sChildTextNode11",
+ const char* textCompare[] = {"dBodyLevel31'sChildTextNode11",
"dBodyLevel31'sChildTextNode12",
"dBodyLevel31'sChildTextNode13"};
- DOM_NamedNodeMap nodeMap;
+
+ IDOM_NamedNodeMap* nodeMap;
bool OK = true;
// For debugging***** printf("\n testElement's outputs:\n");
- node = document.getDocumentElement(); // node gets doc's firstElement
- node2 = node.cloneNode(true);
+ node = document->getDocumentElement(); // node gets doc's firstElement
+ node2 = node->cloneNode(true);
// Check nodes for equality, both their name and value or lack thereof
- if (!(node.getNodeName().equals(node2.getNodeName()) && // Compares node names for equality
- (node.getNodeValue() != null && node2.getNodeValue() != null) // Checks to make sure each node has a value node
- ? node.getNodeValue().equals(node2.getNodeValue()) // If both have value nodes test those value nodes for equality
- :(node.getNodeValue() == null && node2.getNodeValue() == null)))// If one node doesn't have a value node make sure both don't
+ if (!(!XMLString::compareString(node->getNodeName(), node2->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && node2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(node->getNodeValue(), node2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && node2->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
{
- fprintf(stderr, "'cloneNode' did not clone the DOM_Element node correctly.\n");
+ fprintf(stderr, "'cloneNode' did not clone the IDOM_Element* node correctly.\n");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
- element = document.getDocumentElement(); // element gets doc's firstElement
- compare = "";
- attribute = element.getAttribute(document.getNodeValue() + "'s test attribute");
- if (! compare.equals(element.getAttribute(document.getNodeValue() + "'s test attribute")))
+ element = document->getDocumentElement(); // element gets doc's firstElement
+
+ XMLString::copyString(tempStr, document->getNodeValue());
+ XMLString::transcode("'s test attribute", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ if (XMLString::compareString(XMLUni::fgZeroLenString, element->getAttribute(tempStr)))
{
- fprintf(stderr, "Warning!!! DOM_Element's 'getAttribute' failed!\n");
+ fprintf(stderr, "Warning!!! IDOM_Element's 'getAttribute' failed!\n");
OK = false;
}
- attributeNode = element.getAttributeNode(document.getNodeValue() + "FirstElement");
- if(! (attributeNode == null))
+ XMLString::copyString(tempStr, document->getNodeValue());
+ XMLString::transcode("FirstElement", tempStr2, 3999);
+ XMLString::catString(tempStr, tempStr2);
+ attributeNode = element->getAttributeNode(tempStr);
+ if(! (attributeNode == 0))
{
- fprintf(stderr, "Warning!!! DOM_Element's 'getAttributeNode' failed! It should have returned 'null' here!\n");
+ fprintf(stderr, "Warning!!! IDOM_Element's 'getAttributeNode' failed! It should have returned '0' here!\n");
OK = false;
}
- newAttributeNode = document.createAttribute("AnotherFirstElementAttribute");
- newAttributeNode.setValue("A new attribute which helps test calls in DOM_Element");
+ XMLString::transcode("AnotherFirstElementAttribute", tempStr, 3999);
+ newAttributeNode = document->createAttribute(tempStr);
+
+ XMLString::transcode("A new attribute which helps test calls in IDOM_Element", tempStr, 3999);
+ newAttributeNode->setValue(tempStr);
// This test is incorrect. It assumes that there is a defined ordering of the entries
// in a nodeMap, but there is no ordering required.
#ifdef TheFollowingCheckIsInvalid
- element.setAttributeNode(newAttributeNode);
- nodeMap = element.getAttributes();
- int size = nodeMap.getLength();
+ element->setAttributeNode(newAttributeNode);
+ nodeMap = element->getAttributes();
+ int size = nodeMap->getLength();
int k;
for (k = 0; k < size; k++)
{
- DOM_Node n = (DOM_Node) nodeMap.item(k);
- if (! (attributeCompare[k].equals(n.getNodeName())))
+ IDOM_Node* n = (IDOM_Node) nodeMap->item(k);
+ XMLString::transcode(attributeCompare[k], tempStr, 3999);
+ if (XMLString::compareString(tempStr, n->getNodeName())))
{
- printf("Warning!!! Comparison of firstElement's attributes failed.\n");
- printf(" n.getNodeName() = \""); n.getNodeValue().print(); printf("\"\n");
- printf(" expected value = \""); attributeCompare[k].print(); printf("\"\n");
- printf(" This failure can be a result of DOM_Element's 'setValue' and/or 'setAttributeNode' and/or 'getAttributes' failing.\n");
+ printf("Warning!!! Comparison of firstElement's attributes failed at line %i.\n", __LINE__);
+ printf(" This failure can be a result of IDOM_Element's 'setValue' and/or 'setAttributeNode' and/or 'getAttributes' failing.\n");
OK = false;
break;
}
- // printf("firstElement's attribute number " + k + " : " + n.getNodeName());
+ // printf("firstElement's attribute number " + k + " : " + n->getNodeName());
}
#endif
- nodeMap = element.getAttributes();
- int size = nodeMap.getLength();
+ nodeMap = element->getAttributes();
+ int size = nodeMap->getLength();
if (size != 2)
{
- printf("DOM_Element Tests Failure 001\n");
+ printf("IDOM_Element* Tests Failure 001\n");
OK = false;
};
- element.setAttributeNode(newAttributeNode);
- size = nodeMap.getLength();
+ element->setAttributeNode(newAttributeNode);
+ size = nodeMap->getLength();
if (size != 3)
{
- printf("DOM_Element Tests Failure 002\n");
+ printf("IDOM_Element* Tests Failure 002\n");
OK = false;
};
// Fetch the newly added attribute node back out of from the named node map,
- // and check that we are returned the same node that we put in.
- DOM_Node abc12 = nodeMap.getNamedItem("AnotherFirstElementAttribute");
- DOM_Attr fetchedAttr = (DOM_Attr &) abc12;
+ // and check that we are returned the same node that we put in->
+ XMLString::transcode("AnotherFirstElementAttribute", tempStr, 3999);
+ IDOM_Node* abc12 = nodeMap->getNamedItem(tempStr);
+ IDOM_Attr* fetchedAttr = (IDOM_Attr*) abc12;
if (fetchedAttr != newAttributeNode)
{
- printf("DOM_Element Tests Failure 003\n");
+ printf("IDOM_Element* Tests Failure 003\n");
OK = false;
};
// Fetch the newly added attribute back out directly from the element itself.
- fetchedAttr = element.getAttributeNode("AnotherFirstElementAttribute");
+ XMLString::transcode("AnotherFirstElementAttribute", tempStr, 3999);
+ fetchedAttr = element->getAttributeNode(tempStr);
if (fetchedAttr != newAttributeNode)
{
- printf("DOM_Element Tests Failure 004\n");
+ printf("IDOM_Element* Tests Failure 004\n");
OK = false;
};
- DOM_NodeList docElements = document.getElementsByTagName("*");
- int docSize = docElements.getLength();
+ XMLString::transcode("*",tempStr, 3999);
+ IDOM_NodeList* docElements = document->getElementsByTagName(tempStr);
+ int docSize = docElements->getLength();
int i;
for (i = 0; i < docSize; i++)
{
- DOM_Node n = docElements.item(i);
- if (! (elementNames[i].equals(n.getNodeName())))
+ IDOM_Node* n = docElements->item(i);
+ XMLString::transcode(elementNames[i], tempStr, 3999);
+ if (XMLString::compareString(tempStr, n->getNodeName()))
{
- printf("Warning!!! Comparison of DOM_Element's 'getElementsByTagName' "
- "and/or 'item' failed at element number %d : ", i );
- n.getNodeName().print();
+ printf("Warning!!! Comparison of IDOM_Element's 'getElementsByTagName' "
+ "and/or 'item' failed at element number %d at line %i \n", i, __LINE__ );
printf("\n");
OK = false;
break;
}
- // printf("docElement's number " + i + " is: " + n.getNodeName());
+ // printf("docElement's number " + i + " is: " + n->getNodeName());
}
- DOM_Node abc15 = document.getElementsByTagName("dBodyLevel21").item(0); // element gets DOM_Element test BodyLevel21
- element = (DOM_Element &) abc15;
-
- DOM_Node abc16 = document.getElementsByTagName("dBodyLevel31").item(0); // element2 gets DOM_Element test BodyLevel31
- element2 = (DOM_Element &) abc16;
- DOM_NodeList text = ((DOM_Node &) element2).getChildNodes();
- int textSize = text.getLength();
+ XMLString::transcode("dBodyLevel21", tempStr, 3999);
+ IDOM_Node* abc15 = document->getElementsByTagName(tempStr)->item(0); // element gets IDOM_Element* test BodyLevel21
+ element = (IDOM_Element*) abc15;
+
+ XMLString::transcode("dBodyLevel31", tempStr, 3999);
+ IDOM_Node* abc16 = document->getElementsByTagName(tempStr)->item(0); // element2 gets IDOM_Element* test BodyLevel31
+ element2 = (IDOM_Element*) abc16;
+ IDOM_NodeList* text = ((IDOM_Node* &) element2)->getChildNodes();
+ int textSize = text->getLength();
int j;
static bool firstTime = true;
if (firstTime)
@@ -1565,136 +1543,138 @@
// this test to fail on all but the first time through.
for (j = 0; j < textSize; j++)
{
- DOM_Node n = text.item(j);
- if (! (textCompare[j].equals(n.getNodeValue())))
+ IDOM_Node* n = text->item(j);
+ XMLString::transcode(textCompare[j], tempStr, 3999);
+ if (XMLString::compareString(tempStr, n->getNodeValue()))
{
- printf("Warning!!! Comparison of original text nodes via DOM_Node 'getChildNodes' & DOM_NodeList 'item'\n"
- " failed at text node: #%d \n ", j );
- n.getNodeValue().print();
- printf("\n");
+ printf("Warning!!! Comparison of original text nodes via IDOM_Node* 'getChildNodes' & IDOM_NodeList 'item'\n"
+ " failed at text node: #%d at line %i \n ", j, __LINE__ );
OK = false;
break;
}
- // printf("DOM_Element testBodyLevel31's child text node " + j + " is: " + n.getNodeValue());
+ // printf("IDOM_Element* testBodyLevel31's child text node " + j + " is: " + n->getNodeValue());
}
}
- element = document.getDocumentElement(); // element gets doc's firstElement
- element.normalize(); // Concatenates all adjacent text nodes in this element's subtree
- DOM_NodeList text2 = ((DOM_Node) element2).getChildNodes();
- compare = "dBodyLevel31'sChildTextNode11dBodyLevel31'sChildTextNode12dBodyLevel31'sChildTextNode13";
- DOM_Node n = text2.item(0);
- if (! (compare.equals(n.getNodeValue())))
+ element = document->getDocumentElement(); // element gets doc's firstElement
+ element->normalize(); // Concatenates all adjacent text nodes in this element's subtree
+ IDOM_NodeList* text2 = ((IDOM_Node*) element2)->getChildNodes();
+ XMLString::transcode("dBodyLevel31'sChildTextNode11dBodyLevel31'sChildTextNode12dBodyLevel31'sChildTextNode13", tempStr, 3999);
+ IDOM_Node* n = text2->item(0);
+ if (XMLString::compareString(tempStr, n->getNodeValue()))
{
- printf("Warning!!! Comparison of concatenated text nodes created by DOM_Element's 'normalize' failed!\n");
+ printf("Warning!!! Comparison of concatenated text nodes created by IDOM_Element's 'normalize' failed!\n");
OK = false;
}
- element.setAttribute("FirstElementLastAttribute", "More attribute stuff for firstElement!!");
- element.removeAttribute("FirstElementLastAttribute");
- element.removeAttributeNode(newAttributeNode);
+ XMLString::transcode("FirstElementLastAttribute", tempStr, 3999);
+ XMLString::transcode("More attribute stuff for firstElement!!", tempStr2, 3999);
+ element->setAttribute(tempStr, tempStr2);
+
+ XMLString::transcode("FirstElementLastAttribute", tempStr, 3999);
+ element->removeAttribute(tempStr);
+ element->removeAttributeNode(newAttributeNode);
- // doc.getLastChild().setNodeValue("This shouldn't work");//!! Throws a NO_MODIFICATION_ALLOWED_ERR***
+ // doc->getLastChild()->setNodeValue("This shouldn't work");//!! Throws a NO_MODIFICATION_ALLOWED_ERR***
-// For debugging***** printf("All DOM_Element method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_Element* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_Element method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_Element* method calls listed above failed, all others worked correctly.*****\n");
// printf("");
-
+ return OK;
};
/**
- * This method tests DOM_Entity methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_Entity* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testEntity(DOM_Document document)
+bool IDTest::testEntity(IDOM_Document* document)
{
- DOM_Entity entity;
- DOM_Node node, node2;
+ IDOM_Entity* entity;
+ IDOM_Node* node, *node2;
bool OK = true;
- DOMString compare;
// For debugging***** printf("\n testEntity's outputs:\n\n");
- DOM_Node abc20 = document.getDoctype().getEntities().getNamedItem("ourEntityNode");
- entity = (DOM_Entity &) abc20;
+ XMLString::transcode("ourEntityNode", tempStr, 3999);
+ IDOM_Node* abc20 = document->getDoctype()->getEntities()->getNamedItem(tempStr);
+ entity = (IDOM_Entity*) abc20;
node = entity;
- node2 = entity.cloneNode(true);
+ node2 = entity->cloneNode(true);
// Check nodes for equality, both their name and value or lack thereof
- if (!(node.getNodeName().equals(node2.getNodeName()) && // Compares node names for equality
- ((node.getNodeValue() != null && node2.getNodeValue() != null) ? // Checks to make sure each node has a value node
- node.getNodeValue().equals(node2.getNodeValue()) : // If both have value nodes test those value nodes for equality
- (node.getNodeValue() == null && node2.getNodeValue() == null)))) // If one node doesn't have a value node make sure both don't
+ if (!(!XMLString::compareString(node->getNodeName(), node2->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && node2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(node->getNodeValue(), node2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && node2->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
{
- printf("Warning!!! 'cloneNode' did not clone the DOM_Entity node correctly");
+ fprintf(stderr, "'cloneNode' did not clone the IDOM_Entity* node correctly");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
-// For debugging***** printf("All DOM_Entity method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_Entity* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_Entity method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_Entity* method calls listed above failed, all others worked correctly.*****\n");
// printf("");
+ return OK;
};
/**
- * This method tests DOM_EntityReference methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_EntityReference* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testEntityReference(DOM_Document document)
+bool IDTest::testEntityReference(IDOM_Document* document)
{
- DOM_EntityReference entityReference;
- DOM_Node node, node2;
+ IDOM_EntityReference* entityReference;
+ IDOM_Node* node, *node2;
bool OK = true;
// For debugging***** printf("\n testEntityReference's outputs:\n");
- DOM_Node abc30 = document.getLastChild().getLastChild().getLastChild().getFirstChild();
- entityReference = (DOM_EntityReference &) abc30;
+ IDOM_Node* abc30 = document->getLastChild()->getLastChild()->getLastChild()->getFirstChild();
+ entityReference = (IDOM_EntityReference*) abc30;
node = entityReference;
- node2 = node.cloneNode(true);
+ node2 = node->cloneNode(true);
// Check nodes for equality, both their name and value or lack thereof
- if (!(node.getNodeName().equals(node2.getNodeName()) && // Compares node names for equality
- (node.getNodeValue() != null && node2.getNodeValue() != null) // Checks to make sure each node has a value node
- ? node.getNodeValue().equals(node2.getNodeValue()) // If both have value nodes test those value nodes for equality
- :(node.getNodeValue() == null && node2.getNodeValue() == null)))// If one node doesn't have a value node make sure both don't
+ if (!(!XMLString::compareString(node->getNodeName(), node2->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && node2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(node->getNodeValue(), node2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && node2->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
{
- printf("'cloneNode' did not clone the DOM_EntityReference node correctly\n");
+ fprintf(stderr, "'cloneNode' did not clone the IDOM_EntityReference* node correctly\n");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
- // entityReference.setNodeValue("This shouldn't work");//!! Throws a NO_MODIFICATION_ALLOWED_ERR ********
+ // entityReference->setNodeValue("This shouldn't work");//!! Throws a NO_MODIFICATION_ALLOWED_ERR ********
-// For debugging***** printf("All DOM_EntityReference method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_EntityReference* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_EntityReference method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_EntityReference* method calls listed above failed, all others worked correctly.*****\n");
// printf("\n");
+ return OK;
};
/**
- * This method tests DOM_Node methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_Node* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*
*
********* This is only for a test of cloneNode "deep"*******
********* And for error tests*********
*/
-void DTest::testNode(DOM_Document document)
+bool IDTest::testNode(IDOM_Document* document)
{
- DOM_Node node, node2;
+ IDOM_Node* node, *node2;
bool result;
bool OK = true;
// For debugging***** printf("\n testNode's outputs:\n");
- node = document.getDocumentElement();
- node2 = node.cloneNode(true);
+ node = document->getDocumentElement();
+ node2 = node->cloneNode(true);
result = treeCompare(node, node2); // Deep clone test of cloneNode
if (result)
{
@@ -1706,8 +1686,8 @@
OK = false;
}
//!! The following gives a did not clone successfully message*********
- node = document.getDocumentElement();
- node2 = node.getFirstChild();
+ node = document->getDocumentElement();
+ node2 = node->getFirstChild();
result = treeCompare(node, node2);
if (!result)
{
@@ -1720,97 +1700,95 @@
}
// Deep clone test also in testDocument
-// For debugging***** printf("All DOM_Node method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_Node* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_Node method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_Node* method calls listed above failed, all others worked correctly.*****\n");
// printf("\n");
+ return OK;
};
/**
- * This method tests DOM_Notation methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_Notation* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testNotation(DOM_Document document)
+bool IDTest::testNotation(IDOM_Document* document)
{
- DOM_Node node, node2;
- DOM_Notation notation;
+ IDOM_Node* node, *node2;
+ IDOM_Notation* notation;
bool OK = true;
- DOMString compare;
// For debugging***** printf("\n testNotation's outputs:\n");
- DOM_Node abc40 = document.getDoctype().getNotations().getNamedItem("ourNotationNode");
- notation = (DOM_Notation &) abc40;
+ XMLString::transcode("ourNotationNode", tempStr, 3999);
+ IDOM_Node* abc40 = document->getDoctype()->getNotations()->getNamedItem(tempStr);
+ notation = (IDOM_Notation*) abc40;
node = notation;
- node2 = notation.cloneNode(true);//*****?
+ node2 = notation->cloneNode(true);//*****?
// Check nodes for equality, both their name and value or lack thereof
- if (!(node.getNodeName().equals(node2.getNodeName()) && // Compares node names for equality
- (node.getNodeValue() != null && node2.getNodeValue() != null) // Checks to make sure each node has a value node
- ? node.getNodeValue().equals(node2.getNodeValue()) // If both have value nodes test those value nodes for equality
- :(node.getNodeValue() == null && node2.getNodeValue() == null)))// If one node doesn't have a value node make sure both don't
+ if (!(!XMLString::compareString(node->getNodeName(), node2->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && node2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(node->getNodeValue(), node2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && node2->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
{
- printf("'cloneNode' did not clone the DOM_Notation node correctly");
+ fprintf(stderr, "'cloneNode' did not clone the IDOM_Notation* node correctly");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
- // notation.setNodeValue("This shouldn't work");//!! Throws a NO_MODIFICATION_ALLOWED_ERR ********
+ // notation->setNodeValue("This shouldn't work");//!! Throws a NO_MODIFICATION_ALLOWED_ERR ********
-// For debugging***** printf("All DOM_Notation method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_Notation* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_Notation method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_Notation* method calls listed above failed, all others worked correctly.*****\n");
// printf("");
+ return OK;
};
/**
- * This method tests DOM_ProcessingInstruction methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_ProcessingInstruction* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testPI(DOM_Document document)
+bool IDTest::testPI(IDOM_Document* document)
{
- DOM_Node node, node2;
- DOM_ProcessingInstruction pI, pI2;
- DOMString compare;
+ IDOM_ProcessingInstruction* pI, *pI2;
bool OK = true;
// For debugging***** printf("\n testPI's outputs:\n");
- DOM_Node abc50 = document.getDocumentElement().getFirstChild();// Get doc's DOM_ProcessingInstruction
- pI = (DOM_ProcessingInstruction &) abc50;
- DOM_Node abc51 = pI.cloneNode(true);//*****?
- pI2 = (DOM_ProcessingInstruction &) abc51;
+ IDOM_Node* abc50 = document->getDocumentElement()->getFirstChild();// Get doc's IDOM_ProcessingInstruction
+ pI = (IDOM_ProcessingInstruction*) abc50;
+ IDOM_Node* abc51 = pI->cloneNode(true);//*****?
+ pI2 = (IDOM_ProcessingInstruction*) abc51;
// Check nodes for equality, both their name and value or lack thereof
- if (!(pI.getNodeName().equals(pI2.getNodeName()) && // Compares node names for equality
- (pI.getNodeValue() != null && pI2.getNodeValue() != null) // Checks to make sure each node has a value node
- ? pI.getNodeValue().equals(pI2.getNodeValue()) // If both have value nodes test those value nodes for equality
- :(pI.getNodeValue() == null && pI2.getNodeValue() == null)))// If one node doesn't have a value node make sure both don't
+ if (!(!XMLString::compareString(pI->getNodeName(), pI2->getNodeName()) && // Compares node names for equality
+ (pI->getNodeValue() != 0 && pI2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(pI->getNodeValue(), pI2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ :(pI->getNodeValue() == 0 && pI2->getNodeValue() == 0)))// If one node doesn't have a value node make sure both don't
{
- printf("'cloneNode' did not clone the DOM_Entity node correctly\n");
+ printf("'cloneNode' did not clone the IDOM_Entity* node correctly\n");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
- // compare = "This is [#document: null]'s processing instruction"; // AH Revisit. Where id
- // this ": null]" stuff come from in the Java version?? I don' think that it is right.
- compare = "This is #document's processing instruction";
- if (! compare.equals(pI.getData()))
+ // compare = "This is [#document: 0]'s processing instruction"; // AH Revisit. Where id
+ // this ": 0]" stuff come from in the Java version?? I don' think that it is right.
+ XMLString::transcode("This is #document's processing instruction", tempStr, 3999);
+ if (XMLString::compareString(tempStr, pI->getData()))
{
printf("Warning!!! PI's 'getData' failed!\n");
OK = false;
}
- pI.setData("PI's reset data");
- compare = "PI's reset data";
- if (! compare.equals(pI.getData()))
+ XMLString::transcode("PI's reset data", tempStr, 3999);
+ pI->setData(tempStr);
+ if (XMLString::compareString(tempStr, pI->getData()))
{
printf("Warning!!! PI's 'setData' failed!\n");
OK = false;
}
- compare = "dTargetProcessorChannel";
- if (! compare.equals(pI.getTarget()))
+ XMLString::transcode("dTargetProcessorChannel", tempStr, 3999);
+ if (XMLString::compareString(tempStr, pI->getTarget()))
{
printf("Warning!!! PI's 'getTarget' failed!\n");
OK = false;
@@ -1818,77 +1796,79 @@
// Restore original PI data.
- pI.setData("This is #document's processing instruction");
+ XMLString::transcode("This is #document's processing instruction", tempStr, 3999);
+ pI->setData(tempStr);
// For debugging***** printf("All PI method calls worked correctly.\n");
if (!OK)
printf("\n*****The PI method calls listed above failed, all others worked correctly.*****\n");
// printf("\n");
+ return OK;
};
/**
- * This method tests DOM_Text methods for the XML DOM implementation
- * version 2.0 10/12/98
- * @param document org.w3c.dom.DOM_Document
+ * This method tests IDOM_Text* methods for the XML IDOM implementation
+ * @param document org.w3c.dom.IDOM_Document
*
*/
-void DTest::testText(DOM_Document document)
+bool IDTest::testText(IDOM_Document* document)
{
- DOM_Node node, node2;
- DOM_Text text;
- DOMString compare;
+ IDOM_Node* node, *node2;
+ IDOM_Text* text;
bool OK = true;
// For debugging***** printf("\n testText's outputs:\n");
- DOM_Node abc70 = document.getDocumentElement().getElementsByTagName("dBodyLevel31").item(0);
- DOM_Element elem = (DOM_Element &) abc70;
- node = elem.getFirstChild(); // charData gets textNode11
- text = (DOM_Text &) node;
- node2 = node.cloneNode(true);//*****?
+ XMLString::transcode("dBodyLevel31", tempStr, 3999);
+ IDOM_Node* abc70 = document->getDocumentElement()->getElementsByTagName(tempStr)->item(0);
+ IDOM_Element* elem = (IDOM_Element*) abc70;
+ node = elem->getFirstChild(); // charData gets textNode11
+ text = (IDOM_Text*) node;
+ node2 = node->cloneNode(true);//*****?
// Check nodes for equality, both their name and value or lack thereof
- if (!(node.getNodeName().equals(node2.getNodeName()) && // Compares node names for equality
- (node.getNodeValue() != null && node2.getNodeValue() != null) // Checks to make sure each node has a value node
- ? node.getNodeValue().equals(node2.getNodeValue()) // If both have value nodes test those value nodes for equality
- :(node.getNodeValue() == null && node2.getNodeValue() == null)))// If one node doesn't have a value node make sure both don't
+ if (!(!XMLString::compareString(node->getNodeName(), node2->getNodeName()) && // Compares node names for equality
+ (node->getNodeValue() != 0 && node2->getNodeValue() != 0) // Checks to make sure each node has a value node
+ ? !XMLString::compareString(node->getNodeValue(), node2->getNodeValue()) // If both have value nodes test those value nodes for equality
+ : (node->getNodeValue() == 0 && node2->getNodeValue() == 0))) // If one node doesn't have a value node make sure both don't
{
- printf("'cloneNode' did not clone the DOM_Text node correctly\n");
+ fprintf(stderr, "'cloneNode' did not clone the IDOM_Text* node correctly\n");
OK = false;
}
// Deep clone test comparison is in testNode & testDocument
- text.splitText(25);
+ text->splitText(25);
// Three original text nodes were concatenated by 'normalize' in testElement
- compare = "dBodyLevel31'sChildTextNo";
- if (! compare.equals(text.getNodeValue()))
+ XMLString::transcode("dBodyLevel31'sChildTextNo", tempStr, 3999);
+ if (XMLString::compareString(tempStr, text->getNodeValue()))
{
- printf("First part of DOM_Text's split text failed!\n" );
+ printf("First part of IDOM_Text's split text failed!\n" );
OK = false;
}
// Three original text nodes were concatenated by 'normalize' in testElement
- compare = "de11dBodyLevel31'sChildTextNode12dBodyLevel31'sChildTextNode13";
- if (! compare.equals(text.getNextSibling().getNodeValue()))
+ XMLString::transcode("de11dBodyLevel31'sChildTextNode12dBodyLevel31'sChildTextNode13", tempStr, 3999);
+ if (XMLString::compareString(tempStr, text->getNextSibling()->getNodeValue()))
{
- printf("The second part of DOM_Text's split text failed!\n") ;
+ printf("The second part of IDOM_Text's split text failed!\n") ;
OK = false;
}
- // Re-normalize the text nodes under elem, so that this test can be rerun.
- elem.normalize();
+ // Re-normalize the text nodes under elem, so that this test can be rerun->
+ elem->normalize();
//************************************************* ERROR TESTS
- DTest tests;
+ IDTest tests;
//!! Throws INDEX_SIZE_ERR ********************
// text.splitText(-1);
// text.splitText(100);
-// For debugging***** printf("All DOM_Text method calls worked correctly.\n");
+// For debugging***** printf("All IDOM_Text* method calls worked correctly.\n");
if (!OK)
- printf("\n*****The DOM_Text method calls listed above failed, all others worked correctly.*****\n");
+ printf("\n*****The IDOM_Text* method calls listed above failed, all others worked correctly.*****\n");
// printf("\n");
+ return OK;
};
@@ -1896,55 +1876,55 @@
/**
*
- * @param node org.w3c.dom.DOM_Node
- * @param node2 org.w3c.dom.DOM_Node
+ * @param node org.w3c.dom.IDOM_Node
+ * @param node2 org.w3c.dom.IDOM_Node
*
*/
-bool DTest::treeCompare(DOM_Node node, DOM_Node node2)
+bool IDTest::treeCompare(IDOM_Node* node, IDOM_Node* node2)
{
bool answer = true;
- DOM_Node kid, kid2; // Check the subtree for equality
- kid = node.getFirstChild();
- kid2 = node2.getFirstChild();
- if (!kid.isNull() && !kid2.isNull())
+ IDOM_Node* kid, *kid2; // Check the subtree for equality
+ kid = node->getFirstChild();
+ kid2 = node2->getFirstChild();
+ if (kid && kid2)
{
answer = treeCompare(kid, kid2);
if (!answer)
return answer;
else
- if (!kid.getNextSibling().isNull() && !kid2.getNextSibling().isNull())
+ if (kid->getNextSibling() && kid2->getNextSibling())
{
- while (!kid.getNextSibling().isNull() && !kid2.getNextSibling().isNull())
+ while (kid->getNextSibling() && kid2->getNextSibling())
{
- answer = treeCompare(kid.getNextSibling(), kid2.getNextSibling());
+ answer = treeCompare(kid->getNextSibling(), kid2->getNextSibling());
if (!answer)
return answer;
else
{
- kid = kid.getNextSibling();
- kid2 = kid2.getNextSibling();
+ kid = kid->getNextSibling();
+ kid2 = kid2->getNextSibling();
}
}
} else
- if (!(kid.getNextSibling().isNull() && kid2.getNextSibling().isNull()))
+ if (!(!kid->getNextSibling() && !kid2->getNextSibling()))
{
return false;
}
} else
if (kid != kid2)
{
- // One or the other of (kid1, kid2) is null, but not both.
+ // One or the other of (kid1, kid2) is 0, but not both.
return false;
}
- if (!(node.getNodeName().equals(node2.getNodeName())))
+ if (XMLString::compareString(node->getNodeName(), node2->getNodeName()))
return false;
- if (node.getNodeValue()==null && node2.getNodeValue()!=null)
+ if (node->getNodeValue()==0 && node2->getNodeValue()!=0)
return false;
- if (node.getNodeValue()!=null && node2.getNodeValue()==null)
+ if (node->getNodeValue()!=0 && node2->getNodeValue()==0)
return false;
- if (!(node.getNodeValue().equals(node2.getNodeValue())))
+ if (XMLString::compareString(node->getNodeValue(), node2->getNodeValue()))
return false;
return answer;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org