[sword-svn] r2312 - in trunk: src/keys tests tests/testsuite

scribe at crosswire.org scribe at crosswire.org
Thu Apr 9 06:10:03 MST 2009


Author: scribe
Date: 2009-04-09 06:10:03 -0700 (Thu, 09 Apr 2009)
New Revision: 2312

Added:
   trunk/tests/testsuite/versekeytest.good
   trunk/tests/testsuite/versekeytest.sh
Removed:
   trunk/tests/testsuite/versekey.good
   trunk/tests/testsuite/versekey.sh
Modified:
   trunk/src/keys/versekey.cpp
   trunk/tests/versekeytest.cpp
Log:
Reverted recent ParseVerseKey fix for AutoNormalize(false)
Added test cases to capture the problem
Added test cases to cover all autonorm/heading combos



Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2009-04-09 07:10:50 UTC (rev 2311)
+++ trunk/src/keys/versekey.cpp	2009-04-09 13:10:03 UTC (rev 2312)
@@ -655,8 +655,10 @@
 							tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
 						}
 						else {
-							*lastKey = *curKey;
-							tmpListKey << *curKey;
+							lastKey->LowerBound(*curKey);
+							lastKey->UpperBound(*curKey);
+							*lastKey = TOP;
+							tmpListKey << *lastKey;
 							tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
 						}
 					}
@@ -860,8 +862,11 @@
 					tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
 				}
 				else {
-					*lastKey = *curKey;					
-					tmpListKey << *curKey;
+					lastKey->LowerBound(*curKey);
+					lastKey->UpperBound(*curKey);
+					*lastKey = TOP;
+					tmpListKey << *lastKey;
+//					tmpListKey << curKey->getText();
 					tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
 				}
 			}
