Skip to content
Snippets Groups Projects
Select Git revision
  • 10a85fe85e3614f7d3b5ec02757229a4ad252cea
  • master default protected
  • revert-0c4fcdc7
3 results

PartitioningTests.java

Blame
  • Forked from Tim Miller / SWEN90006-A1-2018
    Source project has a limited visibility.
    PartitioningTests.java 18.66 KiB
    package swen90006.machine;
    
    import java.util.List;
    import java.util.ArrayList;
    import java.nio.charset.Charset;
    import java.nio.file.Path;
    import java.nio.file.Files;
    import java.nio.file.FileSystems;
    
    import org.junit.*;
    import static org.junit.Assert.*;
    
    public class PartitioningTests
    {
    	 
    	  //Any method annotated with "@Before" will be executed before each test,
    	  //allowing the tester to set up some shared resources.
    	  @Before public void setUp()
    	  {
    	  }
    
    	  //Any method annotated with "@After" will be executed after each test,
    	  //allowing the tester to release any shared resources used in the setup.
    	  @After public void tearDown()
    	  {
    	  }
    
    	  // EC10
    	  // Test a valid input of add instruction.
    	  // Partitioning class is { ret Ra; | Ra ( REGISTER }
    	  @Test public void retInstructionValidTest()
    	  {
    		  List<String> list = new ArrayList<String>();
    		  list.add("mov R0 0;");
    		  list.add("ret R0;");
    		  Machine m = new Machine();
    		  assertEquals(m.execute(list), 0);
    	  }
    	  
    	  // EC11
    	  // Test a invalid input of add instruction.
    	  // Partitioning class is { ret Ra; | Ra not ( REGISTER }
    	  @Test (expected = InvalidInstructionException.class) 
    	  public void retInstructionInvalidTest()
    	  throws Throwable
    	  {
    		  List<String> list = new ArrayList<String>();
    		  list.add("mov R0 0;");
    		  list.add("ret R-1;");
    		  Machine m = new Machine();
    		  m.execute(list);
    	  }
    	  
    	  // EC12
    	  // Test a valid input of add instruction.
    	  // Partitioning class is { mov Ra V; | Ra ( REGISTER V ( VALUE }
    	  @Test public void movInstructionValidTest()
    	  {
    		  List<String> list = new ArrayList<String>();
    		  list.add("mov R0 0;");
    		  list.add("ret R0;");
    		  Machine m = new Machine();
    		  assertEquals(m.execute(list), 0);
    	  }
    	 
    	  // EC13
    	  // Test a invalid input of add instruction.
    	  // Partitioning class is { mov Ra V; | Ra not ( REGISTER }
    	  @Test (expected = InvalidInstructionException.class) 
    	  public void movInstructionInvalidRegisterTest()