diff options
Diffstat (limited to 'tests/versemgrtest.cpp')
-rw-r--r-- | tests/versemgrtest.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/versemgrtest.cpp b/tests/versemgrtest.cpp new file mode 100644 index 0000000..8d5ec98 --- /dev/null +++ b/tests/versemgrtest.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org) + * CrossWire Bible Society + * P. O. Box 2528 + * Tempe, AZ 85280-2528 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ + +#include <iostream> +#include <stdio.h> +#include <stdlib.h> + +#include <versemgr.h> +#ifndef NO_SWORD_NAMESPACE +using namespace sword; +#endif + +using std::cout; +using std::endl; + +int main(int argc, char **argv) { + + const char *v11n = (argc > 1) ? argv[1] : "KJV"; + + VerseMgr *vmgr = VerseMgr::getSystemVerseMgr(); + const VerseMgr::System *system = vmgr->getVersificationSystem(v11n); + int bookCount = system->getBookCount(); + const VerseMgr::Book *lastBook = system->getBook(bookCount-1); + int chapMax = lastBook->getChapterMax(); + int verseMax = lastBook->getVerseMax(chapMax); + long offsetMax = system->getOffsetFromVerse(bookCount-1, chapMax, verseMax); + + cout << "Versification System: " << v11n << "\n"; + cout << "Book Count: " << bookCount << "\n"; + cout << "Last Book: " << lastBook->getLongName() << " (" << lastBook->getOSISName() << ")\n"; + cout << " Chapter Max: " << chapMax << "\n"; + cout << " Verse Max: " << verseMax << "\n"; + cout << " Offset: " << offsetMax << "\n\n"; + cout << "Offset, Book, Chapter, Verse\n"; + + int book, chapter, verse; + for (long offset = 0; offset <= offsetMax; offset++) { + system->getVerseFromOffset(offset, &book, &chapter, &verse); + cout << offset << ": " << book << ", " << chapter << ", " << verse << "\n"; + } + + cout << endl; + + return 0; +} |