@@ -1036,41 +1041,24 @@
 
 void VerseKey::setPosition(SW_POSITION p) {
 	switch (p) {
-	case POS_TOP: 
-		if (isBoundSet()) {
-			const VerseKey *lb = &LowerBound();
-			testament = lb->Testament();
-			book      = lb->Book();
-			chapter   = lb->Chapter();
-			verse     = lb->Verse();
-			suffix    = lb->getSuffix();
-		}
-		else {
-			Index(0);
-		}
+	case POS_TOP: {
+		const VerseKey *lb = &LowerBound();
+		testament = lb->Testament();
+		book      = lb->Book();
+		chapter   = lb->Chapter();
+		verse     = lb->Verse();
+		suffix    = lb->getSuffix();
 		break;
-	case POS_BOTTOM: 
-		if (isBoundSet()) {
-			const VerseKey *ub = &UpperBound();
-			testament = ub->Testament();
-			book      = ub->Book();
-			chapter   = ub->Chapter();
-			verse     = ub->Verse();
-			suffix    = ub->getSuffix();
-		}
-		else {
-			VerseKey t;
-			t.copyFrom(this);
-			t.AutoNormalize(0);
-			t.Headings(1);
-			t.Testament(2);
-			t.Book(BMAX[1]);
-			t.Chapter(t.getChapterMax());
-			t.Verse(t.getVerseMax());
-			Index(t.Index());
-			
-		}
+	}
+	case POS_BOTTOM: {
+		const VerseKey *ub = &UpperBound();
+		testament = ub->Testament();
+		book      = ub->Book();
+		chapter   = ub->Chapter();
+		verse     = ub->Verse();
+		suffix    = ub->getSuffix();
 		break;
+	}
 	case POS_MAXVERSE:
 		Normalize();
 		verse     = getVerseMax();

Deleted: trunk/tests/testsuite/versekey.good
===================================================================
--- trunk/tests/testsuite/versekey.good	2009-04-09 07:10:50 UTC (rev 2311)
+++ trunk/tests/testsuite/versekey.good	2009-04-09 13:10:03 UTC (rev 2312)
@@ -1,7 +0,0 @@
-x: Amos 1:5
-Amos 1:5
-Amos 1:5
-Error: 1: Luke 1:1
-Error: 1: Luke 1:1
-Error: 0: Acts 5:1
-Error: 1: Acts 28:31

Deleted: trunk/tests/testsuite/versekey.sh
===================================================================
--- trunk/tests/testsuite/versekey.sh	2009-04-09 07:10:50 UTC (rev 2311)
+++ trunk/tests/testsuite/versekey.sh	2009-04-09 13:10:03 UTC (rev 2312)
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-../versekeytest

Copied: trunk/tests/testsuite/versekeytest.good (from rev 2311, trunk/tests/testsuite/versekey.good)
===================================================================
--- trunk/tests/testsuite/versekeytest.good	                        (rev 0)
+++ trunk/tests/testsuite/versekeytest.good	2009-04-09 13:10:03 UTC (rev 2312)
@@ -0,0 +1,47 @@
+x: Amos 1:5
+Amos 1:5
+Amos 1:5
+Error: 1: Luke 1:1
+Error: 1: Luke 1:1
+Error: 0: Acts 5:1
+Error: 1: Acts 28:31
+
+Normalization on; headings on ====
+
+jn.3.50: John 4:13
+++: John 4:14
+--: John 4:13
+MAXVERSE: John 4:54
+MAXCHAPTER: John 21:1
+TOP: [ Module Heading ]
+BOTTOM: Revelation of John 22:21
+
+Normalization off; headings on ====
+
+jn.3.50: John 3:50
+++: John 3:51
+--: John 3:50
+MAXVERSE: John 3:36
+MAXCHAPTER: John 21:1
+TOP: [ Module Heading ]
+BOTTOM: Revelation of John 22:21
+
+Normalization on; headings off ====
+
+jn.3.50: John 4:14
+++: John 4:15
+--: John 4:14
+MAXVERSE: John 4:54
+MAXCHAPTER: John 21:1
+TOP: Genesis 1:1
+BOTTOM: Revelation of John 22:21
+
+Normalization off; headings off ====
+
+jn.3.50: John 3:50
+++: John 3:51
+--: John 3:50
+MAXVERSE: John 3:36
+MAXCHAPTER: John 21:1
+TOP: Genesis 1:1
+BOTTOM: Revelation of John 22:21


Property changes on: trunk/tests/testsuite/versekeytest.good
___________________________________________________________________
Added: svn:mergeinfo
   + 

Copied: trunk/tests/testsuite/versekeytest.sh (from rev 2311, trunk/tests/testsuite/versekey.sh)
===================================================================
--- trunk/tests/testsuite/versekeytest.sh	                        (rev 0)
+++ trunk/tests/testsuite/versekeytest.sh	2009-04-09 13:10:03 UTC (rev 2312)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+../versekeytest


Property changes on: trunk/tests/testsuite/versekeytest.sh
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mergeinfo
   + 

Modified: trunk/tests/versekeytest.cpp
===================================================================
--- trunk/tests/versekeytest.cpp	2009-04-09 07:10:50 UTC (rev 2311)
+++ trunk/tests/versekeytest.cpp	2009-04-09 13:10:03 UTC (rev 2312)
@@ -110,6 +110,88 @@
 	(*mod)--;
 	cout << mod->getKeyText() << "\n";
 */
+	VerseKey vk;
 
+	cout << "\nNormalization on; headings on ====\n\n";
+
+	vk.AutoNormalize(1);
+	vk.Headings(1);
+
+	vk = "jn3.50";
+	cout << "jn.3.50: " << vk << "\n";
+	vk++;
+	cout << "++: " << vk << "\n";
+	vk--;
+	cout << "--: " << vk << "\n";
+	vk = MAXVERSE;
+	cout << "MAXVERSE: " << vk << "\n";
+	vk = MAXCHAPTER;
+	cout << "MAXCHAPTER: " << vk << "\n";
+	vk = TOP;
+	cout << "TOP: " << vk << "\n";
+	vk = BOTTOM;
+	cout << "BOTTOM: " << vk << "\n";
+
+	cout << "\nNormalization off; headings on ====\n\n";
+	
+	vk.AutoNormalize(0);
+	vk.Headings(1);
+
+	vk = "jn3.50";
+	cout << "jn.3.50: " << vk << "\n";
+	vk++;
+	cout << "++: " << vk << "\n";
+	vk--;
+	cout << "--: " << vk << "\n";
+	vk = MAXVERSE;
+	cout << "MAXVERSE: " << vk << "\n";
+	vk = MAXCHAPTER;
+	cout << "MAXCHAPTER: " << vk << "\n";
+	vk = TOP;
+	cout << "TOP: " << vk << "\n";
+	vk = BOTTOM;
+	cout << "BOTTOM: " << vk << "\n";
+
+	cout << "\nNormalization on; headings off ====\n\n";
+	
+	vk.AutoNormalize(1);
+	vk.Headings(0);
+
+	vk = "jn3.50";
+	cout << "jn.3.50: " << vk << "\n";
+	vk++;
+	cout << "++: " << vk << "\n";
+	vk--;
+	cout << "--: " << vk << "\n";
+	vk = MAXVERSE;
+	cout << "MAXVERSE: " << vk << "\n";
+	vk = MAXCHAPTER;
+	cout << "MAXCHAPTER: " << vk << "\n";
+	vk = TOP;
+	cout << "TOP: " << vk << "\n";
+	vk = BOTTOM;
+	cout << "BOTTOM: " << vk << "\n";
+
+	cout << "\nNormalization off; headings off ====\n\n";
+	
+	vk.AutoNormalize(0);
+	vk.Headings(0);
+
+	vk = "jn3.50";
+	cout << "jn.3.50: " << vk << "\n";
+	vk++;
+	cout << "++: " << vk << "\n";
+	vk--;
+	cout << "--: " << vk << "\n";
+	vk = MAXVERSE;
+	cout << "MAXVERSE: " << vk << "\n";
+	vk = MAXCHAPTER;
+	cout << "MAXCHAPTER: " << vk << "\n";
+	vk = TOP;
+	cout << "TOP: " << vk << "\n";
+	vk = BOTTOM;
+	cout << "BOTTOM: " << vk << "\n";
+
+
 	return 0;
 }




More information about the sword-cvs mailing list