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
He Zhu
SWEN90006-A1-2018
Commits
2221fb36
Commit
2221fb36
authored
6 years ago
by
He Zhu
Browse files
Options
Downloads
Patches
Plain Diff
Delete BoundaryTests.java
parent
41af50df
Branches
Branches containing commit
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
-232
0 additions, 232 deletions
test/swen90006/machine/BoundaryTests.java
with
0 additions
and
232 deletions
test/swen90006/machine/BoundaryTests.java
deleted
100644 → 0
+
0
−
232
View file @
41af50df
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
{
Machine
m
=
new
Machine
();
//Test valid case when the Ra in RET holds some value
@Test
public
void
TestEC1
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC1.s"
);
m
.
execute
(
lines
);
}
//Test on points for register is valid
@Test
public
void
TestEC2a
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC2a.s"
);
m
.
execute
(
lines
);
}
//Test on points for register is valid
@Test
public
void
TestEC2b
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC2b.s"
);
m
.
execute
(
lines
);
}
//Test on point for Rc is not equal to 0
@Test
public
void
TestEC3a
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC3a.s"
);
m
.
execute
(
lines
);
}
//Test off point for Rc is 0
@Test
public
void
TestEC3b
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC3b.s"
);
m
.
execute
(
lines
);
//"no op" for dividend is 0, so there should throw no exception
}
//Test off point for val is not equal to 1
@Test
(
expected
=
NoReturnValueException
.
class
)
public
void
TestEC5
()
throws
Throwable
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC5.s"
);
m
.
execute
(
lines
);
throw
new
NoReturnValueException
();
}
//Test on point for the val is the length of the program
@Test
public
void
TestEC6
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC6.s"
);
m
.
execute
(
lines
);
}
//Test off point for val is greater than the length of the program
@Test
(
expected
=
NoReturnValueException
.
class
)
public
void
TestEC7
()
throws
Throwable
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC7.s"
);
m
.
execute
(
lines
);
throw
new
NoReturnValueException
();
}
//Test on point for value belongs to {-65535,...,65535}
@Test
public
void
TestEC10a
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC10a.s"
);
m
.
execute
(
lines
);
}
//Test on point for value belongs to {-65535,...,65535}
@Test
public
void
TestEC10b
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC10b.s"
);
m
.
execute
(
lines
);
}
//Test off point for value belongs to {-65535,...,65535}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
TestEC10c
()
throws
Throwable
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC10c.s"
);
m
.
execute
(
lines
);
throw
new
InvalidInstructionException
();
}
//Test on point for pc value in LDR is valid
@Test
public
void
TestEC11a
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC11a.s"
);
m
.
execute
(
lines
);
}
//Test on point for pc value in LDR is valid
@Test
public
void
TestEC11b
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC11b.s"
);
m
.
execute
(
lines
);
}
//Test off point for pc value in LDR is valid
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
TestEC11c
()
throws
Throwable
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC11c.s"
);
m
.
execute
(
lines
);
throw
new
InvalidInstructionException
();
}
//Test on point for JZ instruction is valid
@Test
public
void
TestEC13
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC13.s"
);
m
.
execute
(
lines
);
}
//Test off point for JZ instruction is valid
@Test
(
expected
=
NoReturnValueException
.
class
)
public
void
TestEC14
()
throws
Throwable
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC14.s"
);
m
.
execute
(
lines
);
throw
new
NoReturnValueException
();
}
//Test on point for JZ instruction is valid with Ra is 0
@Test
public
void
TestEC15
()
{
final
List
<
String
>
lines
=
readInstructions
(
"boundaryEC15.s"
);
m
.
execute
(
lines
);
}
//Any method annotation with "@Test" is executed as a test.
@Test
public
void
aTest
()
{
//the assertEquals method used to check whether two values are
//equal, using the equals method
final
int
expected
=
2
;
final
int
actual
=
1
+
1
;
assertEquals
(
expected
,
actual
);
}
@Test
public
void
anotherTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"a"
);
list
.
add
(
"b"
);
//the assertTrue method is used to check whether something holds.
assertTrue
(
list
.
contains
(
"a"
));
}
//To test an exception, specify the expected exception after the @Test
@Test
(
expected
=
java
.
io
.
IOException
.
class
)
public
void
anExceptionTest
()
throws
Throwable
{
throw
new
java
.
io
.
IOException
();
}
//This test should fail.
//To provide additional feedback when a test fails, an error message
//can be included
@Test
public
void
aFailedTest
()
{
//include a message for better feedback
final
int
expected
=
2
;
final
int
actual
=
1
+
2
;
assertEquals
(
"Some failure message"
,
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