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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hongyi Chen
SWEN90006-A1-2018
Commits
ff0c4fea
Commit
ff0c4fea
authored
Sep 3, 2018
by
Hongyi Chen
Browse files
Options
Downloads
Patches
Plain Diff
Replace PartitioningTests.java
parent
564dfcde
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/PartitioningTests.java
+141
-0
141 additions, 0 deletions
test/swen90006/machine/PartitioningTests.java
with
141 additions
and
0 deletions
test/swen90006/machine/PartitioningTests.java
+
141
−
0
View file @
ff0c4fea
...
@@ -71,6 +71,147 @@ public class PartitioningTests
...
@@ -71,6 +71,147 @@ public class PartitioningTests
assertEquals
(
"Some failure message"
,
expected
,
actual
);
assertEquals
(
"Some failure message"
,
expected
,
actual
);
}
}
@Test
public
void
EC1TestCase
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"RET R1"
);
Machine
machine
=
new
Machine
();
int
actual
=
0
;
assertEquals
(
machine
.
execute
(
list
),
actual
);
}
@Test
(
expected
=
NoReturnValueException
.
class
)
public
void
EC2ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"ADD R1 R2 R3"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
EC3ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"CMP R1 R2"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
EC4ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"ADD R1 R2 R-1"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
EC5ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"CMP R32 R2 R3"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
public
void
EC6TestCase
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"MOV R1 2"
);
list
.
add
(
"MOV R2 3"
);
list
.
add
(
"ADD R3 R1 R2"
);
list
.
add
(
"RET R3"
);
Machine
machine
=
new
Machine
();
int
actual
=
5
;
assertEquals
(
machine
.
execute
(
list
),
actual
);
}
@Test
public
void
EC7TestCase
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"MOV R1 2"
);
list
.
add
(
"MOV R2 3"
);
list
.
add
(
"ADD R3 R1 R2"
);
list
.
add
(
"RET R2"
);
list
.
add
(
"RET R3"
);
Machine
machine
=
new
Machine
();
int
actual
=
3
;
assertEquals
(
machine
.
execute
(
list
),
actual
);
}
@Test
(
expected
=
NoReturnValueException
.
class
)
public
void
EC8ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"MOV R1 2"
);
list
.
add
(
"MOV R2 3"
);
list
.
add
(
"ADD R3 R1 R2"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
EC9ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"MOV R1 2"
);
list
.
add
(
"MOV R2 3"
);
list
.
add
(
"CMP R1 R2"
);
list
.
add
(
"ADD R3 R1 R2"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
EC10ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"MOV R1 6"
);
list
.
add
(
"MOV R2 -66666"
);
list
.
add
(
"ADD R3 R1 R2"
);
list
.
add
(
"RET R3"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
EC11ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"MOV R1 6"
);
list
.
add
(
"MOV R2 66666"
);
list
.
add
(
"ADD R3 R1 R2"
);
list
.
add
(
"RET R3"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
EC12ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"MOV R1 6"
);
list
.
add
(
"MOV R-2 7"
);
list
.
add
(
"ADD R3 R1 R-2"
);
list
.
add
(
"RET R3"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
@Test
(
expected
=
InvalidInstructionException
.
class
)
public
void
EC13ExceptionTest
()
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
list
.
add
(
"MOV R1 6"
);
list
.
add
(
"MOV R38 7"
);
list
.
add
(
"ADD R3 R1 R38"
);
list
.
add
(
"RET R3"
);
Machine
machine
=
new
Machine
();
machine
.
execute
(
list
);
}
//Read in a file containing a program and convert into a list of
//Read in a file containing a program and convert into a list of
//string instructions
//string instructions
private
List
<
String
>
readInstructions
(
String
file
)
private
List
<
String
>
readInstructions
(
String
file
)
...
...
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