88 lines
1.9 KiB
C++
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"
|