-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathBinsTest.java
More file actions
92 lines (82 loc) · 2.32 KB
/
BinsTest.java
File metadata and controls
92 lines (82 loc) · 2.32 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import org.junit.Test;
import java.math.BigDecimal;
import java.util.Arrays;
public class BinsTest {
@Test
public void binsTest(){
//given
Integer min = 2;
Integer max = 12;
//when
Bins bin = new Bins(min, max);
//then
System.out.println(Arrays.toString(bin.getBoxes()));
}
@Test
public void fillBinsTest(){
//given
Bins bin = new Bins(2, 12);
Dice dice = new Dice(2);
//when
for (int i = 0; i < 1000000; i++) {
Integer input = dice.tossAndSum();
bin.fillBins(input);
}
String result = Arrays.toString(bin.getBoxes());
//then -check by looking at
System.out.println(result);
}
@Test
public void getBinTest(){
//given
Bins bin = new Bins(2, 12);
Dice dice = new Dice(2);
//when
for (int i = 0; i < 1000; i++) {
Integer input = dice.tossAndSum();
bin.fillBins(input);
}
String wholeBin = Arrays.toString(bin.getBoxes());
Integer bin5 = bin.getBin(5);
Integer bin12 = bin.getBin(12);
//Then
System.out.println(wholeBin);
System.out.println(bin5);
System.out.println(bin12);
}
@Test
public void incrementBinTest(){
//given
Bins bin = new Bins(2, 12);
Dice dice = new Dice(2);
//when
for (int i = 0; i < 1000; i++) {
Integer input = dice.tossAndSum();
bin.fillBins(input);
}
String wholeBin = Arrays.toString(bin.getBoxes());
Integer bin12 = bin.getBin(12);
bin.incrementBin(12);
Integer bin12AfterIncrement = bin.getBin(12);
//Then
System.out.println(wholeBin);
System.out.println(bin12);
System.out.println(bin12AfterIncrement);
}
@Test
public void getPercentTest(){
//given
Bins bin = new Bins(2, 12);
Dice dice = new Dice(2);
for (int i = 0; i < 1000; i++) {
Integer input = dice.tossAndSum();
bin.fillBins(input);
}
String wholeBin = Arrays.toString(bin.getBoxes());
//when
double result = bin.getPercent(12);
//then
System.out.println(wholeBin);
System.out.println(result);
}
}