add some tests

This commit is contained in:
Dorian Zedler 2021-05-11 19:36:15 +02:00
parent 7b52e7cf44
commit 6bfcd9be47
Signed by: dorian
GPG key ID: 989DE36109AFA354
3 changed files with 175 additions and 0 deletions

73
ScStwLibraries/tests/.gitignore vendored Normal file
View file

@ -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

View file

@ -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)

View file

@ -0,0 +1,88 @@
#include <QtTest>
#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"