diff --git a/classes/swen90006/machine/BoundaryTests.class b/classes/swen90006/machine/BoundaryTests.class index 2ba0555264cb67e19f67bce50ede5c9c692d5d05..39995919ae3402b67109053be90965559d759222 100644 Binary files a/classes/swen90006/machine/BoundaryTests.class and b/classes/swen90006/machine/BoundaryTests.class differ diff --git a/classes/swen90006/machine/PartitioningTests.class b/classes/swen90006/machine/PartitioningTests.class index b084b43b945ece63ee63632a5d84c0904474e340..3fb5d6b8cf0b8557c393193a97599731d61b4f59 100644 Binary files a/classes/swen90006/machine/PartitioningTests.class and b/classes/swen90006/machine/PartitioningTests.class differ diff --git a/test/swen90006/machine/BoundaryTests.java b/test/swen90006/machine/BoundaryTests.java index d3a53c0aad9952225c70e649cca9d939e1255547..221ae3888f628ad764d4aa060f3fb1f6cb33fa44 100644 --- a/test/swen90006/machine/BoundaryTests.java +++ b/test/swen90006/machine/BoundaryTests.java @@ -32,138 +32,173 @@ public class BoundaryTests public void boundaryTest1() throws Exception { final List<String> lines = readInstructions("examples/BV1.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 3); + assertEquals(m.execute(lines), -65535); } @Test public void boundaryTest2() throws Exception { final List<String> lines = readInstructions("examples/BV2.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 2); + assertEquals(m.execute(lines), 65535); } - @Test + @Test() public void boundaryTest3() throws Exception { final List<String> lines = readInstructions("examples/BV3.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 3); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } } @Test public void boundaryTest4() throws Exception { final List<String> lines = readInstructions("examples/BV4.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 3); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } } @Test public void boundaryTest5() throws Exception { final List<String> lines = readInstructions("examples/BV5.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), 2); } @Test public void boundaryTest6() throws Exception { final List<String> lines = readInstructions("examples/BV6.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), 2); } @Test public void boundaryTest7() throws Exception { final List<String> lines = readInstructions("examples/BV7.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 3); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } } @Test public void boundaryTest8() throws Exception { final List<String> lines = readInstructions("examples/BV8.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 3); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } } @Test public void boundaryTest9() throws Exception { final List<String> lines = readInstructions("examples/BV9.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 5); + assertEquals(m.execute(lines), -2147483648); } @Test public void boundaryTest10() throws Exception { - final List<String> lines = readInstructions("examples/BV10.s"); + final List<String> lines = new ArrayList<String>(); + lines.add("MOV R0 65535"); + lines.add("MOV R1 32768"); + lines.add("MOV R2 32767"); + lines.add("MUL R0 R0 R1"); + lines.add("ADD R0 R0 R2"); + lines.add("RET R0"); Machine m = new Machine(); - assertEquals(m.execute(lines), 6); + assertEquals(m.execute(lines), 2147483647); } @Test public void boundaryTest11() throws Exception { final List<String> lines = readInstructions("examples/BV11.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 7); + assertEquals(m.execute(lines), 2147483647); } @Test public void boundaryTest12() throws Exception { final List<String> lines = readInstructions("examples/BV12.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 5); + assertEquals(m.execute(lines), -2147483648); } @Test public void boundaryTest13() throws Exception { final List<String> lines = readInstructions("examples/BV13.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), 0); } @Test public void boundaryTest14() throws Exception { final List<String> lines = readInstructions("examples/BV14.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), 0); } @Test public void boundaryTest15() throws Exception { final List<String> lines = readInstructions("examples/BV15.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } } @Test public void boundaryTest16() throws Exception { final List<String> lines = readInstructions("examples/BV16.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), 5); + } @Test public void boundaryTest17() throws Exception { final List<String> lines = readInstructions("examples/BV17.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), 2); } @Test public void boundaryTest18() throws Exception { final List<String> lines = readInstructions("examples/BV18.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), 2); } @Test public void boundaryTest19() throws Exception { final List<String> lines = readInstructions("examples/BV19.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), -2); } @Test public void boundaryTest20() throws Exception { final List<String> lines = readInstructions("examples/BV20.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 1); + assertEquals(m.execute(lines), 0); } @Test public void boundaryTest21() throws Exception { final List<String> lines = readInstructions("examples/BV21.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 6); + assertEquals(m.execute(lines), 1); } @Test public void boundaryTest22() throws Exception { final List<String> lines = readInstructions("examples/BV22.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 6); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof NoReturnValueException); + } } @Test public void boundaryTest23() throws Exception { final List<String> lines = readInstructions("examples/BV23.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 6); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof NoReturnValueException); + } } } diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java index d7e2d2f89e5a2a9d6cd5807ec1d4658d12d60292..e34e54dfcde911329047843a8926b3d4cc70bbae 100644 --- a/test/swen90006/machine/PartitioningTests.java +++ b/test/swen90006/machine/PartitioningTests.java @@ -29,103 +29,151 @@ public class PartitioningTests public void partitionTest1() throws Exception{ final List<String> lines = readInstructions("examples/EC1.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 9); + assertEquals(m.execute(lines), 10); } @Test public void partitionTest2() throws Exception{ final List<String> lines = readInstructions("examples/EC2.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 3); - + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof NoReturnValueException); + } } @Test public void partitionTest3() throws Exception{ final List<String> lines = readInstructions("examples/EC3.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 3); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof NoReturnValueException); + } } @Test public void partitionTest4() throws Exception{ final List<String> lines = readInstructions("examples/EC4.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 9); - + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof NoReturnValueException); + } } @Test public void partitionTest5() throws Exception{ final List<String> lines = readInstructions("examples/EC5.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 2); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } } @Test public void partitionTest6() throws Exception{ final List<String> lines = readInstructions("examples/EC6.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 2); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } } @Test public void partitionTest7() throws Exception{ final List<String> lines = readInstructions("examples/EC7.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 7); + assertEquals(m.execute(lines), 2147483647); } @Test public void partitionTest8() throws Exception{ final List<String> lines = readInstructions("examples/EC8.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 5); + assertEquals(m.execute(lines), -2147483648); } @Test public void partitionTest9() throws Exception{ final List<String> lines = readInstructions("examples/EC9.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 1); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } + } @Test public void partitionTest10() throws Exception{ final List<String> lines = readInstructions("examples/EC10.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 1); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } + } @Test public void partitionTest11() throws Exception{ final List<String> lines = readInstructions("examples/EC11.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 5); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } + } @Test public void partitionTest12() throws Exception{ final List<String> lines = readInstructions("examples/EC12.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 5); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } + } @Test public void partitionTest131() throws Exception{ final List<String> lines = readInstructions("examples/EC13-1.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 1); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } + } @Test public void partitionTest132() throws Exception{ final List<String> lines = readInstructions("examples/EC13-2.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 1); + try { + m.execute(lines); + }catch(Exception e) { + assertTrue(e instanceof InvalidInstructionException); + } + } @Test public void partitionTest14() throws Exception{ final List<String> lines = readInstructions("examples/EC14.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 4); + assertEquals(m.execute(lines), 1); } }