forked from ChicoState/Minefield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FieldTest.cpp
80 lines (62 loc) · 1.31 KB
/
FieldTest.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* Unit Tests for Field class
**/
#include <gtest/gtest.h>
#include <iostream>
#include "Field.h"
class FieldTest : public ::testing::Test
{
protected:
FieldTest(){}
virtual ~FieldTest(){}
virtual void SetUp(){}
virtual void TearDown(){}
};
TEST(FieldTest, placeMineInBounds)
{
Field minefield;
minefield.placeMine(4,5);
ASSERT_EQ( MINE_HIDDEN, minefield.get(4,5) );
}
TEST(FieldTest, isSafeFalse)
{
Field minefield;
minefield.placeMine(3,3);
ASSERT_FALSE( minefield.isSafe(3,3) );
}
TEST(FieldTest, isSafeTrue)
{
Field minefield;
minefield.placeMine(3,4);
ASSERT_TRUE( minefield.isSafe(3,3) );
}
TEST(FieldTest, revealAdjacentCenter)
{
Field minefield;
minefield.revealAdjacent(2,2);
ASSERT_EQ( EMPTY_SHOWN, minefield.get(2,2) );
}
TEST(FieldTest, revealAdjacentRight)
{
Field minefield;
minefield.revealAdjacent(2,2);
ASSERT_EQ( EMPTY_SHOWN, minefield.get(3,2) );
}
TEST(FieldTest, revealAdjacentLeft)
{
Field minefield;
minefield.revealAdjacent(2,2);
ASSERT_EQ( EMPTY_SHOWN, minefield.get(1,2) );
}
TEST(FieldTest, revealAdjacentAbove)
{
Field minefield;
minefield.revealAdjacent(2,2);
ASSERT_EQ( EMPTY_SHOWN, minefield.get(2,1) );
}
TEST(FieldTest, revealAdjacentBellow)
{
Field minefield;
minefield.revealAdjacent(2,2);
ASSERT_EQ( EMPTY_SHOWN, minefield.get(2,3) );
}