summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-22 17:59:33 +0200
committerSven Gothel <[email protected]>2010-04-22 17:59:33 +0200
commit695e0bdc13cc2cd5be7b810469142572bbd8bb83 (patch)
tree8dd1ad9bd5b199773b174ee31191c0e562b1cfbb /test
parent9162a4c083be8ad15eef3cffad6d070c9ea12b93 (diff)
parent1babc3207da7210d7d70c47307d91db496109f0d (diff)
Merge branch 'master' of github.com:mbien/gluegen
Diffstat (limited to 'test')
-rw-r--r--test/junit/com/jogamp/common/util/IntIntHashMapTest.java29
-rw-r--r--test/junit/com/jogamp/common/util/LongIntHashMapTest.java36
2 files changed, 61 insertions, 4 deletions
diff --git a/test/junit/com/jogamp/common/util/IntIntHashMapTest.java b/test/junit/com/jogamp/common/util/IntIntHashMapTest.java
index 18eeef6..f041123 100644
--- a/test/junit/com/jogamp/common/util/IntIntHashMapTest.java
+++ b/test/junit/com/jogamp/common/util/IntIntHashMapTest.java
@@ -4,6 +4,7 @@
package com.jogamp.common.util;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Random;
import org.junit.BeforeClass;
@@ -39,6 +40,7 @@ public class IntIntHashMapTest {
}
}
+
/**
* Test of put method, of class IntIntHashMap.
*/
@@ -75,6 +77,31 @@ public class IntIntHashMapTest {
}
}
+
+ @Test
+ public void iteratorTest() {
+
+ final IntIntHashMap intmap = new IntIntHashMap(iterations);
+
+ for (int i = 0; i < iterations; i++) {
+ intmap.put(rndKeys[i], rndValues[i]);
+ }
+
+ Iterator iterator = intmap.iterator();
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+
+ int n = 0;
+ while (iterator.hasNext()) {
+ IntIntHashMap.Entry entry = (IntIntHashMap.Entry)iterator.next();
+ assertNotNull(entry);
+ n++;
+ }
+ assertEquals(intmap.size(), n);
+
+// out.println(intmap);
+
+ }
@Test
public void benchmark() {
@@ -83,6 +110,8 @@ public class IntIntHashMapTest {
final IntIntHashMap intmap = new IntIntHashMap(1024);
final HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(1024);
+ out.println(intmap.getClass().getName()+" vs "+map.getClass().getName());
+
out.println("put");
long time = currentTimeMillis();
for (int i = 0; i < iterations; i++) {
diff --git a/test/junit/com/jogamp/common/util/LongIntHashMapTest.java b/test/junit/com/jogamp/common/util/LongIntHashMapTest.java
index 67a610f..53aa252 100644
--- a/test/junit/com/jogamp/common/util/LongIntHashMapTest.java
+++ b/test/junit/com/jogamp/common/util/LongIntHashMapTest.java
@@ -3,6 +3,7 @@
*/
package com.jogamp.common.util;
+import java.util.Iterator;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Random;
@@ -78,19 +79,46 @@ public class LongIntHashMapTest {
}
@Test
+ public void iteratorTest() {
+
+ final LongIntHashMap map = new LongIntHashMap(iterations);
+
+ for (int i = 0; i < iterations; i++) {
+ map.put(rndKeys[i], rndValues[i]);
+ }
+
+ Iterator iterator = map.iterator();
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+
+ int n = 0;
+ while (iterator.hasNext()) {
+ LongIntHashMap.Entry entry = (LongIntHashMap.Entry)iterator.next();
+ assertNotNull(entry);
+ n++;
+ }
+ assertEquals(map.size(), n);
+
+// out.println(intmap);
+
+ }
+
+ @Test
public void benchmark() {
// simple benchmark
- final LongIntHashMap intmap = new LongIntHashMap(1024);
+ final LongIntHashMap intmap = new LongIntHashMap(1024);
final HashMap<Long, Integer> map = new HashMap<Long, Integer>(1024);
+ out.println(intmap.getClass().getName()+" vs "+map.getClass().getName());
+
out.println("put");
long time = currentTimeMillis();
for (int i = 0; i < iterations; i++) {
intmap.put(rndKeys[i], rndValues[i]);
}
long intmapTime = (currentTimeMillis() - time);
- out.println(" iimap: " + intmapTime+"ms");
+ out.println(" limap: " + intmapTime+"ms");
time = currentTimeMillis();
@@ -106,7 +134,7 @@ public class LongIntHashMapTest {
System.out.println();
System.out.println("get");
intmapTime = (currentTimeMillis() - time);
- out.println(" iimap: " + intmapTime+"ms");
+ out.println(" limap: " + intmapTime+"ms");
for (int i = 0; i < iterations; i++) {
intmap.get(rndValues[i]);
}
@@ -122,7 +150,7 @@ public class LongIntHashMapTest {
out.println();
out.println("remove");
intmapTime = (currentTimeMillis() - time);
- out.println(" iimap: " + intmapTime+"ms");
+ out.println(" limap: " + intmapTime+"ms");
for (int i = 0; i < iterations; i++) {
intmap.remove(rndValues[i]);
}