|
|
@@ -1,79 +1,79 @@
|
|
|
-/*
|
|
|
- * @author Ranides Atterwim <ranides@gmail.com>
|
|
|
- * @copyright Ranides Atterwim
|
|
|
- * @license WTFPL
|
|
|
- * @url http://ranides.net/projects/???
|
|
|
- */
|
|
|
-package net.ranides.assira.collection.maps;
|
|
|
-
|
|
|
-import java.util.Map;
|
|
|
-import net.ranides.assira.collection.mockup.TMaps;
|
|
|
-import net.ranides.assira.collection.mockup.CollectionSuite;
|
|
|
-import net.ranides.assira.junit.QAssert;
|
|
|
-import net.ranides.assira.test.TMap;
|
|
|
-import net.ranides.assira.test.TMap.TItems;
|
|
|
-import org.junit.Test;
|
|
|
-import static org.junit.Assert.*;
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * @author Ranides Atterwim <ranides@gmail.com>
|
|
|
- */
|
|
|
-public class IntHashMapTest {
|
|
|
-
|
|
|
- private final TMap<Integer, String> $map = TMaps.MAP_IS;
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testSuite() {
|
|
|
- CollectionSuite.SUITE
|
|
|
- .param("map!", $map)
|
|
|
- .run(() -> new IntHashMap<>(32, 0.75f));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testConstruct() {
|
|
|
- assertNotNull( new IntHashMap<>(32, 0.75f) );
|
|
|
- assertNotNull( new IntHashMap<>(32) );
|
|
|
- assertNotNull( new IntHashMap<>() );
|
|
|
-
|
|
|
- QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
- new IntHashMap<>(32, 0.0f)
|
|
|
- );
|
|
|
- QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
- new IntHashMap<>(32, -1.0f)
|
|
|
- );
|
|
|
- QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
- new IntHashMap<>(32, 1.1f)
|
|
|
- );
|
|
|
- QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
- new IntHashMap<>(32, 2.0f)
|
|
|
- );
|
|
|
- QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
- new IntHashMap<>(-1, 0.5f)
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testConstructCopy() {
|
|
|
- TItems<Integer, String> items = $map.range(60).item(2).item(3);
|
|
|
-
|
|
|
- Map<Integer, String> imap = items.into(new java.util.HashMap<>());
|
|
|
- HashMap<Integer, String> smap = new HashMap<>(imap);
|
|
|
-
|
|
|
- assertEquals(60, new IntHashMap<>(imap, 0.75f).size());
|
|
|
- assertEquals(60, new IntHashMap<>(imap).size());
|
|
|
-
|
|
|
- assertEquals(60, new IntHashMap<>(smap, 0.75f).size());
|
|
|
- assertEquals(60, new IntHashMap<>(smap).size());
|
|
|
-
|
|
|
- assertEquals(60, new IntHashMap<>(new IntHashMap(smap), 0.75f).size());
|
|
|
- assertEquals(60, new IntHashMap<>(new IntHashMap(smap)).size());
|
|
|
-
|
|
|
- assertEquals(60, new IntHashMap<>(items.keysInt(), items.values()).size());
|
|
|
-
|
|
|
- QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
- new IntHashMap<>($map.range(60).keysInt(), $map.range(40).values())
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+/*
|
|
|
+ * @author Ranides Atterwim <ranides@gmail.com>
|
|
|
+ * @copyright Ranides Atterwim
|
|
|
+ * @license WTFPL
|
|
|
+ * @url http://ranides.net/projects/???
|
|
|
+ */
|
|
|
+package net.ranides.assira.collection.maps;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+import net.ranides.assira.collection.mockup.TMaps;
|
|
|
+import net.ranides.assira.collection.mockup.CollectionSuite;
|
|
|
+import net.ranides.assira.junit.QAssert;
|
|
|
+import net.ranides.assira.test.TMap;
|
|
|
+import net.ranides.assira.test.TMap.TItems;
|
|
|
+import org.junit.Test;
|
|
|
+import static org.junit.Assert.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author Ranides Atterwim <ranides@gmail.com>
|
|
|
+ */
|
|
|
+public class IntHashMapTest {
|
|
|
+
|
|
|
+ private final TMap<Integer, String> $map = TMaps.MAP_IS;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testSuite() {
|
|
|
+ CollectionSuite.SUITE
|
|
|
+ .param("map!", $map)
|
|
|
+ .run(() -> new IntHashMap<>(32, 0.75f));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testConstruct() {
|
|
|
+ assertNotNull( new IntHashMap<>(32, 0.75f) );
|
|
|
+ assertNotNull( new IntHashMap<>(32) );
|
|
|
+ assertNotNull( new IntHashMap<>() );
|
|
|
+
|
|
|
+ QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
+ new IntHashMap<>(32, 0.0f)
|
|
|
+ );
|
|
|
+ QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
+ new IntHashMap<>(32, -1.0f)
|
|
|
+ );
|
|
|
+ QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
+ new IntHashMap<>(32, 1.1f)
|
|
|
+ );
|
|
|
+ QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
+ new IntHashMap<>(32, 2.0f)
|
|
|
+ );
|
|
|
+ QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
+ new IntHashMap<>(-1, 0.5f)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testConstructCopy() {
|
|
|
+ TItems<Integer, String> items = $map.range(60).item(2).item(3);
|
|
|
+
|
|
|
+ Map<Integer, String> imap = items.into(new java.util.HashMap<>());
|
|
|
+ HashMap<Integer, String> smap = new HashMap<>(imap);
|
|
|
+
|
|
|
+ assertEquals(60, new IntHashMap<>(imap, 0.75f).size());
|
|
|
+ assertEquals(60, new IntHashMap<>(imap).size());
|
|
|
+
|
|
|
+ assertEquals(60, new IntHashMap<>(smap, 0.75f).size());
|
|
|
+ assertEquals(60, new IntHashMap<>(smap).size());
|
|
|
+
|
|
|
+ assertEquals(60, new IntHashMap<>(new IntHashMap<>(smap), 0.75f).size());
|
|
|
+ assertEquals(60, new IntHashMap<>(new IntHashMap<>(smap)).size());
|
|
|
+
|
|
|
+ assertEquals(60, new IntHashMap<>(items.keysInt(), items.values()).size());
|
|
|
+
|
|
|
+ QAssert.assertThrows(IllegalArgumentException.class, () ->
|
|
|
+ new IntHashMap<>($map.range(60).keysInt(), $map.range(40).values())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+}
|