[sword-svn] r1938 - in trunk/tests: . testsuite

scribe at crosswire.org scribe at crosswire.org
Fri Jun 30 00:47:33 MST 2006


Author: scribe
Date: 2006-06-30 00:47:31 -0700 (Fri, 30 Jun 2006)
New Revision: 1938

Added:
   trunk/tests/testsuite/xmltag.good
   trunk/tests/testsuite/xmltag.sh
Modified:
   trunk/tests/xmltest.cpp
Log:
Added the start of a unit test for xmltag


Added: trunk/tests/testsuite/xmltag.good
===================================================================
--- trunk/tests/testsuite/xmltag.good	2006-06-30 07:21:40 UTC (rev 1937)
+++ trunk/tests/testsuite/xmltag.good	2006-06-30 07:47:31 UTC (rev 1938)
@@ -0,0 +1,128 @@
+<verse osisID="John.1.1" type='test type' yeah = "stuff" />
+<verse osisID="John.1.1" type="test type" yeah="stuff"/>
+<verse addedAttribute='with a " quote' osisID="John.1.1" type="test type" yeah="stuff"/>
+Tag name: [verse]
+ - attribute: [addedAttribute] = [with a " quote]
+	4 parts:
+	with
+	a
+	"
+	quote
+ - attribute: [osisID] = [John.1.1]
+	1 parts:
+	John.1.1
+ - attribute: [type] = [test type]
+	2 parts:
+	test
+	type
+ - attribute: [yeah] = [stuff]
+	1 parts:
+	stuff
+ isEmpty: 1
+ isEndTag: 0
+
+<yo mama='stuff' />
+<yo mama="stuff"/>
+<yo addedAttribute='with a " quote' mama="stuff"/>
+Tag name: [yo]
+ - attribute: [addedAttribute] = [with a " quote]
+	4 parts:
+	with
+	a
+	"
+	quote
+ - attribute: [mama] = [stuff]
+	1 parts:
+	stuff
+ isEmpty: 1
+ isEndTag: 0
+
+<yo mama='stuff'>
+<yo mama="stuff">
+<yo addedAttribute='with a " quote' mama="stuff">
+Tag name: [yo]
+ - attribute: [addedAttribute] = [with a " quote]
+	4 parts:
+	with
+	a
+	"
+	quote
+ - attribute: [mama] = [stuff]
+	1 parts:
+	stuff
+ isEmpty: 0
+ isEndTag: 0
+
+<yo mama = 'stuff'>
+<yo mama="stuff">
+<yo addedAttribute='with a " quote' mama="stuff">
+Tag name: [yo]
+ - attribute: [addedAttribute] = [with a " quote]
+	4 parts:
+	with
+	a
+	"
+	quote
+ - attribute: [mama] = [stuff]
+	1 parts:
+	stuff
+ isEmpty: 0
+ isEndTag: 0
+
+<yo mama = 'stuff' yoyoma="hohum">
+<yo mama="stuff" yoyoma="hohum">
+<yo addedAttribute='with a " quote' mama="stuff" yoyoma="hohum">
+Tag name: [yo]
+ - attribute: [addedAttribute] = [with a " quote]
+	4 parts:
+	with
+	a
+	"
+	quote
+ - attribute: [mama] = [stuff]
+	1 parts:
+	stuff
+ - attribute: [yoyoma] = [hohum]
+	1 parts:
+	hohum
+ isEmpty: 0
+ isEndTag: 0
+
+yo mama = 'stuff' yoyoma="hohum"
+<yo mama="stuff" yoyoma="hohum">
+<yo addedAttribute='with a " quote' mama="stuff" yoyoma="hohum">
+Tag name: [yo]
+ - attribute: [addedAttribute] = [with a " quote]
+	4 parts:
+	with
+	a
+	"
+	quote
+ - attribute: [mama] = [stuff]
+	1 parts:
+	stuff
+ - attribute: [yoyoma] = [hohum]
+	1 parts:
+	hohum
+ isEmpty: 0
+ isEndTag: 0
+
+yo mama = 'stuff' yoyoma="hohum"/
+<yo mama="stuff" yoyoma="hohum"/>
+<yo addedAttribute='with a " quote' mama="stuff" yoyoma="hohum"/>
+Tag name: [yo]
+ - attribute: [addedAttribute] = [with a " quote]
+	4 parts:
+	with
+	a
+	"
+	quote
+ - attribute: [mama] = [stuff]
+	1 parts:
+	stuff
+ - attribute: [yoyoma] = [hohum]
+	1 parts:
+	hohum
+ isEmpty: 1
+ isEndTag: 0
+

Added: trunk/tests/testsuite/xmltag.sh
===================================================================
--- trunk/tests/testsuite/xmltag.sh	2006-06-30 07:21:40 UTC (rev 1937)
+++ trunk/tests/testsuite/xmltag.sh	2006-06-30 07:47:31 UTC (rev 1938)
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Just let it run the default
+../xmltest
+
+#let's try some crazy stuff
+../xmltest "<yo mama='stuff' />"
+../xmltest "<yo mama='stuff'>"
+../xmltest "<yo mama = 'stuff'>"
+../xmltest "<yo mama = 'stuff' yoyoma=\"hohum\">"
+../xmltest "yo mama = 'stuff' yoyoma=\"hohum\""
+../xmltest "yo mama = 'stuff' yoyoma=\"hohum\"/"


Property changes on: trunk/tests/testsuite/xmltag.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/tests/xmltest.cpp
===================================================================
--- trunk/tests/xmltest.cpp	2006-06-30 07:21:40 UTC (rev 1937)
+++ trunk/tests/xmltest.cpp	2006-06-30 07:47:31 UTC (rev 1938)
@@ -5,10 +5,12 @@
 using namespace std;
 
 int main(int argc, char **argv) {
+
 	const char *xml = "<verse osisID=\"John.1.1\" type=\'test type\' yeah = \"stuff\" />";
 	cout << ((argc > 1) ? argv[1]: xml) << "\n";
+
 	XMLTag x((argc > 1) ? argv[1] : xml);
-//	x.setAttribute("newOne", "oneValue");
+
 	cout << x.toString() << "\n";
 	x.setAttribute("addedAttribute", "with a \" quote");
 	cout << x.toString() << "\n";
@@ -18,6 +20,13 @@
 		const char *name = it->c_str();
 		cout << " - attribute: [" << name << "] = [";
 		cout << x.getAttribute(name) << "]\n";
+		int count = x.getAttributePartCount(name, ' ');
+		cout << "\t" << count << " parts:\n";
+		int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
+		do {
+			cout << "\t" << x.getAttribute(name, i, ' ') << "\n";
+			if (i < 0) i = 0;	// to handle our -1 condition
+		} while (++i < count);
 	}
 	cout << " isEmpty: " << x.isEmpty() << "\n";
 	cout << " isEndTag: " << x.isEndTag() << "\n";



More information about the sword-cvs mailing list