summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/bjc/TestUtils.java74
-rw-r--r--src/test/java/bjc/data/BooleanToggleTest.java7
-rw-r--r--src/test/java/bjc/data/CircularIteratorTest.java3
-rw-r--r--src/test/java/bjc/data/QueuedIteratorTest.java7
-rw-r--r--src/test/java/bjc/esodata/StackTest.java18
-rw-r--r--src/test/java/bjc/esodata/ThresholdSetTest.java4
6 files changed, 59 insertions, 54 deletions
diff --git a/src/test/java/bjc/TestUtils.java b/src/test/java/bjc/TestUtils.java
index c325877..17d6b7a 100644
--- a/src/test/java/bjc/TestUtils.java
+++ b/src/test/java/bjc/TestUtils.java
@@ -6,17 +6,17 @@ import static org.junit.Assert.*;
/**
* Utility methods for doing testing
- *
+ *
* @author Ben Culkin
*/
public class TestUtils {
/**
* Assert an iterator provides a particular sequence of values.
- *
+ *
* @param src
- * The iterator to pull values from.
+ * The iterator to pull values from.
* @param vals
- * The values to expect from the iterator.
+ * The values to expect from the iterator.
*/
@SafeVarargs
public static <T> void assertIteratorEquals(Iterator<T> src, T... vals) {
@@ -24,9 +24,9 @@ public class TestUtils {
if (src.hasNext()) {
assertEquals(vals[i], src.next());
} else {
- String msg = String.format("not enough values: got %d, wanted %d",
- i, vals.length);
-
+ String msg = String.format("not enough values: got %d, wanted %d", i,
+ vals.length);
+
assertTrue(msg, false);
}
}
@@ -34,7 +34,7 @@ public class TestUtils {
/**
* Assert an iterator provides a particular sequence of values.
- *
+ *
* @param src
* The iterator to pull values from.
* @param hasMore
@@ -43,14 +43,14 @@ public class TestUtils {
* The values to expect from the iterator.
*/
@SafeVarargs
- public static <T> void assertIteratorEquals(boolean hasMore, Iterator<T> src, T... vals) {
+ public static <T> void assertIteratorEquals(boolean hasMore, Iterator<T> src,
+ T... vals) {
/*
* @NOTE
- *
- * Even though it's awkward, the boolean has to come first.
- * Otherwise, there are cases where the compiler will get
- * confused as to what the right value for T is, and be unable
- * to pick an overload.
+ *
+ * Even though it's awkward, the boolean has to come first. Otherwise, there are
+ * cases where the compiler will get confused as to what the right value for T
+ * is, and be unable to pick an overload.
*/
assertIteratorEquals(src, vals);
@@ -59,35 +59,35 @@ public class TestUtils {
/**
* Assert an iterator provides a particular sequence of values.
- *
+ *
* @param src
- * The iterator to pull values from.
+ * The iterator to pull values from.
* @param vals
- * The values to expect from the iterator.
+ * The values to expect from the iterator.
*/
@SafeVarargs
public static <T> void assertIteratorSet(Iterator<T> src, T... vals) {
Set<T> s1 = new HashSet<>();
Set<T> s2 = new HashSet<>();
-
+
for (int i = 0; i < vals.length; i++) {
if (src.hasNext()) {
s1.add(vals[i]);
s2.add(src.next());
} else {
- String msg = String.format("not enough values: got %d, wanted %d",
- i, vals.length);
-
+ String msg = String.format("not enough values: got %d, wanted %d", i,
+ vals.length);
+
assertTrue(msg, false);
}
}
-
+
assertEquals(s1, s2);
}
/**
* Assert an iterator provides a particular sequence of values.
- *
+ *
* @param src
* The iterator to pull values from.
* @param hasMore
@@ -96,28 +96,28 @@ public class TestUtils {
* The values to expect from the iterator.
*/
@SafeVarargs
- public static <T> void assertIteratorSet(boolean hasMore, Iterator<T> src, T... vals) {
+ public static <T> void assertIteratorSet(boolean hasMore, Iterator<T> src,
+ T... vals) {
/*
* @NOTE
- *
- * Even though it's awkward, the boolean has to come first.
- * Otherwise, there are cases where the compiler will get
- * confused as to what the right value for T is, and be unable
- * to pick an overload.
+ *
+ * Even though it's awkward, the boolean has to come first. Otherwise, there are
+ * cases where the compiler will get confused as to what the right value for T
+ * is, and be unable to pick an overload.
*/
assertIteratorSet(src, vals);
assertEquals("iterator not exhausted", hasMore, src.hasNext());
}
-
+
/**
* Assert that a list contains a certain set of values.
- *
+ *
* @param src
- * The list to read values from.
- *
+ * The list to read values from.
+ *
* @param exps
- * The values to expect in the list.
+ * The values to expect in the list.
*/
@SafeVarargs
public static <T> void assertListEquals(List<T> src, T... exps) {
@@ -135,12 +135,12 @@ public class TestUtils {
* Assert a stack has the given contents.
*
* @param <T>
- * The type of items in the stack.
+ * The type of items in the stack.
*
* @param src
- * The stack to inspect.
+ * The stack to inspect.
* @param exps
- * The values that are expected.
+ * The values that are expected.
*/
public static <T> void assertStackEquals(bjc.esodata.Stack<T> src, T... exps) {
assertArrayEquals(exps, src.toArray());
diff --git a/src/test/java/bjc/data/BooleanToggleTest.java b/src/test/java/bjc/data/BooleanToggleTest.java
index 3fb4490..bf7a04f 100644
--- a/src/test/java/bjc/data/BooleanToggleTest.java
+++ b/src/test/java/bjc/data/BooleanToggleTest.java
@@ -6,6 +6,7 @@ import org.junit.Test;
/**
* Test for boolean toggles.
+ *
* @author bjculkin
*
*/
@@ -17,7 +18,7 @@ public class BooleanToggleTest {
@Test
public void test() {
BooleanToggle tog = new BooleanToggle();
-
+
// Check initial value is false.
assertEquals(false, tog.peek());
// Check that 'get' returns the old value
@@ -27,9 +28,9 @@ public class BooleanToggleTest {
// 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());
}
diff --git a/src/test/java/bjc/data/CircularIteratorTest.java b/src/test/java/bjc/data/CircularIteratorTest.java
index 289c62a..dfe2a17 100644
--- a/src/test/java/bjc/data/CircularIteratorTest.java
+++ b/src/test/java/bjc/data/CircularIteratorTest.java
@@ -6,9 +6,10 @@ import java.util.Arrays;
import java.util.List;
import org.junit.Test;
+
/**
* Test for circular iterators.,
- *
+ *
* @author bjculkin
*
*/
diff --git a/src/test/java/bjc/data/QueuedIteratorTest.java b/src/test/java/bjc/data/QueuedIteratorTest.java
index ef83469..b880f97 100644
--- a/src/test/java/bjc/data/QueuedIteratorTest.java
+++ b/src/test/java/bjc/data/QueuedIteratorTest.java
@@ -9,7 +9,7 @@ import static bjc.data.QueuedIterator.queued;
/**
* Test of QueuedIterator.
- *
+ *
* @author bjculkin
*
*/
@@ -23,7 +23,8 @@ public class QueuedIteratorTest {
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);
+ assertIteratorEquals(false, queued(asList(1, 2, 3), asList(3, 2, 1)), 1, 2, 3, 3,
+ 2, 1);
}
@@ -54,7 +55,7 @@ public class QueuedIteratorTest {
assertIteratorEquals(false, itr, 3, 1, 2, 3);
}
-
+
/**
* Test of last() method.
*/
diff --git a/src/test/java/bjc/esodata/StackTest.java b/src/test/java/bjc/esodata/StackTest.java
index 5dfe7d5..c6e8e21 100644
--- a/src/test/java/bjc/esodata/StackTest.java
+++ b/src/test/java/bjc/esodata/StackTest.java
@@ -131,7 +131,7 @@ public class StackTest {
assertStackEquals(st, "a", "a", "a", "a", "b", "a", "a");
st.drop(6);
-
+
assertStackEquals(st, "a");
st.push("b");
@@ -173,7 +173,7 @@ public class StackTest {
assertStackEquals(stk, 4, 3, 2);
- stk.dip((st) -> {
+ stk.dip(st -> {
int x = stk.pop();
int y = stk.pop();
@@ -182,13 +182,13 @@ public class StackTest {
assertStackEquals(stk, 4, 5);
- stk.dip(2, (st) -> {
+ stk.dip(2, st -> {
stk.push(6);
});
assertStackEquals(stk, 4, 5, 6);
- stk.keep((st) -> {
+ stk.keep(st -> {
int v = st.pop();
st.push(v + 1);
@@ -196,12 +196,12 @@ public class StackTest {
assertStackEquals(stk, 4, 5, 5, 6);
- stk.multicleave(2, (st) -> {
+ stk.multicleave(2, st -> {
int x = st.pop();
int y = st.pop();
st.push(x + y);
- }, (st) -> {
+ }, st -> {
int x = st.pop();
int y = st.pop();
@@ -210,12 +210,12 @@ public class StackTest {
assertStackEquals(stk, 1, 9, 5, 6);
- stk.spread((st) -> {
+ stk.spread(st -> {
int x = st.pop();
int y = st.pop();
st.push(x + y);
- }, (st) -> {
+ }, st -> {
int y = st.pop();
st.push(y + 1);
@@ -223,7 +223,7 @@ public class StackTest {
assertStackEquals(stk, 10, 6, 6);
- stk.apply(2, (st) -> {
+ stk.apply(2, st -> {
int lhs = st.pop();
st.push(lhs - st.pop());
});
diff --git a/src/test/java/bjc/esodata/ThresholdSetTest.java b/src/test/java/bjc/esodata/ThresholdSetTest.java
index 1f9af04..8f1b995 100644
--- a/src/test/java/bjc/esodata/ThresholdSetTest.java
+++ b/src/test/java/bjc/esodata/ThresholdSetTest.java
@@ -43,7 +43,9 @@ public class ThresholdSetTest {
public void testContains() {
ThresholdSet<String> thst = TS("1", "2", "2", "x", "z");
- int[] exps = new int[] {1, 2, -1};
+ int[] exps = new int[] {
+ 1, 2, -1
+ };
assertArrayEquals(exps, thst.containsKeys("1", "2", "y"));
}