From e401fb037c555eb18db54708037a796523258c32 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 10 Jul 2019 17:10:51 -0400 Subject: General improvements to stack --- src/test/java/bjc/esodata/ThresholdSetTest.java | 60 +++++++++++++++++++------ 1 file changed, 47 insertions(+), 13 deletions(-) (limited to 'src/test/java/bjc/esodata/ThresholdSetTest.java') diff --git a/src/test/java/bjc/esodata/ThresholdSetTest.java b/src/test/java/bjc/esodata/ThresholdSetTest.java index b37f866..6995ad8 100644 --- a/src/test/java/bjc/esodata/ThresholdSetTest.java +++ b/src/test/java/bjc/esodata/ThresholdSetTest.java @@ -3,11 +3,13 @@ package bjc.esodata; import org.junit.Test; import bjc.TestUtils; -import bjc.esodata.ThresholdSet; -import java.util.Iterator; +import java.util.*; import static bjc.TestUtils.*; + +import static bjc.esodata.ThresholdSet.*; + import static org.junit.Assert.*; /** @@ -18,29 +20,61 @@ import static org.junit.Assert.*; public class ThresholdSetTest { @Test public void testAdd() { - ThresholdSet thst = new ThresholdSet<>(); - - thst.addKeys("a", "b"); + ThresholdSet thst = TS("a", "b"); - assertIteratorEquals(false, thst.setView().iterator(), "a", "b"); + assertIteratorSet(false, thst.setView().iterator(), "a", "b"); + assertEquals(thst.setSize(), 2); } @Test public void testAddMulti() { - ThresholdSet thst = new ThresholdSet<>(); + ThresholdSet thst = TS("a", "b", "a"); - thst.addKeys("a", "b", "a"); + assertIteratorSet(false, thst.setView().iterator(), "b"); + assertEquals(thst.setSize(), 1); + } - assertIteratorEquals(false, thst.setView().iterator(), "b"); + @Test + public void testAddMulti2() { + ThresholdSet thst = TS("a", "b"); + thst.add("a"); + + assertIteratorSet(false, thst.setView().iterator(), "b"); + assertEquals(thst.setSize(), 1); + } + + @Test + public void testContains() { + ThresholdSet thst = TS("1", "2", "2", "x", "z"); + + int[] exps = new int[] {1, 2, -1}; + assertArrayEquals(exps, thst.containsKeys("1", "2", "y")); } @Test public void testRemoveMulti() { - ThresholdSet thst = new ThresholdSet<>(); + ThresholdSet thst = TS("a", "a", "b"); + + thst.remove("a"); + + assertIteratorSet(false, thst.setView().iterator(), "a", "b"); + assertEquals(2, thst.setSize()); + + thst.remove("a"); + + assertIteratorSet(false, thst.setView().iterator(), "b"); + assertEquals(1, thst.setSize()); + } + + @Test + public void testSetTransparency() { + ThresholdSet thst = TS("a", "b", "c"); - thst.addKeys("a", "a", "b"); - thst.removeKeys("a"); + thst.setView().add("b"); + assertIteratorSet(false, thst.setView().iterator(), "a", "c"); + assertEquals(2, thst.setView().size()); - assertIteratorEquals(false, thst.setView().iterator(), "a", "b"); + thst.setView().remove("c"); + assertIteratorSet(false, thst.setView().iterator(), "a"); } } -- cgit v1.2.3