-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShipTest.java
More file actions
69 lines (58 loc) · 1.7 KB
/
ShipTest.java
File metadata and controls
69 lines (58 loc) · 1.7 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
import static org.junit.jupiter.api.Assertions.*;
import cs3500.pa03.Model.Coord;
import cs3500.pa03.Model.DirectionType;
import cs3500.pa03.Model.Ship;
import cs3500.pa03.Model.ShipType;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class ShipTest {
Ship s;
Ship s2;
Ship s3;
Ship s4;
@BeforeEach
public void setup() {
Coord first = new Coord(2,1);
Coord second = new Coord(1,2);
List<Coord> points = List.of(first, second);
s = new Ship(ShipType.CARRIER, points, DirectionType.HORIZONTAL, first);
}
@Test
void getShipType() {
assertEquals(ShipType.CARRIER, s.getShipType());
}
@Test
void getPoints(){
Coord first = new Coord(2,1);
Coord second = new Coord(1,2);
List<Coord> expected = List.of(first, second);
assertEquals(expected.size(), s.getPoints().size());
}
@Test
void testShipTypeLength() {
assertEquals(6, ShipType.CARRIER.getLength());
assertEquals(5, ShipType.BATTLESHIP.getLength());
assertEquals(3, ShipType.SUBMARINE.getLength());
assertEquals(4, ShipType.DESTROYER.getLength());
}
@Test
void testShipTypeSymbol() {
assertEquals('C', ShipType.CARRIER.getSymbol());
assertEquals('B', ShipType.BATTLESHIP.getSymbol());
assertEquals('S', ShipType.SUBMARINE.getSymbol());
assertEquals('D', ShipType.DESTROYER.getSymbol());
}
@Test
void getFirstCoord() {
assertEquals(2, s.getFirstCoord().getX());
assertEquals(1, s.getFirstCoord().getY());
}
@Test
void getDirection() {
assertEquals(DirectionType.HORIZONTAL, s.getDirection());
}
@Test
void getShipLength() {
}
}