@TestDescription("This test checks that you use constants (static, final, private) fields for the default capacity and the growth factor when the array resizes.")
assertEquals(10,backingArray.length,"Default initial capacity is not 10");
}
@Order(complexityTestLevel)
@Order(implSpecificTestLevel)
@DisplayName("push() and pop() take constant time")
@DisplayName("enqueue should always succeed")
@Timeout(value=10,unit=SECONDS)
@TestDescription("This test is checking every enqueue in your ArrayDeque returns true.\nThe only time an enqueue might return false is if it doesn't resize (like in the B Tests).")
@TestDescription("This test is checking every push in your ArrayDeque returns true.\nThe only time a push might return false is if it doesn't resize (like in the B Tests).")
@DependsOn({"fields","constructors","push"})
@Test
publicvoidtestThatArrayDequePushAlwaysSucceeds(){
ArrayDeque<Integer>impl=newArrayDeque<>();
for(inti=0;i<100;i++){
assertTrue(impl.push(i),"push() should always succeed for ArrayDeque");
assertEquals(reference.toString(),me.toString(),"toString outputs should be the same");
reference.addLast(value);
me.enqueue(value);
}
}
}
}
// TIME COMPLEXITY TESTS ------------------------------------------------
@DisplayName("Implementation Tests")
@Nested
@Order(complexityTestLevel)
classImplementationTests{
@DisplayName("enqueue() and dequeue() take constant time")
@Order(fixedSizeQueueLevel)
@Timeout(value=10,unit=SECONDS)
@DisplayName("Test iterator matches reference for wraparound values")
@Test()
@TestHint("This test is likely failing because you don't have correct wrap-around behavior.\n Remember that everything should advance; so, it's possible that your start wraps around.")
publicvoidtestQueueOperationComplexity(){
@ParameterizedTest(name="Test iterator and wraparound behavior with {1} random values with seed = {0} and fixed array size = {2}")
fail(whatIsBeingTested+" is expected to be "+expected+" time or better. The actual calculated time is "+calculated+".\nThis test is non-deterministic which means it might not always be correct. If you run it multiple times and it usually passes, that's probably fine.");
fail(whatIsBeingTested+" is expected to be "+expected+" time or better. The actual calculated time is "+calculated+".");//"\nThis test is non-deterministic which means it might not always be correct. If you run it multiple times and it usually passes, that's probably fine.");