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/11/12 18:52:25 UTC
cvs commit: xml-xerces/c/tests/DOM/RangeTest RangeTest.cpp
tng 2002/11/12 09:52:25
Modified: c/tests/DOM/RangeTest RangeTest.cpp
Log:
Test update: do not issue "Test Run Successfully" if there was an error.
Revision Changes Path
1.13 +33 -8 xml-xerces/c/tests/DOM/RangeTest/RangeTest.cpp
Index: RangeTest.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/tests/DOM/RangeTest/RangeTest.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- RangeTest.cpp 5 Nov 2002 21:47:35 -0000 1.12
+++ RangeTest.cpp 12 Nov 2002 17:52:25 -0000 1.13
@@ -79,12 +79,16 @@
XERCES_CPP_NAMESPACE_USE
+bool errorOccurred = false;
+
#define TASSERT(c) tassert((c), __FILE__, __LINE__)
void tassert(bool c, const char *file, int line)
{
- if (!c)
+ if (!c) {
+ errorOccurred = true;
printf("Failure. Line %d, file %s\n", line, file);
+ }
};
@@ -93,14 +97,24 @@
try { \
operation; \
printf(" Error: no exception thrown at line %d\n", __LINE__); \
-} \
+ errorOccurred = true; \
+ } \
+ catch (DOMRangeException &e) { \
+ if (e.code != expected_exception) { \
+ printf(" Wrong RangeException code: %d at line %d\n", e.code, __LINE__); \
+ errorOccurred = true; \
+ } \
+ } \
catch (DOMException &e) { \
- if (e.code != expected_exception) \
- printf(" Wrong exception code: %d at line %d\n", e.code, __LINE__); \
-} \
+ if (e.code != expected_exception) { \
+ printf(" Wrong exception code: %d at line %d\n", e.code, __LINE__); \
+ errorOccurred = true; \
+ } \
+ } \
catch (...) { \
- printf(" Wrong exception thrown at line %d\n", __LINE__); \
-} \
+ printf(" Wrong exception thrown at line %d\n", __LINE__); \
+ errorOccurred = true; \
+ } \
}
//Define a bunch of XMLCh* string for comparison
XMLCh xa[] = {chLatin_a, chNull};
@@ -962,6 +976,12 @@
TASSERT(!XMLString::compareString(newtestrange->getEndContainer()->getNodeName(),xfoo));
TASSERT(!XMLString::compareString(newtestrange->toString(),xabHellocd));
+ // Now do some exception test
+ newrange->detach();
+ EXCEPTION_TEST(newrange->setStart( moo, 0 ), DOMException::INVALID_STATE_ERR);
+ EXCEPTION_TEST(newtestrange->setStartBefore(moo), DOMRangeException::INVALID_NODE_TYPE_ERR);
+
+
doc->release();
doc2->release();
doc3->release();
@@ -970,6 +990,11 @@
// And call the termination method
XMLPlatformUtils::Terminate();
+
+ if (errorOccurred) {
+ printf("Test Failed\n");
+ return 4;
+ }
printf("Test Run Successfully\n");
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org