From fd139d24bd5538aa0589f4c7864f3c52f3155c3e Mon Sep 17 00:00:00 2001
From: Zhaolin Deng <zhaolin.deng@student.unimelb.edu.au>
Date: Mon, 17 Sep 2018 01:21:38 +1000
Subject: [PATCH] Replace PartitioningTests.java

---
 test/swen90006/machine/PartitioningTests.java | 75 ++++++++-----------
 1 file changed, 33 insertions(+), 42 deletions(-)

diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java
index bf5b21c..b8fbdb9 100644
--- a/test/swen90006/machine/PartitioningTests.java
+++ b/test/swen90006/machine/PartitioningTests.java
@@ -26,18 +26,9 @@ public class PartitioningTests
 
   //Any method annotation with "@Test" is executed as a test.
   
-  @Test public void ec2Test()
-  {
-    //the assertEquals method used to check whether two values are
-    //equal, using the equals method
-	List<String> list = new ArrayList<String>();
-    list.add("jmp 0");
-    list.add("ret R0");	
-    Machine m = new Machine();
-    assertEquals(m.execute(list), "No result");
-  }
   
-  @Test public void ec3Test()
+  @Test(expected = swen90006.machine.NoReturnValueException.class)
+  public void ec3Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -45,7 +36,7 @@ public class PartitioningTests
     list.add("jmp 10");
     list.add("ret R0");	
     Machine m = new Machine();
-    assertEquals(m.execute(list),NoReturnValueException);
+    m.execute(list);
   }
 
   @Test public void ec4Test()
@@ -59,7 +50,8 @@ public class PartitioningTests
     assertEquals(m.execute(list), 0);
   }
   
-  @Test public void ec5Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec5Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -67,17 +59,18 @@ public class PartitioningTests
     list.add("jmp 66666");
     list.add("ret R0");	
     Machine m = new Machine();
-    assertEquals(m.execute(list),InvalidInstructionException);
+    m.execute(list);
   } 
   
-  @Test public void ec6Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec6Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
 	List<String> list = new ArrayList<String>();
     list.add("ret R40");	
     Machine m = new Machine();
-    assertEquals(m.execute(list), InvalidInstructionException);
+    m.execute(list);
   }
   
   @Test public void ec7Test()
@@ -101,7 +94,8 @@ public class PartitioningTests
     assertEquals(m.execute(list), 5);
   }
   
-  @Test public void ec9Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec9Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -109,21 +103,12 @@ public class PartitioningTests
     list.add("mov R1 66666");
     list.add("ret R1");	
     Machine m = new Machine();
-    assertEquals(m.execute(list),InvalidInstructionException);
+    m.execute(list);
   }
   
-  @Test public void ec10Test()
-  {
-    //the assertEquals method used to check whether two values are
-    //equal, using the equals method
-	List<String> list = new ArrayList<String>();
-    list.add("jz R1 0");
-    list.add("ret R1");	
-    Machine m = new Machine();
-    assertEquals(m.execute(list),"No result");
-  }
-  
-  @Test public void ec11Test()
+
+  @Test(expected = swen90006.machine.NoReturnValueException.class)
+  public void ec11Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -157,7 +142,8 @@ public class PartitioningTests
     assertEquals(m.execute(list), 0);
   }
   
-  @Test public void ec14Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec14Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -166,10 +152,11 @@ public class PartitioningTests
 	list.add("ldr R0 R1 66666");
     list.add("ret R0");	
     Machine m = new Machine();
-    assertEquals(m.execute(list), InvalidInstructionException);
+    m.execute(list);
   }
   
-  @Test public void ec15Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec15Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -178,10 +165,11 @@ public class PartitioningTests
 	list.add("ldr R0 R1 0");
     list.add("ret R0");	
     Machine m = new Machine();
-    assertEquals(m.execute(list), InvalidInstructionException);
+    m.execute(list);
   }
   
-  @Test public void ec16Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec16Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -189,10 +177,11 @@ public class PartitioningTests
 	list.add("ldr R0 R40 0");
     list.add("ret R0");	
     Machine m = new Machine();
-    assertEquals(m.execute(list), InvalidInstructionException);
+    m.execute(list);
   }
   
-  @Test public void ec17Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec17Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -200,10 +189,11 @@ public class PartitioningTests
 	list.add("str R0 0 R40");
     list.add("ret R0");	
     Machine m = new Machine();
-    assertEquals(m.execute(list), InvalidInstructionException);
+    m.execute(list);
   }
   
-  @Test public void ec18Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec18Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -212,7 +202,7 @@ public class PartitioningTests
 	list.add("str R1 0 R0");
     list.add("ret R0");	
     Machine m = new Machine();
-    assertEquals(m.execute(list), InvalidInstructionException);
+    m.execute(list);
   }
   
   @Test public void ec20Test()
@@ -228,7 +218,8 @@ public class PartitioningTests
     assertEquals(m.execute(list), 30);
   }
   
-  @Test public void ec21Test()
+  @Test(expected = swen90006.machine.InvalidInstructionException.class)
+  public void ec21Test()
   {
     //the assertEquals method used to check whether two values are
     //equal, using the equals method
@@ -236,7 +227,7 @@ public class PartitioningTests
 	list.add("add R0 R1 R40");
     list.add("ret R0");	
     Machine m = new Machine();
-    assertEquals(m.execute(list), InvalidInstructionException);
+    m.execute(list);
   }
   
   @Test public void ec22Test()
-- 
GitLab