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

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

    // 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);
    QVERIFY(grid2.get_state(4,4) == 2);
    QVERIFY(grid2.get_state(1, 1) == 10);
    QVERIFY(grid2.get_state(1, 2) == 1);
Eugene Pin's avatar
Eugene Pin committed
29
}