public void Does_Not_Find_Nonexistant_Key_In_Bucket() { var ht = new SimpleHashTable(); ht.Add(1, 1); Assert.IsFalse(ht.ContainsKey(2)); }
public void Finds_Key_In_Bucket() { var ht = new SimpleHashTable(); ht.Add(1, 1); ht.Add(2, 2); Assert.IsTrue(ht.ContainsKey(1)); }
public void Does_Not_Find_Nonexistant_Key_In_Overloaded_Bucket() { //all go into same bucket var ht = new SimpleHashTable(1); ht.Add(1, 1); ht.Add(2, 2); Assert.IsFalse(ht.ContainsKey(3)); }
public void Finds_Key_In_Overloaded_Bucket() { //all go into same bucket var ht = new SimpleHashTable(1); ht.Add(1, 1); ht.Add(2, 2); Assert.IsTrue(ht.ContainsKey(1)); }
public static void HashTable() { SimpleHashTable <string, int> simpleHash = new SimpleHashTable <string, int>(); simpleHash.Add("hello", 1); simpleHash.Add("world", 2); simpleHash.Add("this", 3); simpleHash.Add("is", 4); Assert.That(simpleHash.ContainsKey("world") == true); Assert.That(simpleHash.ContainsKey("nohash") == false); Assert.That(simpleHash["is"] == 4); Assert.That(simpleHash["hello"] == 1); simpleHash["hello"] = 10; Assert.That(simpleHash["hello"] == 10); simpleHash.Remove("this"); Assert.That(simpleHash.ContainsKey("this") == false); }
public void Rejects_Null_Key() { var ht = new SimpleHashTable(); var valid = true; try { ht.ContainsKey(null); } catch (ArgumentNullException) { valid = false; } Assert.IsFalse(valid); }