Skip to content
Snippets Groups Projects
Commit 051abe87 authored by Jiaming Zhang's avatar Jiaming Zhang
Browse files

Delete BoundaryTests.java

parent e46379cb
No related branches found
No related tags found
No related merge requests found
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()
{
}
//To test B1 in Machine.
@Test public void b1Test()
{
final int expected = InvalidInstructionException;
final int actual = Machine.execute("R0");
assertEquals(expected, actual);
}
//To test B5 in Machine.
@Test public void b5Test()
{
final int expected = InvalidInstructionException;
final int actual = Machine.execute("R0");
assertEquals(expected, actual);
}
//To test B6 in Machine.
@Test public void b6Test()
{
final int expected = InvalidInstructionException;
final int actual = Machine.execute({LDR R2 R0 -1, RET R2});
assertEquals(expected, actual);
}
//To test B7 in Machine.
@Test public void b7Test()
{
final int expected = 0;
final int actual = Machine.execute({LDR R2 R0 1, RET R2});
assertEquals(expected, actual);
}
//To test B8 in Machine.
@Test public void b8Test()
{
final int expected = InvalidInstructionException;
final int actual = Machine.execute({LDR R2 R0 32, RET R2});
assertEquals(expected, actual);
}
//To test B9 in Machine.
@Test public void b9Test()
{
final int expected = InvalidInstructionException;
final int actual = Machine.execute({MOV R2 -65536, RET R2});
assertEquals(expected, actual);
}
//To test B10 in Machine.
@Test public void b10Test()
{
final int expected = 1;
final int actual = Machine.execute({MOV R2 1, RET R2});
assertEquals(expected, actual);
}
//To test B11 in Machine.
@Test public void b11Test()
{
final int expected = InvalidInstructionException;
final int actual = Machine.execute({MOV R2 65536, RET R2});
assertEquals(expected, actual);
}
//Read in a file containing a program and convert into a list of
//string instructions
private List<String> readInstructions(String file)
{
Charset charset = Charset.forName("UTF-8");
List<String> lines = null;
try {
lines = Files.readAllLines(FileSystems.getDefault().getPath(file), charset);
}
catch (Exception e){
System.err.println("Invalid input file! (stacktrace follows)");
e.printStackTrace(System.err);
System.exit(1);
}
return lines;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment