summaryrefslogtreecommitdiff
path: root/tests/versekeytest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/versekeytest.cpp')
-rw-r--r--tests/versekeytest.cpp108
1 files changed, 74 insertions, 34 deletions
diff --git a/tests/versekeytest.cpp b/tests/versekeytest.cpp
index 02cfe75..4ae064e 100644
--- a/tests/versekeytest.cpp
+++ b/tests/versekeytest.cpp
@@ -1,5 +1,10 @@
-/*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+/******************************************************************************
+ *
+ * versekeytest.cpp -
+ *
+ * $Id: versekeytest.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -31,11 +36,46 @@ using namespace sword;
using std::cout;
using std::endl;
+class _System {
+public:
+class Out {
+public:
+ void println(const char *x) { cout << x << endl; }
+ void println(int x) { cout << x << endl; }
+} out;
+} System;
+
int main(int argc, char **argv) {
+ VerseKey vk;
+/*
+ vk.setTestament(2);
+ vk.setBook(4);
+ vk.setChapter(3);
+ vk.setVerse(1);
+ System.out.println(vk.getText());
+ System.out.println(vk.getIndex());
+ System.out.println(vk.getTestamentIndex());
+ vk.setVersificationSystem("KJVA");
+ System.out.println(vk.getText());
+ System.out.println(vk.getIndex());
+ System.out.println(vk.getTestamentIndex());
+ System.out.println("decrementing...");
+ vk.setVersificationSystem("KJV");
+ vk.decrement();
+ System.out.println(vk.getText());
+ System.out.println(vk.getIndex());
+ System.out.println(vk.getTestamentIndex());
+ vk.setVersificationSystem("KJVA");
+ System.out.println(vk.getText());
+ System.out.println(vk.getIndex());
+ System.out.println(vk.getTestamentIndex());
+*/
+
+
/*
VerseKey currentVerse;
-currentVerse.AutoNormalize(0);
-currentVerse.Headings(1);
+currentVerse.setAutoNormalize(true);
+currentVerse.setIntros(true);
currentVerse.Persist(1);
currentVerse = "jn2";
cout << currentVerse << endl;
@@ -44,18 +84,25 @@ cout << currentVerse << endl;
SWModule *mod = mgr.getModule("KJVgb");
*/
VerseKey *parser = new VerseKey(); //(VerseKey *)mod->CreateKey();
+ parser->setIntros(true);
- ListKey scope = parser->ParseVerseList("amos 2:2", *parser, true);
+ ListKey result = parser->parseVerseList("[ Testament 1 Heading ]");
+ cout << "Should be: [ Testament 1 Heading ]\n" << result << "\n\n";
- cout << ((scope++ == scope) ? "single" : "multiple") << "\n";
+ parser->setText("[ Testament 1 Heading ]");
+ cout << "Should be: [ Testament 1 Heading ]\n" << *parser << "\n\n";
- scope = parser->ParseVerseList("amos", *parser, true);
+ result.clear();
+
+ ListKey scope = parser->parseVerseList("amos 2:2", *parser, true);
cout << ((scope++ == scope) ? "single" : "multiple") << "\n";
- scope = parser->ParseVerseList("amos", *parser, true);
+ scope = parser->parseVerseList("amos", *parser, true);
+
+ cout << ((scope++ == scope) ? "single" : "multiple") << "\n";
- ListKey result;
+ scope = parser->parseVerseList("amos", *parser, true);
scope++;
scope++;
@@ -77,28 +124,28 @@ cout << currentVerse << endl;
std::cout << result.getText() << "\n";
const char *bounds = "lk,acts";
- scope = parser->ParseVerseList(bounds, *parser, true);
+ scope = parser->parseVerseList(bounds, *parser, true);
VerseKey boundTest("lk", "acts");
boundTest.setText("Is.1.13");
- std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
+ std::cout << "Error: " << (int)boundTest.popError() << ": " << boundTest << "\n";
boundTest.setText("1Sam.21.1");
- std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
+ std::cout << "Error: " << (int)boundTest.popError() << ": " << boundTest << "\n";
boundTest.setText("acts.5.1");
- std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
+ std::cout << "Error: " << (int)boundTest.popError() << ": " << boundTest << "\n";
boundTest.setText("rom.5.1");
- std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
+ std::cout << "Error: " << (int)boundTest.popError() << ": " << boundTest << "\n";
*x = "Is.1.13";
scope = *x;
-// if (scope == x) std::cout << "Error restricting bounds: " << x.getText() << " is in " << bounds << "\n";
- if (!scope.Error()) std::cout << "Error restricting bounds: " << x->getText() << " is in " << bounds << "\n";
+ if (scope == *x) std::cout << "Error restricting bounds: " << x->getText() << " is in " << bounds << "\n";
+ if (!scope.popError()) std::cout << "Error restricting bounds: " << x->getText() << " is in " << bounds << "\n";
*x = "1Sam.21.1";
scope = *x;
- if (!scope.Error()) std::cout << "Error restricting bounds: " << x->getText() << " is in " << bounds << "\n";
+ if (!scope.popError()) std::cout << "Error restricting bounds: " << x->getText() << " is in " << bounds << "\n";
/*
VerseKey *y = (VerseKey *)mod->CreateKey();
@@ -118,21 +165,18 @@ cout << currentVerse << endl;
(*mod)--;
cout << mod->getKeyText() << "\n";
*/
- VerseKey vk;
cout << "\nNormalization on; headings on ====\n\n";
- vk.AutoNormalize(1);
- vk.Headings(1);
+ vk.setAutoNormalize(true);
+ vk.setIntros(true);
vk = "jn3.50";
-/* TODO: these report 1 number off from what I think they should report
cout << "jn.3.50: " << vk << "\n";
vk++;
cout << "++: " << vk << "\n";
vk--;
cout << "--: " << vk << "\n";
-*/
vk = MAXVERSE;
cout << "MAXVERSE: " << vk << "\n";
vk = MAXCHAPTER;
@@ -144,19 +188,17 @@ cout << currentVerse << endl;
cout << "\nNormalization off; headings on ====\n\n";
- vk.AutoNormalize(0);
- vk.Headings(1);
+ vk.setAutoNormalize(false);
+ vk.setIntros(true);
vk = "jn3.50";
cout << "jn.3.50: " << vk << "\n";
-/* TODO: These probably are undefined and likely to be ok
vk++;
cout << "++: " << vk << "\n";
vk--;
cout << "--: " << vk << "\n";
vk = MAXVERSE;
cout << "MAXVERSE: " << vk << "\n";
-*/
vk = MAXCHAPTER;
cout << "MAXCHAPTER: " << vk << "\n";
vk = TOP;
@@ -166,8 +208,8 @@ cout << currentVerse << endl;
cout << "\nNormalization on; headings off ====\n\n";
- vk.AutoNormalize(1);
- vk.Headings(0);
+ vk.setAutoNormalize(true);
+ vk.setIntros(false);
vk = "jn3.50";
cout << "jn.3.50: " << vk << "\n";
@@ -186,19 +228,17 @@ cout << currentVerse << endl;
cout << "\nNormalization off; headings off ====\n\n";
- vk.AutoNormalize(0);
- vk.Headings(0);
+ vk.setAutoNormalize(false);
+ vk.setIntros(false);
vk = "jn3.50";
cout << "jn.3.50: " << vk << "\n";
-/* TODO: These probably are undefined and likely to be ok
vk++;
cout << "++: " << vk << "\n";
vk--;
cout << "--: " << vk << "\n";
vk = MAXVERSE;
cout << "MAXVERSE: " << vk << "\n";
-*/
vk = MAXCHAPTER;
cout << "MAXCHAPTER: " << vk << "\n";
vk = TOP;
@@ -208,11 +248,11 @@ cout << currentVerse << endl;
VerseKey yo = "jn.3.16";
VerseKey yo2 = yo++;
- cout << yo2 << ": " << (int)yo2.Error() << endl;
+ cout << yo2 << ": " << (int)yo2.popError() << endl;
VerseKey vkey;
VerseKey tmpkey = "1sam 1:1";
- vkey.AutoNormalize(1); // line 147
+ vkey.setAutoNormalize(true);
vkey = tmpkey;
int chapter = (vkey.getChapter()-1);
vkey.setChapter(chapter);