forked from stjkr02/gitWorkflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeckTest.java
66 lines (50 loc) · 1.34 KB
/
DeckTest.java
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
import junit.framework.TestCase;
public class DeckTest extends TestCase {
public void testNewDeck()
{
Deck d = new Deck();
int quantitySum = 0;
int colorSum = 0;
int shadingSum = 0;
int shapeSum = 0;
Card theCards[] = new Card[81];
int position = 0;
while(d.hasNext())
{
Card c = d.getNext();
theCards[position] = c;
position++;
quantitySum += c.getQuantity();
colorSum += c.getColor();
shadingSum += c.getShading();
shapeSum += c.getShape();
}
assertEquals(0, quantitySum % 3);
assertEquals(0, colorSum % 3);
assertEquals(0, shadingSum % 3);
assertEquals(0, shapeSum % 3);
for(int p1 = 0; p1 < 81; p1++)
{
for(int p2 = p1 + 1; p2 < 81; p2++)
{
assertFalse(theCards[p1].equals(theCards[p2]));
}
}
}
public void testEmptyDeck()
{
Deck d = new Deck("empty.dat");
assertFalse(d.hasNext());
}
public void testDeckFromFile()
{
Deck d = new Deck("deck.dat");
assertTrue(d.hasNext());
assertEquals(new Card(1, 1, 1, 1), d.getNext());
assertTrue(d.hasNext());
assertEquals(new Card(1, 1, 1, 2), d.getNext());
assertTrue(d.hasNext());
assertEquals(new Card(1, 1, 1, 3), d.getNext());
assertFalse(d.hasNext());
}
}