[sword-svn] r2438 - trunk/tests

scribe at crosswire.org scribe at crosswire.org
Sun Aug 9 15:14:22 MST 2009


Author: scribe
Date: 2009-08-09 15:14:21 -0700 (Sun, 09 Aug 2009)
New Revision: 2438

Added:
   trunk/tests/striptest.cpp
Modified:
   trunk/tests/Makefile.am
Log:
added new test for assessment of our extended character set searching


Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am	2009-07-16 00:13:25 UTC (rev 2437)
+++ trunk/tests/Makefile.am	2009-08-09 22:14:21 UTC (rev 2438)
@@ -7,7 +7,7 @@
 noinst_PROGRAMS = ciphertest keytest mgrtest parsekey versekeytest vtreekeytest versemgrtest listtest casttest \
 modtest compnone complzss localetest introtest indextest configtest keycast \
 romantest testblocks filtertest rawldidxtest lextest swaptest \
- swbuftest xmltest webiftest
+ swbuftest xmltest webiftest striptest
 
 if ICU
 ICUPROG = icutest translittest tlitmgrtest
@@ -61,6 +61,7 @@
 swaptest_SOURCES = swaptest.cpp
 swbuftest_SOURCES = swbuftest.cpp
 webiftest_SOURCES = webiftest.cpp
+striptest_SOURCES = striptest.cpp
 xmltest_SOURCES = xmltest.cpp
 
 

Added: trunk/tests/striptest.cpp
===================================================================
--- trunk/tests/striptest.cpp	                        (rev 0)
+++ trunk/tests/striptest.cpp	2009-08-09 22:14:21 UTC (rev 2438)
@@ -0,0 +1,32 @@
+#include <swmgr.h>
+#include <swmodule.h>
+#include <iostream>
+
+using namespace sword;
+
+using std::cout;
+using std::endl;
+
+int main(int argc, char **argv) {
+
+	SWBuf modName = (argc > 1) ? argv[2] : "WLC";
+	SWBuf keyText = (argc > 2) ? argv[3] : "Gen.1.9";
+	SWBuf searchText = (argc > 3) ? argv[4] : "מתחת";
+	SWMgr library;
+	SWModule *book = library.getModule(modName);
+	StringList filters = library.getGlobalOptions();
+	for (StringList::iterator it = filters.begin(); it != filters.end(); ++it) {
+	    // blindly turn off all filters.  Some filters don't support "Off", but that's ok, we should just silently fail on those.
+	    library.setGlobalOption(*it, "Off");
+	}
+	book->setKey(keyText.c_str());
+	SWBuf entryStripped = book->StripText();
+	cout << "Module: " << book->Description() << "\t Key: " << book->getKeyText() << "\n";
+	cout << "RawEntry:\n" << book->getRawEntry() << "\n";
+	cout << "StripText:\n" << entryStripped << "\n";
+	cout << "Search Target: " << searchText << "\n";
+	cout << "Search Target StripText: " << book->StripText(searchText) << "\n";
+	cout << "Found: " << ((strstr(entryStripped.c_str(), book->StripText(searchText))) ? "true":"false") << endl; 
+
+	return 0;
+}




More information about the sword-cvs mailing list