58 lines
1.3 KiB
C++
Executable File
58 lines
1.3 KiB
C++
Executable File
/**
|
|
* AES unit test fire automaton
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <QtCore>
|
|
#include <QMetaType>
|
|
|
|
#include <AreaEffectSimulation/Utils/fire_automaton.h>
|
|
|
|
Q_DECLARE_METATYPE(int32_t)
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
class TestFireAutomaton: public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void initTestCase();
|
|
void init();
|
|
|
|
void testResumePaused();
|
|
void testStop();
|
|
void testStates();
|
|
void testSchedule_0();
|
|
void testSchedule_1();
|
|
void testSchedule_2();
|
|
void testSchedule_3();
|
|
void testSchedule_4();
|
|
|
|
private:
|
|
struct FireEvent
|
|
{
|
|
qint64 time;
|
|
int32_t id;
|
|
};
|
|
|
|
void testScheduling(int32_t time, FireAutomaton::TimeType type, int32_t numberOfRounds, const QVector<int32_t>& effectorIds,
|
|
const QString& pattern, QVector<qint64> expectedDelays, QVector<QVector<int32_t>> expectedSchedule);
|
|
void testStepping(int32_t numberOfRounds, const QVector<int32_t>& effectorIds, const QString& pattern, QVector<QVector<int32_t>> expectedSchedule);
|
|
void fireReceived(int32_t id);
|
|
|
|
QVector<FireEvent> m_receivedFire;
|
|
qint64 m_finishedTime;
|
|
};
|
|
|
|
static bool withinTolerance(qint64 measured, qint64 expected, qint64 tolerance) {
|
|
return qAbs(measured-expected) <= tolerance;
|
|
};
|
|
|
|
} // namespace AreaEffectSimulation
|