Commit 00ca9f78 authored by Archie Shahidullah's avatar Archie Shahidullah :expressionless:
Browse files

Update GuitarStringTests.java

parent c9adaeb6
1 merge request!1Review Tests for Project 3
Pipeline #36410 canceled with stage
Showing with 14 additions and 0 deletions
+14 -0
......@@ -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");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment