Select Git revision
BoundaryTests.java
Forked from
Tim Miller / SWEN90006-A1-2018
Source project has a limited visibility.
BoundaryTests.java 8.62 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 BoundaryTests
{
//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()
{
}
@Test public void B1TestCase()
{
//the assertEquals method used to check whether two values are
//equal, using the equals method
List<String> list = new ArrayList<String>();
list.add("MOV R0 0");
list.add("RET R0");
Machine machine = new Machine();
int actual = 0; // expected result
assertEquals(machine.execute(list), actual);
}
@Test public void B2TestCase()
{
//the assertEquals method used to check whether two values are
//equal, using the equals method
List<String> list = new ArrayList<String>();
list.add("MOV R1 1");
list.add("MOV R2 2");
list.add("ADD R31 R1 R2");
list.add("RET R31");
Machine machine = new Machine();
int actual = 31;
assertEquals(machine.execute(list), actual);
}
@Test public void B5TestCase()
{
//the assertEquals method used to check whether two values are
//equal, using the equals method
List<String> list = new ArrayList<String>();
list.add("MOV R1 -65535");
list.add("MOV R2 1");
list.add("DIV R3 R1 R2");
list.add("RET R3");
Machine machine = new Machine();
int actual = -65535;
assertEquals(machine.execute(list), actual);
}
@Test public void B6TestCase()
{
//the assertEquals method used to check whether two values are