Cours:ClasseTestCorrecteurKp : Différence entre versions
(Page créée avec « {|style="vertical-align:middle; width:100%; text-align:left; " |- | {{boîte déroulante/début|titre=testcorrecteurkp.h}} <source lang=cpp> #... ») |
(Annulation des modifications 20150 de Bjacquot (discussion)) |
| (Une révision intermédiaire par le même utilisateur non affichée) | |
(Aucune différence)
| |
Version actuelle datée du 17 octobre 2025 à 16:42
#ifndef TESTCORRECTEURKP_H
#define TESTCORRECTEURKP_H
#include <QtTest/QTest>
#include <QObject>
class TestCorrecteurKp : public QObject
{
Q_OBJECT
public:
explicit TestCorrecteurKp(QObject *parent = nullptr);
private slots:
void process_data();
void process();
signals:
};
#endif // TESTCORRECTEURKP_H
|
#include "testcorrecteurkp.h"
#include "correcteurkp.h"
TestCorrecteurKp::TestCorrecteurKp(QObject *parent)
: QObject{parent}
{
}
void TestCorrecteurKp::process_data()
{
QTest::addColumn<double>("consigne");
QTest::addColumn<double>("Kp");
QTest::addColumn<double>("input");
QTest::addColumn<double>("output");
QTest::newRow("") << 100.0 << 1.0 << 100.0 << 0.0 ;
QTest::newRow("") << 100.0 << 1.0 << 80.0 << 20.0 ;
QTest::newRow("") << 100.0 << 1.0 << 120.0 << -20.0 ;
QTest::newRow("") << 80.0 << 1.0 << 80.0 << 0.0 ;
QTest::newRow("") << 80.0 << 1.0 << 70.0 << 10.0 ;
QTest::newRow("") << 80.0 << 1.0 << 90.0 << -10.0 ;
}
void TestCorrecteurKp::process()
{
QFETCH(double, consigne);
QFETCH(double, Kp);
QFETCH(double, input);
QFETCH(double, output);
QCOMPARE(CorrecteurKp(consigne,Kp).process(input), output);
}
|
//main.cpp
#include "testcorrecteurkp.h"
QTEST_MAIN(TestCorrecteurKp)