Commit 3c2a0681 authored by Adam Blank's avatar Adam Blank
Browse files

Merge branch 'update-tests' into 'master'

Collection of small changes to how tests display

See merge request !1
parents 1136a4b3 4d5197b7
Pipeline #77449 failed with stage
in 0 seconds
Showing with 19 additions and 29 deletions
+19 -29
...@@ -168,9 +168,9 @@ public class BSTDictionaryTests extends IDictionaryNGramTests { ...@@ -168,9 +168,9 @@ public class BSTDictionaryTests extends IDictionaryNGramTests {
@Test @Test
@Order(classSpecificTestLevel) @Order(classSpecificTestLevel)
@DisplayName("Test BST Implementation") @DisplayName("Test binary search tree is structured correctly")
@TestDescription("This test is testing sample keys and values to make sure the BST stores the values correctly.") @TestDescription("This test is testing sample keys and values to make sure the BST stores the values correctly.")
@DependsOn({"put", "toString"}) @DependsOn({"put"})
public void testActualBST() { public void testActualBST() {
BSTDictionary<String, Integer> bst = new BSTDictionary<>(); BSTDictionary<String, Integer> bst = new BSTDictionary<>();
......
...@@ -212,7 +212,7 @@ public class ChainingHashDictionaryTests extends IDictionaryNGramTests { ...@@ -212,7 +212,7 @@ public class ChainingHashDictionaryTests extends IDictionaryNGramTests {
@Test @Test
@TestDescription("This test checks that you use the provided supplier function when resizing the dictionary.") @TestDescription("This test checks that you use the provided supplier function when resizing the dictionary.")
@TestHint("Make sure you are initializing all the buckets of the resized dictionary appropriately with the supplier function. Do not use streams.") @TestHint("Make sure you are initializing all the buckets of the resized dictionary appropriately with the supplier function. Do not use streams.")
@DependsOn({"put", "remove"}) @DependsOn({"put"})
public void testSupplierUsage() { public void testSupplierUsage() {
// Reset from any previous tests // Reset from any previous tests
supplierCounter.resetCounter(); supplierCounter.resetCounter();
......
...@@ -86,7 +86,7 @@ public abstract class IDictionaryNGramTests extends IDictionaryTests { ...@@ -86,7 +86,7 @@ public abstract class IDictionaryNGramTests extends IDictionaryTests {
class ComplexityTestsNGram { class ComplexityTestsNGram {
@Order(specialTestLevel) @Order(specialTestLevel)
@DisplayName("Test get() complexity with NGram keys") @DisplayName("Test get() complexity with NGram keys")
@DependsOn({"get"}) @DependsOn({"put", "get"})
@Test @Test
@Timeout(value = 20, unit = SECONDS) @Timeout(value = 20, unit = SECONDS)
public void testGetComplexity() { public void testGetComplexity() {
...@@ -126,7 +126,7 @@ public abstract class IDictionaryNGramTests extends IDictionaryTests { ...@@ -126,7 +126,7 @@ public abstract class IDictionaryNGramTests extends IDictionaryTests {
@Order(specialTestLevel) @Order(specialTestLevel)
@DisplayName("Test remove() complexity with NGram keys") @DisplayName("Test remove() complexity with NGram keys")
@DependsOn({"remove"}) @DependsOn({"put", "remove"})
@Test @Test
@Timeout(value = 20, unit = SECONDS) @Timeout(value = 20, unit = SECONDS)
public void testRemoveComplexity() { public void testRemoveComplexity() {
...@@ -146,7 +146,7 @@ public abstract class IDictionaryNGramTests extends IDictionaryTests { ...@@ -146,7 +146,7 @@ public abstract class IDictionaryNGramTests extends IDictionaryTests {
@Order(specialTestLevel) @Order(specialTestLevel)
@DisplayName("Test size() complexity with NGram keys") @DisplayName("Test size() complexity with NGram keys")
@DependsOn({"size"}) @DependsOn({"put", "size"})
@Timeout(value = 20, unit = SECONDS) @Timeout(value = 20, unit = SECONDS)
public void testSizeComplexity() { public void testSizeComplexity() {
Function<Integer, IDictionary<Object, Object>> provide = (Integer numElements) -> { Function<Integer, IDictionary<Object, Object>> provide = (Integer numElements) -> {
......
...@@ -250,7 +250,7 @@ public abstract class IDictionaryTests { ...@@ -250,7 +250,7 @@ public abstract class IDictionaryTests {
@ParameterizedTest(name = "Test IDictionary interface with seed={0} and size={1}") @ParameterizedTest(name = "Test IDictionary interface with seed={0} and size={1}")
@CsvSource({"24589, 3000", "96206, 5000"}) @CsvSource({"24589, 3000", "96206, 5000"})
@TestDescription("Creates random data to test the stability of the IDictionary; DOES test remove.") @TestDescription("Creates random data to test the stability of the IDictionary; DOES test remove.")
@DependsOn({"put", "size", "get", "keys", "iterator", "values", "containsKey", "containsValue"}) @DependsOn({"put", "size", "get", "keys", "iterator", "values", "containsKey", "containsValue", "remove"})
void stressTestIDictionaryRemove(int seed, int size) { void stressTestIDictionaryRemove(int seed, int size) {
iDictionaryStressTestHelper(seed, size, true); iDictionaryStressTestHelper(seed, size, true);
} }
......
...@@ -90,7 +90,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests { ...@@ -90,7 +90,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests {
class RuntimeTestsBest { class RuntimeTestsBest {
@Order(specialTestLevel) @Order(specialTestLevel)
@DisplayName("Test get() best case complexity with int keys") @DisplayName("Test get() best case complexity with int keys")
@DependsOn({"get"}) @DependsOn({"put", "get"})
@Test @Test
@Timeout(value = 20, unit = SECONDS) @Timeout(value = 20, unit = SECONDS)
public void testBestCase() { public void testBestCase() {
...@@ -139,24 +139,11 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests { ...@@ -139,24 +139,11 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests {
@Order(0) @Order(0)
@Nested @Nested
class ImplementationTests { class ImplementationTests {
@Order(classSpecificTestLevel)
@DisplayName("Check for linked node class")
@TestDescription("This test checks that hat there is a Node class in the MoveToFrontDictionary")
@Test
public void testLinkedNode() {
Class[] classes = MoveToFrontDictionary.class.getDeclaredClasses();
for (Class clazz : classes) {
if (Iterator.class.isAssignableFrom(clazz)) {
continue;
}
MoveToFrontChecker.isNode(clazz);
}
}
@Order(classSpecificTestLevel) @Order(classSpecificTestLevel)
@DisplayName("Check MoveToFrontDictionary class is properly implemented") @DisplayName("Check MoveToFrontDictionary class is properly implemented")
@TestDescription("This test makes sure that the implementation of the MoveToFront dictionary, i.e. like having the right fields") @TestDescription("This test makes sure that the implementation of the MoveToFront dictionary, i.e. like having the right fields")
@TestHint("MoveToFrontDictionary should only have a head node and an int field to store size") @TestHint("MoveToFrontDictionary should only have a head node and an int field to store size. It should also implement a Node class.")
@DependsOn({"fields", "node class"})
@Test @Test
public void checkMTF() { public void checkMTF() {
MoveToFrontChecker.checkClass(MoveToFrontDictionary.class); MoveToFrontChecker.checkClass(MoveToFrontDictionary.class);
...@@ -182,7 +169,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests { ...@@ -182,7 +169,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests {
@Order(classSpecificTestLevel) @Order(classSpecificTestLevel)
@DisplayName("Check for excessive node allocation in get") @DisplayName("Check for excessive node allocation in get")
@TestDescription("This test checks that no extra nodes are allocated in the get() method") @TestDescription("This test checks that no extra nodes are allocated in the get() method")
@DependsOn({"get"}) @DependsOn({"put", "get"})
@Test @Test
public void testForExcessiveNodeAllocationGet() { public void testForExcessiveNodeAllocationGet() {
NewNode.MoveToFrontDictionary_NUM_CALLS = 0; NewNode.MoveToFrontDictionary_NUM_CALLS = 0;
...@@ -203,7 +190,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests { ...@@ -203,7 +190,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests {
@Order(classSpecificTestLevel) @Order(classSpecificTestLevel)
@DisplayName("Check for excessive Node allocation in remove") @DisplayName("Check for excessive Node allocation in remove")
@TestDescription("This test checks that no extra nodes are allocated in the remove() method") @TestDescription("This test checks that no extra nodes are allocated in the remove() method")
@DependsOn({"remove"}) @DependsOn({"put", "remove"})
@Test @Test
public void testForExcessiveNodeAllocationRemove() { public void testForExcessiveNodeAllocationRemove() {
NewObjectArray.NUM_CALLS = 0; NewObjectArray.NUM_CALLS = 0;
...@@ -225,6 +212,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests { ...@@ -225,6 +212,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests {
@Test @Test
@DisplayName("Sanity check that accessing keys in various locations in the dictionary works") @DisplayName("Sanity check that accessing keys in various locations in the dictionary works")
@TestDescription("This test tries to obtain and remove data from various parts of the dictionary (front, back) to make sure its in the data structure") @TestDescription("This test tries to obtain and remove data from various parts of the dictionary (front, back) to make sure its in the data structure")
@DependsOn({"put", "get", "remove"})
@Order(classSpecificTestLevel) @Order(classSpecificTestLevel)
public void testDataLocations() { public void testDataLocations() {
MoveToFrontDictionary<Integer, Integer> impl = new MoveToFrontDictionary<>(); MoveToFrontDictionary<Integer, Integer> impl = new MoveToFrontDictionary<>();
...@@ -266,6 +254,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests { ...@@ -266,6 +254,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests {
@DisplayName("Test that referencing a key moves it to the front") @DisplayName("Test that referencing a key moves it to the front")
@TestDescription("This test is checking the fundamental principle of the MoveToFrontDictionary - that when you access a key, it does get moved to the front") @TestDescription("This test is checking the fundamental principle of the MoveToFrontDictionary - that when you access a key, it does get moved to the front")
@TestHint("Make sure to move to front in both containsKey and get") @TestHint("Make sure to move to front in both containsKey and get")
@DependsOn({"put", "containsKey", "get"})
@Order(specialTestLevel) @Order(specialTestLevel)
public void testMoveToFrontProperty() { public void testMoveToFrontProperty() {
MoveToFrontDictionary<Integer, Integer> impl = new MoveToFrontDictionary<>(); MoveToFrontDictionary<Integer, Integer> impl = new MoveToFrontDictionary<>();
...@@ -308,6 +297,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests { ...@@ -308,6 +297,7 @@ public class MoveToFrontDictionaryTests extends IDictionaryNGramTests {
@DisplayName("Test removing from the front has the desired behavior") @DisplayName("Test removing from the front has the desired behavior")
@TestDescription("This test makes sure that removing from the front updates the head and the rest of the linked list correctly") @TestDescription("This test makes sure that removing from the front updates the head and the rest of the linked list correctly")
@TestHint("Make sure you update your head field correctly in removal, and that if a key is removed, the MoveToFrontDictionary is able to recognize and handle that") @TestHint("Make sure you update your head field correctly in removal, and that if a key is removed, the MoveToFrontDictionary is able to recognize and handle that")
@DependsOn({"put", "get", "remove", "values"})
@Test @Test
public void testFrontRemove() { public void testFrontRemove() {
MoveToFrontDictionary<Integer, Integer> impl = new MoveToFrontDictionary<>(); MoveToFrontDictionary<Integer, Integer> impl = new MoveToFrontDictionary<>();
......
...@@ -218,14 +218,14 @@ public class NGramTests { ...@@ -218,14 +218,14 @@ public class NGramTests {
for(NGram A : diff_length) { for(NGram A : diff_length) {
for(NGram B : diff_length) { for(NGram B : diff_length) {
assertFalse(A.equals(B) && A.hashCode() != B.hashCode(), "The hashCode function returns different values for two equal NGrams"); assertTrue(!A.equals(B) || A.hashCode() == B.hashCode(), "The hashCode function should return the same values for two equal NGrams");
assertFalse(!A.equals(B) && A.hashCode() == B.hashCode(), "The hashCode function returns the same hashCode for (simple) non-equal NGrams"); assertTrue(A.equals(B) || A.hashCode() != B.hashCode(), "The hashCode function should return different hashCodes for (simple) non-equal NGrams");
} }
} }
for(NGram A : permutations) { for(NGram A : permutations) {
for(NGram B : permutations) { for(NGram B : permutations) {
assertFalse(A.equals(B) && A.hashCode() != B.hashCode(), "The hashCode function returns different values for two equal NGrams"); assertTrue(!A.equals(B) || A.hashCode() == B.hashCode(), "The hashCode function should return the same values for two equal NGrams");
assertFalse(!A.equals(B) && A.hashCode() == B.hashCode(), "The hashCode function returns the same hashCode for (simple) non-equal NGrams"); assertTrue(A.equals(B) || A.hashCode() != B.hashCode(), "The hashCode function should return different hashCodes for (simple) non-equal NGrams");
} }
} }
} }
......
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