-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShipUnitsTest.java
More file actions
35 lines (29 loc) · 1 KB
/
ShipUnitsTest.java
File metadata and controls
35 lines (29 loc) · 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
import static org.junit.jupiter.api.Assertions.assertEquals;
import cs3500.pa03.Model.ShipType;
import cs3500.pa03.Model.ShipUnits;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class ShipUnitsTest {
ShipUnits s;
@BeforeEach
void setup() {
s = new ShipUnits();
}
@Test
void getShipUnits() {
int units1 = s.getShipUnits(0, 0, 0, 0);
assertEquals(0, units1);
int units2 = s.getShipUnits(1, 2, 3, 4);
int expectedUnits2 = ShipType.CARRIER.getLength() * 1
+ ShipType.BATTLESHIP.getLength() * 2
+ ShipType.DESTROYER.getLength() * 3
+ ShipType.SUBMARINE.getLength() * 4;
assertEquals(expectedUnits2, units2);
int units3 = s.getShipUnits(-1, -2, -3, -4);
int expectedUnits3 = ShipType.CARRIER.getLength() * -1
+ ShipType.BATTLESHIP.getLength() * -2
+ ShipType.DESTROYER.getLength() * -3
+ ShipType.SUBMARINE.getLength() * -4;
assertEquals(expectedUnits3, units3);
}
}