Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs2-20wi
project03
Commits
00ca9f78
Commit
00ca9f78
authored
4 years ago
by
Archie Shahidullah
Browse files
Options
Download
Email Patches
Plain Diff
Update GuitarStringTests.java
parent
c9adaeb6
1 merge request
!1
Review Tests for Project 3
Pipeline
#36410
canceled with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/edu/caltech/cs2/project03/GuitarStringTests.java
+14
-0
tests/edu/caltech/cs2/project03/GuitarStringTests.java
with
14 additions
and
0 deletions
+14
-0
tests/edu/caltech/cs2/project03/GuitarStringTests.java
View file @
00ca9f78
...
...
@@ -81,6 +81,13 @@ public class GuitarStringTests {
Reflection
.
assertNoPublicFields
(
CircularArrayFixedSizeQueueGuitarString
.
class
);
}
@Order
(
classSpecificTestLevel
)
@DisplayName
(
"There are no protected fields"
)
@Test
public
void
testNoProtectedFields
()
{
Reflection
.
assertNoProtectedFields
(
CircularArrayFixedSizeQueueGuitarString
.
class
);
}
@Order
(
classSpecificTestLevel
)
@DisplayName
(
"The public interface is correct"
)
@Test
...
...
@@ -133,6 +140,7 @@ public class GuitarStringTests {
assertEquals
(
0
,
val
,
"initial values must be 0"
);
}
string
.
pluck
();
queue
=
getQueueFromString
(
string
);
double
sum
=
0
;
double
absSum
=
0
;
for
(
double
val
:
queue
){
...
...
@@ -172,11 +180,13 @@ public class GuitarStringTests {
// Pass through the same number of tics as elements in the array
for
(
int
i
=
0
;
i
<
initSize
;
i
++){
string
.
tic
();
queue
=
getQueueFromString
(
string
);
assertEquals
(
initSize
,
queue
.
size
(),
"queue size must remain the same"
);
}
// Compare peek() values with the expected values in the files
while
(
in
.
hasNext
())
{
string
.
tic
();
queue
=
getQueueFromString
(
string
);
assertEquals
(
initSize
,
queue
.
size
(),
"queue size must remain the same"
);
assertEquals
(
in
.
nextDouble
(),
queue
.
peek
(),
"next expected value not at front of queue"
);
}
...
...
@@ -202,12 +212,14 @@ public class GuitarStringTests {
assertEquals
(
expectedLength
,
string
.
length
(),
"Length should be same as expected"
);
assertEquals
(
queue
.
size
(),
string
.
length
(),
"Length should be same as queue size"
);
string
.
pluck
();
queue
=
getQueueFromString
(
string
);
assertEquals
(
initSize
,
string
.
length
(),
"Length should not have changed from beginning"
);
assertEquals
(
queue
.
size
(),
string
.
length
(),
"Length should be same as queue size"
);
// Run through many iterations, making sure both the queue size and length are constant
for
(
int
i
=
0
;
i
<
iterations
;
i
++)
{
string
.
tic
();
queue
=
getQueueFromString
(
string
);
assertEquals
(
initSize
,
string
.
length
(),
"Length should not have changed from beginning"
);
assertEquals
(
queue
.
size
(),
string
.
length
(),
"Length should be same as queue size"
);
}
...
...
@@ -233,11 +245,13 @@ public class GuitarStringTests {
assertEquals
(
0
,
string
.
sample
(),
"Sample should return 0 before plucking"
);
assertEquals
(
queue
.
peek
(),
string
.
sample
(),
"Sample should same as peek()ing queue"
);
string
.
pluck
();
queue
=
getQueueFromString
(
string
);
assertEquals
(
queue
.
peek
(),
string
.
sample
(),
"Sample should same as peek()ing queue"
);
// Run through many iterations, making sure sample() matches peek()
for
(
int
i
=
0
;
i
<
iterations
;
i
++)
{
string
.
tic
();
queue
=
getQueueFromString
(
string
);
assertEquals
(
queue
.
peek
(),
string
.
sample
(),
"Sample should same as peek()ing queue"
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help