|
| 1 | +package org.APCSLowell; |
| 2 | + |
| 3 | +import org.junit.Test; |
| 4 | +import static org.junit.Assert.*; |
| 5 | + |
| 6 | +public class FrogSimulationTest { |
| 7 | + @Test |
| 8 | + public void partA() { |
| 9 | + FrogSimulation test1 = new FrogSimulation(24, 5); |
| 10 | + test1.setPart("A"); |
| 11 | + test1.setHopValues(new int[] { 5, 7, -2, 8, 6 }); |
| 12 | + boolean res = test1.simulate(); |
| 13 | + assertEquals(res, true); |
| 14 | + test1.setHopValues(new int[] { 6, 7, 6, 6 }); |
| 15 | + res = test1.simulate(); |
| 16 | + assertEquals(res, true); |
| 17 | + test1.setHopValues(new int[] { 6, -6, 31 }); |
| 18 | + res = test1.simulate(); |
| 19 | + assertEquals(res, true); |
| 20 | + test1.setHopValues(new int[] { 4, 2, -8 }); |
| 21 | + res = test1.simulate(); |
| 22 | + assertEquals(res, false); |
| 23 | + test1.setHopValues(new int[] { 5, 4, 2, 4, 3 }); |
| 24 | + res = test1.simulate(); |
| 25 | + assertEquals(res, false); |
| 26 | + test1.setHopValues(new int[] { 24, -7, -6, -6 }); |
| 27 | + res = test1.simulate(); |
| 28 | + assertEquals(res, true); |
| 29 | + test1 = new FrogSimulation(15, 3); |
| 30 | + test1.setPart("A"); |
| 31 | + test1.setHopValues(new int[] { 6, 7, 11 }); |
| 32 | + res = test1.simulate(); |
| 33 | + assertEquals(res, true); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void partB() { |
| 38 | + FrogSimulation test1 = new FrogSimulation(24, 5); |
| 39 | + test1.setPart("B"); |
| 40 | + int[][] testMatrix = { { 5, 7, -2, 8, 6 }, |
| 41 | + { 6, 7, 6, 6 }, |
| 42 | + { 6, -6, 31 }, |
| 43 | + { 4, 2, -8 }, |
| 44 | + { 5, 4, 2, 4, 3 } }; |
| 45 | + test1.setMultipleHopValues(testMatrix); |
| 46 | + assertEquals(test1.runSimulations(5), .6, .01); |
| 47 | + int[][] testMatrix2 = { { 5, 7, -2, 8, 6 }, |
| 48 | + { 5, 4, 2, 4, 3 } }; |
| 49 | + test1.setMultipleHopValues(testMatrix2); |
| 50 | + assertEquals(test1.runSimulations(2), .5, .01); |
| 51 | + int[][] testMatrix3 = { { 5, 7, -2, 8, 6 }, |
| 52 | + { 6, 7, 6, 6 }, |
| 53 | + { 6, -6, 31 } }; |
| 54 | + test1.setMultipleHopValues(testMatrix3); |
| 55 | + assertEquals(test1.runSimulations(3), 1.0, .01); |
| 56 | + } |
| 57 | +} |
0 commit comments