diff --git a/ScStwLibraries/tests/.gitignore b/ScStwLibraries/tests/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/ScStwLibraries/tests/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/ScStwLibraries/tests/tests.pro b/ScStwLibraries/tests/tests.pro new file mode 100644 index 0000000..9708cdf --- /dev/null +++ b/ScStwLibraries/tests/tests.pro @@ -0,0 +1,14 @@ +QT += testlib +QT -= gui + +CONFIG += qt console warn_on depend_includepath testcase +CONFIG -= app_bundle + +TEMPLATE = app + +SOURCES += \ + tst_scstwtimertests.cpp + +# include submodules +CONFIG += ScStwLibraries_QML ScStwLibraries_Styling ScStwLibraries_ClientLibs +include($$PWD/../ScStwLibraries.pri) diff --git a/ScStwLibraries/tests/tst_scstwtimertests.cpp b/ScStwLibraries/tests/tst_scstwtimertests.cpp new file mode 100644 index 0000000..fda43ee --- /dev/null +++ b/ScStwLibraries/tests/tst_scstwtimertests.cpp @@ -0,0 +1,88 @@ +#include +#include "scstwlibraries.h" + +// add necessary includes here + +class ScStwTimerTests : public QObject +{ + Q_OBJECT + +public: + ScStwTimerTests(); + ~ScStwTimerTests(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void basic_cycle_won(); + void basic_cycle_lost(); + void basic_cycle_failed(); + +}; + +ScStwTimerTests::ScStwTimerTests() +{ + +} + +ScStwTimerTests::~ScStwTimerTests() +{ + +} + +void ScStwTimerTests::initTestCase() +{ + +} + +void ScStwTimerTests::cleanupTestCase() +{ + +} + +void ScStwTimerTests::basic_cycle_won() +{ + ScStwTimer * timer = new ScStwTimer(); + QCOMPARE(timer->getState(), ScStwTimer::IDLE); + timer->start(); + QCOMPARE(timer->getState(), ScStwTimer::RUNNING); + timer->stop(); + QCOMPARE(timer->getState(), ScStwTimer::WAITING); + timer->setResult(ScStwTimer::WON); + QCOMPARE(timer->getState(), ScStwTimer::WON); + timer->reset(); + QCOMPARE(timer->getState(), ScStwTimer::IDLE); +} + +void ScStwTimerTests::basic_cycle_lost() +{ + ScStwTimer * timer = new ScStwTimer(); + QCOMPARE(timer->getState(), ScStwTimer::IDLE); + timer->start(); + QCOMPARE(timer->getState(), ScStwTimer::RUNNING); + timer->stop(); + QCOMPARE(timer->getState(), ScStwTimer::WAITING); + timer->setResult(ScStwTimer::LOST); + QCOMPARE(timer->getState(), ScStwTimer::LOST); + timer->reset(); + QCOMPARE(timer->getState(), ScStwTimer::IDLE); +} + +void ScStwTimerTests::basic_cycle_failed() +{ + ScStwTimer * timer = new ScStwTimer(); + QCOMPARE(timer->getState(), ScStwTimer::IDLE); + timer->start(); + QCOMPARE(timer->getState(), ScStwTimer::RUNNING); + + QCOMPARE(timer->getState(), ScStwTimer::WAITING); + timer->setResult(ScStwTimer::WON); + QCOMPARE(timer->getState(), ScStwTimer::WON); + timer->reset(); + QCOMPARE(timer->getState(), ScStwTimer::IDLE); +} + +QTEST_APPLESS_MAIN(ScStwTimerTests) + +#include "tst_scstwtimertests.moc"