Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SWEN90006-A1-2018
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiaming Zhang
SWEN90006-A1-2018
Commits
051abe87
Commit
051abe87
authored
6 years ago
by
Jiaming Zhang
Browse files
Options
Downloads
Patches
Plain Diff
Delete BoundaryTests.java
parent
e46379cb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/swen90006/machine/BoundaryTests.java
+0
-107
0 additions, 107 deletions
test/swen90006/machine/BoundaryTests.java
with
0 additions
and
107 deletions
test/swen90006/machine/BoundaryTests.java
deleted
100644 → 0
+
0
−
107
View file @
e46379cb
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
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment