public void AddingExistentElementUsingMethodMustReplaceTheValue() { var table = new HashTableStuff.HashTable <string, object>(); table.Add("testproba", 100); table.Add("testproba", 200); Assert.AreEqual(200, table["testproba"]); }
public void FillFactorMustBeZeroInEmptyTableAndPositiveInNonEmpty() { var table = new HashTableStuff.HashTable <string, object>(); Assert.AreEqual(0, table.FillFactor, 1e-5); table.Add("testproba555spbu", new object()); }
public void TwoElementsWithTheSameHashShouldExistSeparately() { var table = new HashTableStuff.HashTable <string, int>(HashTableStuff.StringHashFunctions.SimpleHash); table.Add("+-", 100); table.Add("X", 200); // In order to demonstate that tests are correct Assert.AreEqual( HashTableStuff.StringHashFunctions.SimpleHash("+-"), HashTableStuff.StringHashFunctions.SimpleHash("X")); Assert.IsTrue(table.IsInTable("+-"), "`+-` does not exists"); Assert.IsTrue(table.IsInTable("X"), "`X` does not exists"); Assert.AreEqual(100, table["+-"], "`+-` has invalid value"); Assert.AreEqual(200, table["X"], "`X` has invalid value"); }
public void AddingElementUsingMethodMustWork() { var table = new HashTableStuff.HashTable <string, object>(); for (int i = 0; i < 10; ++i) { table.Add((i + 100500).ToString(), new object()); } }
public void ErasingTwoElementsWithTheSameHashMustWork() { var table = new HashTableStuff.HashTable <string, int>(HashTableStuff.StringHashFunctions.SimpleHash); table.Add("+-", 100); table.Add("X", 200); // In order to demonstate that tests are correct Assert.AreEqual( HashTableStuff.StringHashFunctions.SimpleHash("+-"), HashTableStuff.StringHashFunctions.SimpleHash("X")); const double epsilon = 1e-5; table.Erase("+-"); Assert.IsTrue(table.FillFactor > epsilon); table.Erase("X"); Assert.IsTrue(table.FillFactor < epsilon); }
public void AddingAndErasingMultipleElementsMustWork() { var table = new HashTableStuff.HashTable <string, int>(); for (int i = -10000; i <= 10000; ++i) { table.Add(i.ToString(), i - 100); } for (int i = -10000; i <= 10000; ++i) { Assert.IsTrue(table.IsInTable(i.ToString())); table.Erase(i.ToString()); } Assert.AreEqual(0, table.FillFactor, 1e-5); }