From 9a23fc4b27f33f80680814cff0ad0eadf5fa8540 Mon Sep 17 00:00:00 2001 From: Oshgnacknak Date: Sun, 29 Aug 2021 21:30:30 +0200 Subject: [PATCH] Test that a sequence remains "valid" after is has been modified. --- test/aud/exam/prep/SequenceProcessorTest.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/test/aud/exam/prep/SequenceProcessorTest.java b/test/aud/exam/prep/SequenceProcessorTest.java index 4fd202d..2c4e02f 100644 --- a/test/aud/exam/prep/SequenceProcessorTest.java +++ b/test/aud/exam/prep/SequenceProcessorTest.java @@ -24,6 +24,8 @@ public abstract class SequenceProcessorTest { @ArgumentsSource(ListProvider.class) void testThat_createAndIterateWork(List list) { S s = processor.create(list); + + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -69,6 +71,8 @@ public abstract class SequenceProcessorTest { S s = processor.create(list); assertFalse(processor.override(s, -1, -5)); assertFalse(processor.override(s, 999, -5)); + + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -82,6 +86,7 @@ public abstract class SequenceProcessorTest { assertTrue(processor.override(s, list.get(i), to)); list.set(i, to); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } } @@ -92,6 +97,8 @@ public abstract class SequenceProcessorTest { S s = processor.create(list); assertFalse(processor.overrideAll(s, -1, -5)); assertFalse(processor.overrideAll(s, 999, -5)); + + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -107,6 +114,7 @@ public abstract class SequenceProcessorTest { list.replaceAll(k -> Objects.equals(k, from) ? to : k); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } } @@ -117,6 +125,8 @@ public abstract class SequenceProcessorTest { S s = processor.create(list); assertFalse(processor.overrideAt(s, -5, -1)); assertFalse(processor.overrideAt(s, -5, 999)); + + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -130,6 +140,7 @@ public abstract class SequenceProcessorTest { assertTrue(processor.overrideAt(s, to, i)); list.set(i, to); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } } @@ -146,6 +157,7 @@ public abstract class SequenceProcessorTest { list.add(i); list.sort(cmp); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } } @@ -156,6 +168,8 @@ public abstract class SequenceProcessorTest { S s = processor.create(list); assertFalse(processor.remove(s, -1)); assertFalse(processor.remove(s, 999)); + + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -170,6 +184,7 @@ public abstract class SequenceProcessorTest { list.remove(toRemove); assertTrue(processor.remove(s, toRemove)); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } } @@ -180,6 +195,8 @@ public abstract class SequenceProcessorTest { S s = processor.create(list); assertFalse(processor.removeAll(s, -1)); assertFalse(processor.removeAll(s, 999)); + + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -194,6 +211,7 @@ public abstract class SequenceProcessorTest { list.removeAll(Collections.singleton(toRemove)); assertTrue(processor.removeAll(s, toRemove)); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } } @@ -343,8 +361,8 @@ public abstract class SequenceProcessorTest { processor.isLexSmaller(a, b, cmp)); assertEquals( - stringB.compareTo(stringA) < 0, - processor.isLexSmaller(b, a, cmp)); + stringB.compareTo(stringA) < 0, + processor.isLexSmaller(b, a, cmp)); } protected S toSequenceByAscii(String string) { @@ -367,6 +385,7 @@ public abstract class SequenceProcessorTest { .collect(Collectors.toList()); processor.doubleAllKeys(s); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -382,6 +401,7 @@ public abstract class SequenceProcessorTest { s = processor.rotateRight(s); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -397,6 +417,7 @@ public abstract class SequenceProcessorTest { s = processor.rotateLeft(s); + assertTrue(processor.check(s)); assertIterableEquals(list, processor.iterate(s)); } @@ -414,6 +435,7 @@ public abstract class SequenceProcessorTest { processor.removeDuplicates(s); + assertTrue(processor.check(s)); assertIterableEquals(noDuplicatesList, processor.iterate(s)); } } \ No newline at end of file