diff options
author | Your Name <you@example.com> | 2020-11-21 14:33:33 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2020-11-21 14:33:33 -0500 |
commit | 51734065a38cf6db48fe9fb4b16461ce424cad90 (patch) | |
tree | 9abea3db7c02d7eb957256062f8a71d6a7672e35 /testLibbible.cc | |
parent | dcfac3432f981191da68f14f21f5010fc4da51c0 (diff) | |
download | libbible-51734065a38cf6db48fe9fb4b16461ce424cad90.tar.gz libbible-51734065a38cf6db48fe9fb4b16461ce424cad90.tar.bz2 libbible-51734065a38cf6db48fe9fb4b16461ce424cad90.zip |
Updated API to be more explicit with references
Diffstat (limited to 'testLibbible.cc')
-rw-r--r-- | testLibbible.cc | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/testLibbible.cc b/testLibbible.cc index 8a7f468..b8f93b3 100644 --- a/testLibbible.cc +++ b/testLibbible.cc @@ -60,6 +60,18 @@ void StatusTester::update(unsigned long totalBytes, unsigned long completedBytes //----------------------------------------------------------------------------- +class CancelTester : public libbible::Status +{ + public: + virtual void update(unsigned long totalBytes, unsigned long completedBytes, string message); +}; + +void CancelTester::update(unsigned long totalBytes, unsigned long completedBytes, string message) { + libbible::terminateDownload(); +} + +//----------------------------------------------------------------------------- + void TestLibbible::testGetModules(void) { map<string, vector<string>> mods = libbible::getModules(); for(auto pair : mods) { @@ -141,7 +153,7 @@ void TestLibbible::testGetText(void) { //printf("Text is: `%s`\n", allText.c_str()); CPPUNIT_ASSERT(allText == "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. "); - text = libbible::getText(libbible::passage{.modName = "KJV", .reference="John 3:3"}); + text = libbible::getText(libbible::getPassage("KJV", "John 3:3")); allText.clear(); for(auto tex : text) { allText += tex.text; @@ -149,17 +161,17 @@ void TestLibbible::testGetText(void) { //printf("Text is: `%s`\n", allText.c_str()); CPPUNIT_ASSERT(allText == "Jesus answered and said unto him, Verily, verily, I say unto thee, Except a man be born again, he cannot see the kingdom of God. "); - text = libbible::getText(libbible::passage{.modName = "KJV", .reference="Gal 5:22-23"}); + text = libbible::getText(libbible::getPassage("KJV", "Gal 5:22-23")); chapVerses = getChapVerses(text); shouldContain = vector<pair<int, int>>({pair<int, int>(5, 22), pair<int, int>(5, 23)}); CPPUNIT_ASSERT(chapVerses == shouldContain); - text = libbible::getText(libbible::passage{.modName = "KJV", .reference="1 cor 1:31-2:1"}); + text = libbible::getText(libbible::getPassage("KJV", "1 cor 1:31-2:1")); chapVerses = getChapVerses(text); shouldContain = vector<pair<int, int>>({pair<int, int>(1, 31), pair<int, int>(2, 1)}); CPPUNIT_ASSERT(chapVerses == shouldContain); - text = libbible::getText(libbible::passage{.modName = "KJV", .reference="ps 14-15"}); + text = libbible::getText(libbible::getPassage("KJV", "ps 14-15")); chapVerses = getChapVerses(text); shouldContain = vector<pair<int, int>>({pair<int, int>(14, 1), pair<int, int>(14, 2), @@ -188,11 +200,7 @@ void TestLibbible::testSettings(void) { } void TestLibbible::testDownload(void) { - StatusTester status; - libbible::setStatusReporter(status); map<string, vector<string>> modsAvailable = libbible::downloadModsAvailable(); - //CPPUNIT_ASSERT(status.hasBeenUpdated); - status.hasBeenUpdated = false; // We try installing the first available one string language; string name; @@ -204,8 +212,15 @@ void TestLibbible::testDownload(void) { CPPUNIT_ASSERT(!language.empty() && !name.empty()); // Try uninstalling it (shouldn't crash or have nasty side effects!) libbible::uninstallMod(name); + // Try installing it with cancel. Shoudn't work because it gets cancelled! + CancelTester cancel; + libbible::setStatusReporter(cancel); + libbible::installModFromInternet(language, name); auto mods = libbible::getModules(); CPPUNIT_ASSERT(mods.find(name) == mods.end()); + // Now we try with normal status + StatusTester status; + libbible::setStatusReporter(status); libbible::installModFromInternet(language, name); mods = libbible::getModules(); CPPUNIT_ASSERT(mods.find(name) != mods.end()); |