public void TestA_Hash_3() { int size = 16; string key1 = "one"; string key2 = "one"; NativeDictionary <int> nat = new NativeDictionary <int>(size); int index1 = nat.HashFun(key1); int index2 = nat.HashFun(key2); Assert.AreEqual(true, index1 == index2); }
public void TestA_Hash_4() { int size = 16; string key1 = "Blitz krieg pop"; string key2 = " "; string key3 = "111111"; NativeDictionary <int> nat = new NativeDictionary <int>(size); int index1 = nat.HashFun(key1); int index2 = nat.HashFun(key2); int index3 = nat.HashFun(key3); Assert.AreEqual(true, index1 > -1 && index1 < size - 1); Assert.AreEqual(true, index2 > -1 && index2 < size - 1); Assert.AreEqual(true, index3 > -1 && index3 < size - 1); }
public void Get_if_Dict_Has_Key() { NativeDictionary <string> clients = new NativeDictionary <string>(6); string[] names = { "Laura", "Patrik", "Stuart", "Leonard", "Delcin" }; string[] categories = { "New", "Regular", "VIP", "Deptor" }; Console.WriteLine("=== LOG ==="); Console.WriteLine("{0}\n{1}\n{2}\n{3}\n{4}", clients.HashFun(names[0]), clients.HashFun(names[1]), clients.HashFun(names[2]), clients.HashFun(names[3]), clients.HashFun(names[4])); clients.Put(names[0], categories[1]); clients.Put(names[1], categories[0]); clients.Put(names[2], categories[3]); clients.Put(names[3], categories[2]); clients.Put(names[4], categories[1]); Console.WriteLine("{0}\n{1}\n{2}\n{3}\n{4}", clients.Get(names[0]), clients.Get(names[1]), clients.Get(names[2]), clients.Get(names[3]), clients.Get(names[4])); Console.WriteLine("=== LOG END ==="); string actualValue = clients.Get(names[0]); string actualValue2 = clients.Get(names[1]); string actualValue3 = clients.Get(names[2]); string expectedValue4 = "VIP"; string actualValue4 = clients.Get(names[3]); string expectedValue5 = "Regular"; string actualValue5 = clients.Get(names[4]); Assert.IsNull(actualValue); Assert.IsNull(actualValue2); Assert.IsNull(actualValue3); Assert.AreEqual(expectedValue4, actualValue4); Assert.AreEqual(expectedValue5, actualValue5); Assert.IsNull(clients.Get("Hue")); Assert.IsTrue(clients.size == 6); }
public void TestA_Hash_2() { int size = 16; string key = "one"; NativeDictionary <int> nat = new NativeDictionary <int>(size); int index1 = nat.HashFun(key) % size; nat.Put(key, 1); int index2 = 0; for (int i = 0; i < size; i++) { if (nat.values[i] != 0) { index2 = i; } } Assert.AreEqual(index1, index2); }
public void Hash() { NativeDictionary <int> dict = new NativeDictionary <int>(5); Assert.True(dict.HashFun("1") == 3); }