Unverified Commit 8cde8141 authored by Merwane Bouri's avatar Merwane Bouri
Browse files

Implémentation test_alphabet

parent f5586584
Pipeline #78764 passed with stages
in 17 seconds
......@@ -46,12 +46,16 @@ public:
//! Renvoie l'alphabet
static Alphabet& getAlphabet() {static Alphabet a; return a;}
//! Renvoie le nombre d'états de l'alphabet
unsigned taille() const { return etats.size(); }
//! Crée un nouvel état
void newEtat(const state& s);
//! Renvoie l'état en fonction de son identifiant
state getState(unsigned int it) const;
//! Affecte l'identifiant d'état à un état
void setState(unsigned int i, const state& s);
......
......@@ -3,6 +3,38 @@
#include "cellulut_tests.hpp"
#include "alphabet.hpp"
//test sur la classe alphabet et aussi stateColor et State
void CellulutTests::test_alphabet(){
Alphabet a;
stateColor c1('a','b','c');
state s1(c1,"Alpha");
a.newEtat(s1);
stateColor c2('d','e','f');
state s2(c2,"beta");
a.newEtat(s2);
stateColor c3('g','h','i');
state s3(c3,"gamma");
a.newEtat(s3);
state test=a.getState(0);
stateColor sc =test.getColor();
char cb=sc.getBlue();
char cr=sc.getRed();
char cg=sc.getGreen();
QCOMPARE(cb,'c');
QCOMPARE(cg,'b');
QCOMPARE(cr,'a');
state test2=a.getState(1);
stateColor sc2 =test.getColor();
char cb2=sc2.getBlue();
char cr2=sc2.getRed();
char cg2=sc2.getGreen();
QCOMPARE(cb2,'f');
QCOMPARE(cg2,'e');
QCOMPARE(cr2,'d');
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment