From 7e449ded6e7363ca759cb028b4f16dc0eaec264b Mon Sep 17 00:00:00 2001 From: Oshgnacknak Date: Sun, 5 Sep 2021 15:25:12 +0200 Subject: [PATCH] Asserts for check --- .../list/DoubleListItemProcessorTest.java | 51 +++++++++++++++++++ .../RecursiveDoubleListItemProcessorTest.java | 6 +-- 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 test/aud/exam/prep/list/DoubleListItemProcessorTest.java diff --git a/test/aud/exam/prep/list/DoubleListItemProcessorTest.java b/test/aud/exam/prep/list/DoubleListItemProcessorTest.java new file mode 100644 index 0000000..85be768 --- /dev/null +++ b/test/aud/exam/prep/list/DoubleListItemProcessorTest.java @@ -0,0 +1,51 @@ +package aud.exam.prep.list; + +import aud.exam.prep.SequenceProcessor; +import aud.exam.prep.SequenceProcessorTest; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +abstract class DoubleListItemProcessorTest extends SequenceProcessorTest> { + + protected DoubleListItemProcessorTest(SequenceProcessor> processor) { + super(processor); + } + + @Test + void testThat_checkOfNullIsTrue() { + assertTrue(processor.check(null)); + } + + @Test + void testThat_checkOfNoKeyIsFalse() { + var item = new DoubleListItem(); + assertFalse(processor.check(item)); + } + + @Test + void testThat_checkOfNoPrevOfNextIsFalse() { + var item = new DoubleListItem(); + item.key = 1; + + item.next = new DoubleListItem<>(); + item.next.key = 1; + + assertFalse(processor.check(item)); + } + + @Test + void testThat_checkOfCircleIsFalse() { + var item = new DoubleListItem(); + item.next = item; + assertFalse(processor.check(item)); + } + + @Test + void testThat_checkPrevNextNotMatchingIsFalse() { + var item = new DoubleListItem(); + item.next = new DoubleListItem<>(); + item.next.prev = new DoubleListItem<>(); + assertFalse(processor.check(item)); + } +} \ No newline at end of file diff --git a/test/aud/exam/prep/list/RecursiveDoubleListItemProcessorTest.java b/test/aud/exam/prep/list/RecursiveDoubleListItemProcessorTest.java index 60ab264..e3d8d09 100644 --- a/test/aud/exam/prep/list/RecursiveDoubleListItemProcessorTest.java +++ b/test/aud/exam/prep/list/RecursiveDoubleListItemProcessorTest.java @@ -1,10 +1,8 @@ package aud.exam.prep.list; -import aud.exam.prep.SequenceProcessorTest; - -class RecursiveDoubleListItemProcessorTest extends SequenceProcessorTest> { +public class RecursiveDoubleListItemProcessorTest extends DoubleListItemProcessorTest { protected RecursiveDoubleListItemProcessorTest() { super(new RecursiveDoubleListItemProcessor<>()); } -} \ No newline at end of file +}