Cours:ClasseTestCorrecteurKp : Différence entre versions

De troyesGEII
Aller à : navigation, rechercher
(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> #... »)
(Aucune différence)

Version du 17 octobre 2025 à 16:40

testcorrecteurkp.h

#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

testcorrecteurkp.cpp

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