Repository navigation
Expand file tree
/
Copy pathPercolationTest.java
More file actions
117 lines (100 loc) · 2.1 KB
/
Copy pathPercolationTest.java
File metadata and controls
117 lines (100 loc) · 2.1 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package a01.tests;
/************************************************
* Author(s): Gavin Rosenvall, Spencer Rosenvall
* Class: CSIS 2420
* Professor: Frau Posch
* Assignment: A01_Percolation
************************************************/
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import a01.Percolation;
/**
* Class PercolationTests performs JUnit tests on classes PercolationStats.java
* and Percolation.java.
*
* @author GavinR, SpencerR
*
*/
class PercolationTest
{
private Percolation p4 = new Percolation(4); // Percolation Object
@BeforeEach
void setUp() throws Exception
{
}
@Test
public void testPercolation()
{
Percolation p3 = new Percolation(3);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
assertFalse(p3.isOpen(i, j));
}
}
}
@Test
void testPercolation_gridSize()
{
Percolation p3 = new Percolation(3);
assertThrows(Exception.class, () ->
{
p3.isOpen(3, 3); // (3, 3)should not exist.
});
}
@Test
public void testOpen()
{
assertFalse(p4.isOpen(0, 0));
p4.open(0, 0);
assertTrue(p4.isOpen(0, 0));
}
@Test
public void testOpen_01()
{
p4.open(0, 1);
assertTrue(p4.isOpen(0, 1));
}
@Test
public void testIsOpen()
{
assertFalse(p4.isOpen(3, 3));
p4.open(3, 3);
assertTrue(p4.isOpen(3, 3));
}
@Test
public void testIsFull_01()
{
p4.open(0, 1);
assertTrue(p4.isFull(0, 1));
}
@Test
public void testIsFull_diagonal()
{
p4.open(0, 1);
p4.open(1, 2);
assertFalse(p4.isFull(1, 2));
}
@Test
public void testIsFull_flowAroundCorners()
{
p4.open(0, 1);
p4.open(1, 1);
p4.open(1, 2);
p4.open(2, 2);
assertTrue(p4.isFull(2, 2));
}
@Test
public void testPercolates_allClosed()
{
assertFalse(p4.percolates());
}
@Test
public void testPercolates_touchingBottom()
{
}
}