public void PutTest() { NativeDictionary <string> programmers = new NativeDictionary <string>(5); string key = "Jimmy"; string value = "Nube"; string key2 = "Li"; string value2 = "Junior"; string key3 = "Gordon"; string value3 = "Middle"; string key4 = "Fred"; string value4 = "Senior"; string key5 = "Jessica"; string value5 = "Team Lead"; programmers.Put(key, value); programmers.Put(key2, value2); programmers.Put(key3, value3); programmers.Put(key4, value4); programmers.Put(key5, value5); int expectedSize = 5; string expectedKey = "Gordon"; string expectedValue = "Middle"; int actualSize = programmers.size; string actualKey = programmers.slots[2]; string actualValue = programmers.values[2]; Assert.IsTrue(programmers.IsKey(key)); Assert.IsTrue(programmers.IsKey("Jessica")); Assert.AreEqual(expectedSize, actualSize); Assert.AreEqual(expectedKey, actualKey); Assert.AreEqual(expectedValue, actualValue); }
public void Test_IsKey_WhenKeyExists() { var dictionary = new NativeDictionary <int>(10); dictionary.Put("a", 1); dictionary.Put("b", 2); dictionary.Put("c", 3); dictionary.Put("d", 4); dictionary.Put("e", 5); dictionary.Put("f", 6); dictionary.Put("g", 7); dictionary.Put("h", 8); dictionary.Put("i", 9); dictionary.Put("j", 10); dictionary.Put("i", 10); Assert.AreEqual(true, dictionary.IsKey("a")); Assert.AreEqual(true, dictionary.IsKey("b")); Assert.AreEqual(true, dictionary.IsKey("c")); Assert.AreEqual(true, dictionary.IsKey("d")); Assert.AreEqual(true, dictionary.IsKey("e")); Assert.AreEqual(true, dictionary.IsKey("f")); Assert.AreEqual(true, dictionary.IsKey("g")); Assert.AreEqual(true, dictionary.IsKey("h")); Assert.AreEqual(true, dictionary.IsKey("i")); Assert.AreEqual(true, dictionary.IsKey("j")); }
public void Get_in_Empty_Dict() { NativeDictionary <string> clients = new NativeDictionary <string>(3); string key = "Laura"; Assert.IsNull(clients.Get(key)); }
public int AddOrSet(String key, String value) { try { if (String.IsNullOrEmpty(key)) { return(-1); } if (NativeDictionary.ContainsKey(key)) { NativeDictionary[key] = value; } else { NativeDictionary.Add(key, value); } return(Count - 1); } catch (Exception ex) { ILog.LogError(ex); } return(-1); }
public void TestA_Put_3() { NativeDictionary <int> nat = new NativeDictionary <int>(10); nat.Put("cat1", 1); nat.Put("cat2", 3); nat.Put("cat3", 5); nat.Put("cat4", 7); nat.Put("cat5", 9); nat.Put("cat6", 11); nat.Put("cat7", 13); nat.Put("cat8", 15); nat.Put("cat9", 17); nat.Put("cat10", 19); nat.Put("cat11", 21); Assert.AreEqual(1, nat.Get("cat1")); Assert.AreEqual(3, nat.Get("cat2")); Assert.AreEqual(5, nat.Get("cat3")); Assert.AreEqual(7, nat.Get("cat4")); Assert.AreEqual(9, nat.Get("cat5")); Assert.AreEqual(11, nat.Get("cat6")); Assert.AreEqual(13, nat.Get("cat7")); Assert.AreEqual(15, nat.Get("cat8")); Assert.AreEqual(17, nat.Get("cat9")); Assert.AreEqual(19, nat.Get("cat10")); Assert.AreEqual(0, nat.Get("cat11")); }
public void TestB_Put_3() { NativeDictionary <string> nat = new NativeDictionary <string>(10); nat.Put("cat1", "pet"); nat.Put("cat2", "fat"); nat.Put("cat3", "bat"); nat.Put("cat4", "dot"); nat.Put("cat5", "bed"); nat.Put("cat6", "toy"); nat.Put("cat7", "pay"); nat.Put("cat8", "day"); nat.Put("cat9", "say"); nat.Put("cat10", "key"); nat.Put("cat11", "tea"); Assert.AreEqual("pet", nat.Get("cat1")); Assert.AreEqual("fat", nat.Get("cat2")); Assert.AreEqual("bat", nat.Get("cat3")); Assert.AreEqual("dot", nat.Get("cat4")); Assert.AreEqual("bed", nat.Get("cat5")); Assert.AreEqual("toy", nat.Get("cat6")); Assert.AreEqual("pay", nat.Get("cat7")); Assert.AreEqual("day", nat.Get("cat8")); Assert.AreEqual("say", nat.Get("cat9")); Assert.AreEqual("key", nat.Get("cat10")); Assert.AreEqual(null, nat.Get("cat11")); }
public void TestA_Get_3() { int size = 4; string key1 = "one"; string key2 = "one"; int index1 = 10; int index2 = 10; NativeDictionary <int> nat = new NativeDictionary <int>(size); nat.Put(key1, 1); nat.Put(key2, 2); for (int i = 0; i < size; i++) { if (nat.values[i] == 1) { index1 = i; } if (nat.values[i] == 2) { index2 = i; } } Assert.AreEqual(true, index1 == 10); Assert.AreEqual(true, index2 != 10); }
public void IsKey_in_Empty_Dict() { NativeDictionary <string> clients = new NativeDictionary <string>(3); string key = "Laura"; Assert.IsFalse(clients.IsKey(key)); Assert.IsFalse(clients.IsKey("John")); }
public void TestB_Put_1() { NativeDictionary <string> nat = new NativeDictionary <string>(16); nat.Put("one", "1"); Assert.AreEqual("1", nat.Get("one")); }
public void TestA_Put_1() { NativeDictionary <int> nat = new NativeDictionary <int>(16); nat.Put("one", 1); Assert.AreEqual(1, nat.Get("one")); }
public void TestForPutAndIsKey() { NativeDictionary dict = new NativeDictionary(); dict.put("home", 328910); Assert.AreEqual(true, dict.is_key("home")); Assert.AreEqual(false, dict.is_key("qwerty")); }
public void TestA_IsKey_3() { int size = 16; NativeDictionary <int> nat = new NativeDictionary <int>(size); Assert.AreEqual(false, nat.IsKey("one")); Assert.AreEqual(false, nat.IsKey("key")); Assert.AreEqual(false, nat.IsKey(" ")); }
public void Test_IsKey_WhenNoSuchKey() { var dictionary = new NativeDictionary <int>(10); dictionary.Put("b", 2); var result = dictionary.IsKey("a"); Assert.AreEqual(false, result); }
public void TestForGet() { NativeDictionary dict = new NativeDictionary(); dict.put("region", 903299); Assert.AreEqual(903299, dict.get("region")); Assert.AreEqual(-1, dict.get("home")); }
public void TestC_Put_1() { int size = 16; NativeDictionary <BitBag> nat = new NativeDictionary <BitBag>(size); nat.Put("key1", new BitBag(1)); nat.Put("key2", new BitBag(2)); Assert.AreEqual(1, nat.Get("key1").value); Assert.AreEqual(2, nat.Get("key2").value); }
public void TestA_IsKey_5() { int size = 16; NativeDictionary <int> nat = new NativeDictionary <int>(size); nat.Put("one", 1); Assert.AreEqual(false, nat.IsKey("")); Assert.AreEqual(false, nat.IsKey(null)); }
public void IsKey() { NativeDictionary <int> dict = new NativeDictionary <int>(5); dict.Put("1", 1); dict.Put("2", 2); Assert.True(dict.IsKey("1")); Assert.True(dict.IsKey("2")); Assert.True(!dict.IsKey("3")); }
public void IsKeyTest() { NativeDictionary <string> profs = new NativeDictionary <string>(5); string key = "Dmitry"; string value = "engineer"; profs.Put(key, value); Assert.IsTrue(profs.IsKey(key)); Assert.IsFalse(profs.IsKey("football player")); }
public void Test_Get() { var dictionary = new NativeDictionary <int>(2); dictionary.Put("a", 1); dictionary.Put("k", 2); var result = dictionary.Get("k"); Assert.AreEqual(2, result); }
public static void TestsNativeDictionaryGet() { var testDict = new NativeDictionary <int>(3); Assert.AreEqual(3, testDict.size); testDict.Put("one", 1); Assert.AreEqual("one", testDict.slots[1]); Assert.AreEqual(1, testDict.values[1]); Assert.AreEqual(1, testDict.Get("one")); Assert.AreEqual(default(int), testDict.Get("two")); }
public void TestA_Put_5() { NativeDictionary <int> nat = new NativeDictionary <int>(16); nat.Put("1", 1); nat.Put("11", 2); nat.Put("111", 3); Assert.AreEqual(1, nat.Get("1")); Assert.AreEqual(2, nat.Get("11")); Assert.AreEqual(3, nat.Get("111")); }
public void Test_Put_WhenNoExtend() { var dictionary = new NativeDictionary <int>(10); dictionary.Put("a", 1); dictionary.Put("b", 2); dictionary.Put("c", 3); dictionary.Put("d", 4); var result = dictionary.IsKey("c"); Assert.AreEqual(true, result); }
public void TestB_Put_5() { NativeDictionary <string> nat = new NativeDictionary <string>(16); nat.Put("1", "1"); nat.Put("11", "2"); nat.Put("111", "3"); Assert.AreEqual("1", nat.Get("1")); Assert.AreEqual("2", nat.Get("11")); Assert.AreEqual("3", nat.Get("111")); }
public void AddRange(bool removePrevious, params Row[] dct) { if (removePrevious) { NativeDictionary.Clear(); } foreach (Row kvr in dct) { AddOrSet(kvr.Key, kvr.Val); } }
public void AddRange(bool removePrevious, Dictionary <String, String> dct) { if (removePrevious) { NativeDictionary.Clear(); } foreach (KeyValuePair <String, String> kvp in dct) { AddOrSet(kvp); } }
public void TestB_Put_6() { int size = 16; NativeDictionary <string> nat = new NativeDictionary <string>(size); nat.Put(null, "1"); for (int i = 0; i < size; i++) { Assert.AreEqual(true, nat.values[i] == null); } }
public void TestA_Get_2() { int size = 4; string key1 = "one"; string key2 = "two"; string key3 = "three"; string key4 = "four"; NativeDictionary <int> nat = new NativeDictionary <int>(size); nat.Put(key1, 614); nat.Put(key2, 921); nat.Put(key3, 53); nat.Put(key4, 910); int index1 = 0; int index2 = 0; int index3 = 0; int index4 = 0; for (int i = 0; i < size; i++) { if (nat.values[i] == 0) { continue; } else if (nat.slots[i] == key1) { index1 = i; } else if (nat.slots[i] == key2) { index2 = i; } else if (nat.slots[i] == key3) { index3 = i; } else if (nat.slots[i] == key4) { index4 = i; } else { break; } } Assert.AreEqual(nat.values[index1], nat.Get("one")); Assert.AreEqual(nat.values[index2], nat.Get("two")); Assert.AreEqual(nat.values[index3], nat.Get("three")); Assert.AreEqual(nat.values[index4], nat.Get("four")); }
public static void TestsNativeDictionaryIsKey() { var testDict = new NativeDictionary <int>(3); Assert.AreEqual(3, testDict.size); testDict.Put("one", 1); Assert.AreEqual("one", testDict.slots[1]); Assert.AreEqual(1, testDict.values[1]); Assert.IsTrue(testDict.IsKey("one")); Assert.IsFalse(testDict.IsKey("two")); }
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 TestC_Put_2() { int size = 16; BitBag bb1 = new BitBag(1); BitBag bb2 = new BitBag(2); NativeDictionary <BitBag> nat = new NativeDictionary <BitBag>(size); nat.Put("key1", bb1); nat.Put("key2", bb2); Assert.AreEqual(bb1, nat.Get("key1")); Assert.AreEqual(bb2, nat.Get("key2")); }