This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
shared-libraries/ScStwLibraries/tests/tst_scstwtimertests.cpp
2021-05-11 19:36:15 +02:00

88 lines
1.9 KiB
C++

#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"