diff test/org/tmatesoft/hg/test/TestIntMap.java @ 415:ee8264d80747

Explicit constant for regular file flags, access to flags for a given file revision
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 22 Mar 2012 18:54:11 +0100
parents 55fad5e0e98b
children
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestIntMap.java	Wed Mar 21 20:51:12 2012 +0100
+++ b/test/org/tmatesoft/hg/test/TestIntMap.java	Thu Mar 22 18:54:11 2012 +0100
@@ -18,6 +18,11 @@
 
 import static org.junit.Assert.assertEquals;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
 import org.junit.Test;
 import org.tmatesoft.hg.internal.IntMap;
 
@@ -59,4 +64,25 @@
 		}
 		assertEquals(m.size(), actualCount);
 	}
+	
+	@Test
+	public void testIterators() {
+		IntMap<Boolean> m = new IntMap<Boolean>(20);
+		for (int i = 0; i <= 30; i+= 5) {
+			m.put(i, Boolean.TRUE);
+		}
+		HashMap<Integer, Boolean> hm = new HashMap<Integer, Boolean>();
+		for (Iterator<Map.Entry<Integer, Boolean>> it = m.entryIterator(); it.hasNext(); ) {
+			Entry<Integer, Boolean> next = it.next();
+			hm.put(next.getKey(), next.getValue());
+		}
+		assertEquals(m.size(), hm.size());
+		for (int i = 0; i <= 30; i++) {
+			assertEquals(m.get(i), hm.get(i));
+		}
+		//
+		HashMap<Integer, Boolean> hm2 = new HashMap<Integer, Boolean>();
+		m.fill(hm2);
+		assertEquals(hm, hm2);
+	}
 }