Select Git revision
Forked from
Toby Murray / swen90006-a2-2019
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()