1 | sub_1.addTestElement(new TestSampler("one"));↵ | | 1 | sub_1.addTestElement(new TestSampler("one"));↵
|
2 | sub_1.addTestElement(new TestSampler("two"));↵ | | 2 | sub_1.addTestElement(new TestSampler("two"));↵
|
|
3 | LoopController controller = new LoopController();↵ | | 3 | LoopController controller = new LoopController();↵
|
4 | controller.setLoops(5);↵ | | 4 | controller.setLoops(6);↵
|
5 | controller.addTestElement(new TestSampler("zero"));↵ | | 5 | controller.addTestElement(new TestSampler("zero"));↵
|
6 | controller.addTestElement(sub_1);↵ | | 6 | controller.addTestElement(sub_1);↵
|
7 | controller.addIterationListener(sub_1);↵ | | 7 | controller.addIterationListener(sub_1);↵
|
8 | controller.addTestElement(new TestSampler("three"));↵ | | 8 | controller.addTestElement(new TestSampler("three"));↵
|
|
9 | String[] order = new String[] { "zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero",↵ | | |
|
10 | "three", ↵ | | 9 | // Expected results established using the DDA↵
|
| | | 10 | // algorithm (see↵
|
| | | 11 | // http://www.siggraph.org/education/materials/HyperGraph/scanline/outprims/drawline.htm):↵
|
| | | 12 | String[] order = new String[] { "zero", // 0/1 vs. 1/1 -> 0 is↵
|
| | | 13 | // closer to 33.33↵
|
| | | 14 | "three", "zero", // 0/2 vs. 1/2 -> 50.0 is closer to↵
|
| | | 15 | // 33.33↵
|
| | | 16 | "one", "two", "three", "zero", // 1/3 vs. 2/3 -> 33.33 is↵
|
| | | 17 | // closer to 33.33↵
|
| | | 18 | "three", "zero", // 1/4 vs. 2/4 -> 25.0 is closer to↵
|
| | | 19 | // 33.33↵
|
| | | 20 | "three", "zero", // 1/5 vs. 2/5 -> 40.0 is closer to↵
|
| | | 21 | // 33.33↵
|
| | | 22 | "one", "two", "three", "zero", // 2/6 vs. 3/6 -> 33.33 is↵
|
| | | 23 | // closer to 33.33↵
|
| | | 24 | "three",↵
|
| | | 25 | // etc...↵
|
11 | };↵ | | 26 | };↵
|
12 | int counter = 0;↵ | | 27 | int counter = 0;↵
|
13 | controller.setRunningVersion(true);↵ | | 28 | controller.setRunningVersion(true);↵
|
14 | sub_1.setRunningVersion(true);↵ | | 29 | sub_1.setRunningVersion(true);↵
|
15 | sub_1.testStarted();↵ | | 30 | sub_1.testStarted();↵
|
16 | controller.initialize();↵ | | 31 | controller.initialize();↵
|
17 | for (int i = 0; i < 3; i++) {↵ | | 32 | for (int i = 0; i < 3; i++) {↵
|
18 | TestElement sampler = null;↵ | | 33 | TestElement sampler = null;↵
|
19 | while ((sampler = controller.next()) != null) {↵ | | 34 | while ((sampler = controller.next()) != null) {↵
|
20 | assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName());↵ | | 35 | assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName());↵
|
21 | counter++;↵ | | 36 | counter++;↵
|
22 | }↵ | | 37 | }↵
|
23 | assertEquals(counter, order.length);↵ | | 38 | assertEquals(counter, order.length);↵
|
24 | counter = 0;↵ | | 39 | counter = 0;↵
|
25 | }↵ | | 40 | }↵
|
26 | sub_1.testEnded();↵ | | 41 | sub_1.testEnded();↵
|
27 | }↵ | | 42 | }↵
|
|
28 | public void testByPercent33() throws Exception {↵ | | 43 | public void testByPercentZero() throws Exception {↵
|
29 | ThroughputController sub_1 = new ThroughputController();↵ | | 44 | ThroughputController sub_1 = new ThroughputController();↵
|
30 | sub_1.setStyle(ThroughputController.BYPERCENT);↵ | | 45 | sub_1.setStyle(ThroughputController.BYPERCENT);↵
|
31 | sub_1.setPercentThroughput(33.33f);↵ | | 46 | sub_1.setPercentThroughput(0.0f);↵
|
32 | sub_1.addTestElement(new TestSampler("one"));↵ | | 47 | sub_1.addTestElement(new TestSampler("one"));↵
|
33 | sub_1.addTestElement(new TestSampler("two"));↵ | | 48 | sub_1.addTestElement(new TestSampler("two"));↵
|
|
34 | LoopController controller = new LoopController();↵ | | 49 | LoopController controller = new LoopController();↵
|
35 | controller.setLoops(6);↵ | | 50 | controller.setLoops(150);↵
|
36 | controller.addTestElement(new TestSampler("zero"));↵ | | 51 | controller.addTestElement(new TestSampler("zero"));↵
|
37 | controller.addTestElement(sub_1);↵ | | 52 | controller.addTestElement(sub_1);↵
|
38 | controller.addIterationListener(sub_1);↵ | | 53 | controller.addIterationListener(sub_1);↵
|
39 | controller.addTestElement(new TestSampler("three"));↵ | | 54 | controller.addTestElement(new TestSampler("three"));↵
|
40 | // Expected results established using the DDA↵ | | |
|
41 | // algorithm (see↵ | | |
|
42 | // http://www.siggraph.org/education/materials/HyperGraph/scanline/outprims/drawline.htm):↵ | | |
|
43 | String[] order = new String[] { "zero", // 0/1 vs. 1/1 -> 0 is↵ | | |
|
44 | // closer to 33.33↵ | | |
|
45 | "three", "zero", // 0/2 vs. 1/2 -> 50.0 is closer to↵ | | |
|
46 | // 33.33↵ | | |
|
47 | "one", "two", "three", "zero", // 1/3 vs. 2/3 -> 33.33 is↵ | | |
|
48 | // closer to 33.33↵ | | |
|
49 | "three", "zero", // 1/4 vs. 2/4 -> 25.0 is closer to↵ | | |
|
50 | // 33.33↵ | | |
|
51 | "three", "zero", // 1/5 vs. 2/5 -> 40.0 is closer to↵ | | |
|
52 | // 33.33↵ | | |
|
53 | "one", "two", "three", "zero", // 2/6 vs. 3/6 -> 33.33 is↵ | | |
|
54 | // closer to 33.33↵ | | |
|
55 | "three",↵ | | |
|
56 | // etc...↵ | | |
|
57 | ↵ | | |
|
58 | };↵ | | 55 | String[] order = new String[] { "zero", "three", };↵
|
59 | int counter = 0;↵ | | 56 | int counter = 0;↵
|
60 | controller.setRunningVersion(true);↵ | | 57 | controller.setRunningVersion(true);↵
|
61 | sub_1.setRunningVersion(true);↵ | | 58 | sub_1.setRunningVersion(true);↵
|
62 | sub_1.testStarted();↵ | | 59 | sub_1.testStarted();↵
|
63 | controller.initialize();↵ | | 60 | controller.initialize();↵
|
64 | for (int i = 0; i < 3; i++ | | 61 | for (int i = 0; i < 3; i++
|