grid_test.cpp 828 Bytes
Newer Older
Eugene Pin's avatar
Eugene Pin committed
1
2
3
#include <QtTest/QtTest>
#include <algorithm>
#include "cellulut_tests.hpp"
4
#include "grid.hpp"
Eugene Pin's avatar
Eugene Pin committed
5
6
7

void CellulutTests::test_grid()
{
8
9
    Grid grid(7,12);
    // Test méthode "Set cell" et "Get state"
10
11
12
    Coord pos1 = {4,4};
    grid.set_cell(pos1,2);
    Coord pos2 = {1,1};
13
    grid.set_cell(pos2,10);
14
15
    Coord pos3 = {1,2};
    grid.set_cell(pos3,1);
Yann Boucher's avatar
Yann Boucher committed
16
    int state = grid.get_state(pos1);
17
    QCOMPARE(state, 2);
18
19
    QVERIFY(grid.get_state(pos2) == 10);
    QVERIFY(grid.get_state(pos3) == 1);
20
21
22
23
24
25
26
27
28

    // Test operator=
    Grid grid2(5,6);
    QVERIFY(grid2.get_rows() == 5);
    QVERIFY(grid2.get_col() == 6);

    grid2 = grid;
    QVERIFY(grid2.get_rows() == 7);
    QVERIFY(grid2.get_col() == 12);
29
30
31
    QVERIFY(grid2.get_state(pos1) == 2);
    QVERIFY(grid2.get_state(pos2) == 10);
    QVERIFY(grid2.get_state(pos3) == 1);
Eugene Pin's avatar
Eugene Pin committed
32
}