diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2019-07-10 17:10:51 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2019-07-10 17:10:51 -0400 |
| commit | e401fb037c555eb18db54708037a796523258c32 (patch) | |
| tree | 78aa519089a71fe056524abdc28af4894e2640cd /src/test/java/bjc/esodata/ThresholdSetTest.java | |
| parent | 4d0a59a0023f2b4fca144a089a3f75acb4ebd62b (diff) | |
General improvements to stack
Diffstat (limited to 'src/test/java/bjc/esodata/ThresholdSetTest.java')
| -rw-r--r-- | src/test/java/bjc/esodata/ThresholdSetTest.java | 60 |
1 files changed, 47 insertions, 13 deletions
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<String> thst = new ThresholdSet<>(); - - thst.addKeys("a", "b"); + ThresholdSet<String> 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<String> thst = new ThresholdSet<>(); + ThresholdSet<String> 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<String> thst = TS("a", "b"); + thst.add("a"); + + assertIteratorSet(false, thst.setView().iterator(), "b"); + assertEquals(thst.setSize(), 1); + } + + @Test + public void testContains() { + ThresholdSet<String> 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<String> thst = new ThresholdSet<>(); + ThresholdSet<String> 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<String> 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"); } } |
