forked from matt-l-morgan/WhistCardGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardComparatorTest.java
58 lines (49 loc) · 1.4 KB
/
CardComparatorTest.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
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Created by mattmorgan on 2/3/16.
*/
/**
* tests the Card Comparator
*/
public class CardComparatorTest {
/**
* tests cards with difference values
*/
@Test
public void testCompareValue() {
Card H5 = new Card(Card.Suit.Heart,Card.Value.Five);
Card H4 = new Card(Card.Suit.Heart,Card.Value.Four);
assertEquals(new CardComparator().compare(H4, H5), 1);
}
@Test
public void testCompareValue2() {
Card H5 = new Card(Card.Suit.Heart,Card.Value.Five);
Card H4 = new Card(Card.Suit.Heart,Card.Value.Four);
assertEquals(new CardComparator().compare(H5, H4), -1);
}
/**
* tests comparing equal cards
*/
@Test
public void testCompareSame() {
Card H5 = new Card(Card.Suit.Heart,Card.Value.Five);
Card H5copy = new Card(Card.Suit.Heart,Card.Value.Five);
assertEquals(new CardComparator().compare(H5, H5copy), 0);
}
/**
* test comparing by suit
*/
@Test
public void testCompareSuite1() {
Card H5 = new Card(Card.Suit.Heart,Card.Value.Five);
Card C4 = new Card(Card.Suit.Club,Card.Value.Four);
assertEquals(new CardComparator().compare(H5, C4), 1);
}
@Test
public void testCompareSuite2() {
Card H5 = new Card(Card.Suit.Heart,Card.Value.Five);
Card C4 = new Card(Card.Suit.Club,Card.Value.Four);
assertEquals(new CardComparator().compare(C4, H5), -1);
}
}