Example #1
0
 def testSetElementInHashMap(self):
     h = hashmap(5)
     self.assertTrue(h.set("key1", "val1"))
Example #2
0
 def testHashMapConstructor(self):
     h = hashmap(5)
     self.failUnless(h)
Example #3
0
 def testInvalidSizeException(self):
     try:
         h = hashmap(0)
         self.failUnless(False)
     except ValueError:
         self.failUnless(True)
Example #4
0
 def testValueDeletedFromHashMap(self):
     h = hashmap(5)
     h.set("key1", "val1")
     h.delete("key1")
     self.assertIsNone(h.get("key1"))
Example #5
0
 def testLoad(self):
     h = hashmap(4)
     h.set("key1", "val1")
     self.assertEqual(h.load(), 0.25)
Example #6
0
 def testValueOverwrittenInHashMap(self):
     h = hashmap(5)
     h.set("key1", "val1")
     h.set("key1", "val2")
     self.assertIs(h.get("key1"), "val2")
Example #7
0
 def testValueStoredInHashMap(self):
     h = hashmap(5)
     h.set("key1", "val1")
     self.assertIs(h.get("key1"), "val1")
Example #8
0
 def testGetElementNotInHashMap(self):
     h = hashmap(5)
     self.assertIsNone(h.get("key1"))
Example #9
0
 def testGetElementInHashMap(self):
     h = hashmap(5)
     h.set("key1", "val1")
     self.assertIsNotNone(h.get("key1"))
Example #10
0
 def testHashMapFull(self):
     h = hashmap(2)
     h.set("key1", "val1")
     h.set("key2", "val2")
     self.assertFalse(h.set("key3", "val3"))