-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathBinTest.java
More file actions
63 lines (48 loc) · 1.43 KB
/
BinTest.java
File metadata and controls
63 lines (48 loc) · 1.43 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
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
public class BinTest {
@Test
public void testBinConstructor(){
//given
int testMin = 2;
int testMax = 12;
int expected = (testMax - testMin) + 1;
//when
Bins test = new Bins(testMin, testMax);
int actualLength = test.sumOfRolls.length;
int actualValue = test.sumOfRolls[1];
//then
Assert.assertEquals(expected, actualLength);
Assert.assertEquals(0, actualValue);
}
@Test
public void testBinIncrement(){
//given
Bins test = new Bins(2, 12);
int testSum = 7;
//when
test.incrementBin(testSum);
//then
int actual = test.getBin(testSum);
String testString = Arrays.toString(test.sumOfRolls);
//Do not use String.valueOf for Integer ARRAYS!
System.out.println(testString);
Assert.assertEquals(1, actual);
}
@Test
public void testBinIncrement2() {
//given
Bins test = new Bins(2, 12);
int testSum = 7;
//when
test.incrementBin(testSum);
test.incrementBin(testSum);
//then
int actual = test.getBin(testSum);
String testString = Arrays.toString(test.sumOfRolls);
//Do not use String.valueOf for Integer ARRAYS!
System.out.println(testString);
Assert.assertEquals(2, actual);
}
}