-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRodCutTest.java
More file actions
52 lines (43 loc) · 1.18 KB
/
RodCutTest.java
File metadata and controls
52 lines (43 loc) · 1.18 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
package algorithm;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import model.Price;
import model.Result;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class RodCutTest {
private final int rodLength = 7;
private Price price;
private RodCut rodCut;
public RodCutTest(RodCut rodCut) {
this.rodCut = rodCut;
}
@Before
public void setUp() throws Exception {
price = new Price();
price.add(1, 1);
price.add(2, 5);
price.add(3, 8);
price.add(4, 9);
price.add(5, 10);
price.add(6, 17);
price.add(7, 17);
price.add(8, 20);
price.add(9, 24);
price.add(10, 30);
}
@Test
public void testRodCut() throws Exception {
Result result = rodCut.cut(price, rodLength);
assertEquals(18, result.revenue);
assertEquals(1, result.cutPoint.getCutPoint(rodLength));
}
@Parameterized.Parameters(name= "{index}: {0}")
public static Collection<Object[]> instancesToTest() {
return Arrays.asList(new Object[] { new RecursiveRodCut() }, new Object[] { new BottomUpRodCut() }, new Object[] { new TopDownRodCut() });
}
}