diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/tst_BaseWonkoEntityLocalLoadTask.cpp | 15 | ||||
-rw-r--r-- | tests/tst_BaseWonkoEntityRemoteLoadTask.cpp | 15 | ||||
-rw-r--r-- | tests/tst_WonkoIndex.cpp | 50 | ||||
-rw-r--r-- | tests/tst_WonkoVersionList.cpp | 15 |
5 files changed, 99 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 67a7a45e..409462a2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,6 +37,10 @@ add_unit_test(GZip tst_GZip.cpp) add_unit_test(JavaVersion tst_JavaVersion.cpp) add_unit_test(ParseUtils tst_ParseUtils.cpp) add_unit_test(MojangVersionFormat tst_MojangVersionFormat.cpp) +add_unit_test(BaseWonkoEntityLocalLoadTask tst_BaseWonkoEntityLocalLoadTask.cpp) +add_unit_test(BaseWonkoEntityRemoteLoadTask tst_BaseWonkoEntityRemoteLoadTask.cpp) +add_unit_test(WonkoVersionList tst_WonkoVersionList.cpp) +add_unit_test(WonkoIndex tst_WonkoIndex.cpp) # Tests END # diff --git a/tests/tst_BaseWonkoEntityLocalLoadTask.cpp b/tests/tst_BaseWonkoEntityLocalLoadTask.cpp new file mode 100644 index 00000000..74da222a --- /dev/null +++ b/tests/tst_BaseWonkoEntityLocalLoadTask.cpp @@ -0,0 +1,15 @@ +#include <QTest> +#include "TestUtil.h" + +#include "wonko/tasks/BaseWonkoEntityLocalLoadTask.h" + +class BaseWonkoEntityLocalLoadTaskTest : public QObject +{ + Q_OBJECT +private +slots: +}; + +QTEST_GUILESS_MAIN(BaseWonkoEntityLocalLoadTaskTest) + +#include "tst_BaseWonkoEntityLocalLoadTask.moc" diff --git a/tests/tst_BaseWonkoEntityRemoteLoadTask.cpp b/tests/tst_BaseWonkoEntityRemoteLoadTask.cpp new file mode 100644 index 00000000..3a12e04e --- /dev/null +++ b/tests/tst_BaseWonkoEntityRemoteLoadTask.cpp @@ -0,0 +1,15 @@ +#include <QTest> +#include "TestUtil.h" + +#include "wonko/tasks/BaseWonkoEntityRemoteLoadTask.h" + +class BaseWonkoEntityRemoteLoadTaskTest : public QObject +{ + Q_OBJECT +private +slots: +}; + +QTEST_GUILESS_MAIN(BaseWonkoEntityRemoteLoadTaskTest) + +#include "tst_BaseWonkoEntityRemoteLoadTask.moc" diff --git a/tests/tst_WonkoIndex.cpp b/tests/tst_WonkoIndex.cpp new file mode 100644 index 00000000..076c806b --- /dev/null +++ b/tests/tst_WonkoIndex.cpp @@ -0,0 +1,50 @@ +#include <QTest> +#include "TestUtil.h" + +#include "wonko/WonkoIndex.h" +#include "wonko/WonkoVersionList.h" +#include "Env.h" + +class WonkoIndexTest : public QObject +{ + Q_OBJECT +private +slots: + void test_isProvidedByEnv() + { + QVERIFY(ENV.wonkoIndex() != nullptr); + QCOMPARE(ENV.wonkoIndex(), ENV.wonkoIndex()); + } + + void test_providesTasks() + { + QVERIFY(ENV.wonkoIndex()->localUpdateTask() != nullptr); + QVERIFY(ENV.wonkoIndex()->remoteUpdateTask() != nullptr); + } + + void test_hasUid_and_getList() + { + WonkoIndex windex({std::make_shared<WonkoVersionList>("list1"), std::make_shared<WonkoVersionList>("list2"), std::make_shared<WonkoVersionList>("list3")}); + QVERIFY(windex.hasUid("list1")); + QVERIFY(!windex.hasUid("asdf")); + QVERIFY(windex.getList("list2") != nullptr); + QCOMPARE(windex.getList("list2")->uid(), QString("list2")); + QVERIFY(windex.getList("adsf") == nullptr); + } + + void test_merge() + { + WonkoIndex windex({std::make_shared<WonkoVersionList>("list1"), std::make_shared<WonkoVersionList>("list2"), std::make_shared<WonkoVersionList>("list3")}); + QCOMPARE(windex.lists().size(), 3); + windex.merge(std::shared_ptr<WonkoIndex>(new WonkoIndex({std::make_shared<WonkoVersionList>("list1"), std::make_shared<WonkoVersionList>("list2"), std::make_shared<WonkoVersionList>("list3")}))); + QCOMPARE(windex.lists().size(), 3); + windex.merge(std::shared_ptr<WonkoIndex>(new WonkoIndex({std::make_shared<WonkoVersionList>("list4"), std::make_shared<WonkoVersionList>("list2"), std::make_shared<WonkoVersionList>("list5")}))); + QCOMPARE(windex.lists().size(), 5); + windex.merge(std::shared_ptr<WonkoIndex>(new WonkoIndex({std::make_shared<WonkoVersionList>("list6")}))); + QCOMPARE(windex.lists().size(), 6); + } +}; + +QTEST_GUILESS_MAIN(WonkoIndexTest) + +#include "tst_WonkoIndex.moc" diff --git a/tests/tst_WonkoVersionList.cpp b/tests/tst_WonkoVersionList.cpp new file mode 100644 index 00000000..7cb21df7 --- /dev/null +++ b/tests/tst_WonkoVersionList.cpp @@ -0,0 +1,15 @@ +#include <QTest> +#include "TestUtil.h" + +#include "wonko/WonkoVersionList.h" + +class WonkoVersionListTest : public QObject +{ + Q_OBJECT +private +slots: +}; + +QTEST_GUILESS_MAIN(WonkoVersionListTest) + +#include "tst_WonkoVersionList.moc" |