alphabet_test.cpp 1.09 KB
Newer Older
Merwane Bouri's avatar
Merwane Bouri committed
1
2
3
4
5
#include <QtTest/QtTest>
#include <algorithm>
#include "cellulut_tests.hpp"
#include "alphabet.hpp"

Merwane Bouri's avatar
Merwane Bouri committed
6
7
//test sur la classe alphabet et aussi stateColor et State

Merwane Bouri's avatar
Merwane Bouri committed
8
void CellulutTests::test_alphabet(){
Merwane Bouri's avatar
Merwane Bouri committed
9
    Alphabet a;
Merwane Bouri's avatar
Merwane Bouri committed
10
    stateColor c1(1,5,126);
Merwane Bouri's avatar
Merwane Bouri committed
11
12
13
    state s1(c1,"Alpha");
    a.newEtat(s1);

Merwane Bouri's avatar
Merwane Bouri committed
14
    stateColor c2(144,245,74);
Merwane Bouri's avatar
Merwane Bouri committed
15
16
17
    state s2(c2,"beta");
    a.newEtat(s2);

Merwane Bouri's avatar
Merwane Bouri committed
18
    /*stateColor c3('g','h','i');
Merwane Bouri's avatar
Merwane Bouri committed
19
    state s3(c3,"gamma");
Merwane Bouri's avatar
Merwane Bouri committed
20
    a.newEtat(s3);*/
Merwane Bouri's avatar
Merwane Bouri committed
21

22
23
    // L'alphabet possède toujours un état 0, chaque état qui est ajouté commence au numéro 1
    state test=a.getState(1);
Merwane Bouri's avatar
Merwane Bouri committed
24
    stateColor sc =test.getColor();
Merwane Bouri's avatar
Merwane Bouri committed
25
26
27
    unsigned char cb=sc.getBlue();
    unsigned char cr=sc.getRed();
    unsigned char cg=sc.getGreen();
28
29
30
    QCOMPARE(cb,(unsigned char)126);
    QCOMPARE(cg,(unsigned char)5);
    QCOMPARE(cr,(unsigned char)1);
Merwane Bouri's avatar
Merwane Bouri committed
31

32
33
    state test2=a.getState(2);
    stateColor sc2 =test2.getColor();
Merwane Bouri's avatar
Merwane Bouri committed
34
35
36
    unsigned char cb2=sc2.getBlue();
    unsigned char cr2=sc2.getRed();
    unsigned char cg2=sc2.getGreen();
37
38
39
    QCOMPARE(cb2,(unsigned char)74);
    QCOMPARE(cg2,(unsigned char)245);
    QCOMPARE(cr2,(unsigned char)144);
Merwane Bouri's avatar
Merwane Bouri committed
40
41

}