summaryrefslogtreecommitdiff
path: root/src/test/java/bjc/data
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2022-07-26 20:35:01 -0400
committerBen Culkin <scorpress@gmail.com>2022-07-26 20:35:01 -0400
commit629b6bc7444005915983ae8d86c89c4ae215729e (patch)
treeef50616792bfa4392ff9541218ebeaeca62458f0 /src/test/java/bjc/data
parent6ccd5d885084f983013584db35df60a22b76e521 (diff)
Restructure a bit
Diffstat (limited to 'src/test/java/bjc/data')
-rw-r--r--src/test/java/bjc/data/ArrayIteratorTest.java33
-rw-r--r--src/test/java/bjc/data/BooleanToggleTest.java52
-rw-r--r--src/test/java/bjc/data/CircularIteratorTest.java57
-rw-r--r--src/test/java/bjc/data/EitherTest.java35
-rw-r--r--src/test/java/bjc/data/QueuedIteratorTest.java73
5 files changed, 0 insertions, 250 deletions
diff --git a/src/test/java/bjc/data/ArrayIteratorTest.java b/src/test/java/bjc/data/ArrayIteratorTest.java
deleted file mode 100644
index 223eea2..0000000
--- a/src/test/java/bjc/data/ArrayIteratorTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- *
- */
-package bjc.data;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-/**
- * Test ArrayIterator
- * @author Ben Culkin
- *
- */
-public class ArrayIteratorTest {
-
- /**
- * Test ArrayIterator
- */
- @Test
- public void test() {
- ArrayIterator<String> itr = new ArrayIterator<>("a", "b", "c");
-
- assertTrue(itr.hasNext());
- assertEquals("a", itr.next());
- assertEquals("b", itr.next());
- assertEquals("c", itr.next());
-
- assertFalse(itr.hasNext());
- assertNull(itr.next());
- }
-
-}
diff --git a/src/test/java/bjc/data/BooleanToggleTest.java b/src/test/java/bjc/data/BooleanToggleTest.java
deleted file mode 100644
index 0b0937f..0000000
--- a/src/test/java/bjc/data/BooleanToggleTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package bjc.data;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-/**
- * Test for boolean toggles.
- *
- * @author bjculkin
- *
- */
-public class BooleanToggleTest {
-
- /**
- * Test that boolean toggles work right.
- */
- @Test
- public void test() {
- BooleanToggle tog = new BooleanToggle();
-
- // Check initial value is false.
- assertEquals(false, tog.peek());
- // Check that 'get' returns the old value
- assertEquals(false, tog.get());
- // Check that 'get' swaps the value
- assertEquals(true, tog.peek());
- // Check that we can round-trip back.
- assertEquals(true, tog.get());
- assertEquals(false, tog.peek());
-
- tog.set(true);
-
- // Check set works
- assertEquals(true, tog.peek());
-
- BooleanToggle tog2 = new BooleanToggle(true);
-
- // Test equals/hashcode
- assertEquals(tog, tog2);
- assertEquals(tog.hashCode(), tog2.hashCode());
-
- // Swap toggle
- tog2.get();
-
- assertNotEquals(tog.hashCode(), tog2.hashCode());
- assertNotEquals(tog, tog2);
-
- // Test toString
- assertEquals("true", tog.toString());
- }
-}
diff --git a/src/test/java/bjc/data/CircularIteratorTest.java b/src/test/java/bjc/data/CircularIteratorTest.java
deleted file mode 100644
index 8091e1c..0000000
--- a/src/test/java/bjc/data/CircularIteratorTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package bjc.data;
-
-import static bjc.TestUtils.*;
-import java.util.*;
-
-import org.junit.Test;
-
-/**
- * Test for circular iterators.,
- *
- * @author bjculkin
- *
- */
-public class CircularIteratorTest {
- /**
- * Test regular repetition of the entire iterator.
- */
- @Test
- public void testRegular() {
- List<String> lst = Arrays.asList("a", "b", "c");
-
- CircularIterator<String> itr = new CircularIterator<>(lst);
-
- // Check we get initial values correctly, and have more remaining
- assertIteratorEquals(true, itr, "a", "b", "c");
-
- // Check we repeat correctly, and can still repeat
- assertIteratorEquals(true, itr, "a", "b", "c");
- }
-
- /**
- * Test that the last element repeats correctly.
- */
- @Test
- public void testRepLast() {
- List<String> lst = Arrays.asList("a", "b", "c");
-
- CircularIterator<String> itr = new CircularIterator<>(lst, false);
-
- // Check we get initial values correctly, and have more remaining
- assertIteratorEquals(true, itr, "a", "b", "c");
-
- // Check we repeat correctly, and can still repeat
- assertIteratorEquals(true, itr, "c", "c", "c");
- }
-
- /**
- * Test that remove throws an exception.
- */
- @Test(expected = UnsupportedOperationException.class)
- public void testRemove() {
- Iterator<String> arrayItr = new ArrayIterator<>("a", "b");
- CircularIterator<String> itr = new CircularIterator<>(() -> arrayItr);
-
- itr.remove();
- }
-}
diff --git a/src/test/java/bjc/data/EitherTest.java b/src/test/java/bjc/data/EitherTest.java
deleted file mode 100644
index ef2d12b..0000000
--- a/src/test/java/bjc/data/EitherTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package bjc.data;
-
-import static org.junit.Assert.*;
-
-import java.util.*;
-
-import org.junit.*;
-
-@SuppressWarnings("javadoc")
-public class EitherTest
-{
- private Either<String, String> leftEither;
- private Either<String, String> rightEither;
-
- @Before
- public void setUp() throws Exception {
- leftEither = Either.left("left");
- rightEither = Either.right("right");
- }
-
- @Test
- public void testIsLeft() {
- assertTrue("isLeft properly marks left eithers", leftEither.isLeft());
- assertFalse("isLeft properly marks right eithers", rightEither.isLeft());
- }
-
- @Test
- public void testGetLeft() {
- assertEquals("getLeft treats left eithers properly",
- Optional.of("left"), leftEither.getLeft());
- assertEquals("getLeft treats right eithers properly",
- Optional.empty(), rightEither.getLeft());
- }
-
-}
diff --git a/src/test/java/bjc/data/QueuedIteratorTest.java b/src/test/java/bjc/data/QueuedIteratorTest.java
deleted file mode 100644
index b880f97..0000000
--- a/src/test/java/bjc/data/QueuedIteratorTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package bjc.data;
-
-import static java.util.Arrays.asList;
-
-import org.junit.Test;
-
-import static bjc.TestUtils.*;
-import static bjc.data.QueuedIterator.queued;
-
-/**
- * Test of QueuedIterator.
- *
- * @author bjculkin
- *
- */
-public class QueuedIteratorTest {
-
- /**
- * Test of functionality.
- */
- @Test
- public void test() {
- assertIteratorEquals(false, queued());
-
- assertIteratorEquals(false, queued(1, 2, 3), 1, 2, 3);
- assertIteratorEquals(false, queued(asList(1, 2, 3), asList(3, 2, 1)), 1, 2, 3, 3,
- 2, 1);
-
- }
-
- /**
- * Test of before() method.
- */
- @Test
- public void testBefore() {
- QueuedIterator<Integer> itr = queued(1, 2, 3);
-
- assertIteratorEquals(true, itr, 1, 2);
-
- itr.before(1, 2, 3);
-
- assertIteratorEquals(false, itr, 1, 2, 3, 3);
- }
-
- /**
- * Test of after() method.
- */
- @Test
- public void testAfter() {
- QueuedIterator<Integer> itr = queued(1, 2, 3);
-
- assertIteratorEquals(true, itr, 1, 2);
-
- itr.after(1, 2, 3);
-
- assertIteratorEquals(false, itr, 3, 1, 2, 3);
- }
-
- /**
- * Test of last() method.
- */
- @Test
- public void testLast() {
- QueuedIterator<Integer> itr = queued(1, 2, 3);
-
- assertIteratorEquals(true, itr, 1, 2);
-
- itr.after(4);
- itr.last(1, 2, 3);
-
- assertIteratorEquals(false, itr, 3, 4, 1, 2, 3);
- }
-}