[Scummvm-cvs-logs] SF.net SVN: scummvm:[44259] scummvm/trunk/test/common/hashmap.h

wjpalenstijn at users.sourceforge.net wjpalenstijn at users.sourceforge.net
Tue Sep 22 14:49:33 CEST 2009


Revision: 44259
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44259&view=rev
Author:   wjpalenstijn
Date:     2009-09-22 12:49:32 +0000 (Tue, 22 Sep 2009)

Log Message:
-----------
Add basic test for HashMap::iterator

Modified Paths:
--------------
    scummvm/trunk/test/common/hashmap.h

Modified: scummvm/trunk/test/common/hashmap.h
===================================================================
--- scummvm/trunk/test/common/hashmap.h	2009-09-22 12:39:07 UTC (rev 44258)
+++ scummvm/trunk/test/common/hashmap.h	2009-09-22 12:49:32 UTC (rev 44259)
@@ -168,6 +168,38 @@
 		TS_ASSERT(h.empty());
     }
 
+	void test_iterator() {
+		Common::HashMap<int, int> container;
+		container[0] = 17;
+		container[1] = 33;
+		container[2] = 45;
+		container[3] = 12;
+		container[4] = 96;
+		container.erase(1);
+		container[1] = 42;
+		container.erase(0);
+		container.erase(1);
 
+		int found = 0;
+		Common::HashMap<int, int>::iterator i;
+		for (i = container.begin(); i != container.end(); ++i) {
+			int key = i->_key;
+			TS_ASSERT(key >= 0 && key <= 4);
+			TS_ASSERT(!(found & (1 << key)));
+			found |= 1 << key;
+		}
+		TS_ASSERT(found == 16+8+4);
+
+		found = 0;
+		Common::HashMap<int, int>::const_iterator j;
+		for (j = container.begin(); j != container.end(); ++j) {
+			int key = j->_key;
+			TS_ASSERT(key >= 0 && key <= 4);
+			TS_ASSERT(!(found & (1 << key)));
+			found |= 1 << key;
+		}
+		TS_ASSERT(found == 16+8+4);
+}
+
 	// TODO: Add test cases for iterators, find, ...
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list