-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNeighborsStateGetterTests.cpp
43 lines (39 loc) · 1.32 KB
/
NeighborsStateGetterTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "stdafx.h"
#include "CppUnitTest.h"
#include "Cell.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace GameOfLife
{
TEST_CLASS(NeighborsStateGetterTests)
{
private:
std::list<State> getNeighborsState(std::list<Cell> neighbors)
{
std::list<State> neighborsStateList;
std::list<State>::const_iterator neighborsStateIterator;
std::list<Cell>::const_iterator neighborsIterator;
for (neighborsIterator = neighbors.begin(); neighborsIterator != neighbors.end(); ++neighborsIterator)
{
neighborsStateList.push_back(neighborsIterator->getState());
}
return neighborsStateList;
}
public:
TEST_METHOD(OneAliveNeighborsOnTheListBegin)
{
std::list<Cell> neighbors;
neighbors.push_back(Cell(State::ALIVE, std::list<Cell>()));
neighbors.push_back(Cell(State::DEAD, std::list<Cell>()));
neighbors.push_back(Cell(State::ALIVE, std::list<Cell>()));
Assert::AreEqual(State::ALIVE, (*getNeighborsState(neighbors).begin()));
}
TEST_METHOD(OneDeadNeighborsOnTheListBegin)
{
std::list<Cell> neighbors;
neighbors.push_back(Cell(State::DEAD, std::list<Cell>()));
neighbors.push_back(Cell(State::DEAD, std::list<Cell>()));
neighbors.push_back(Cell(State::ALIVE, std::list<Cell>()));
Assert::AreEqual(State::DEAD, (*getNeighborsState(neighbors).begin()));
}
};
}