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 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 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 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 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"));
        }
示例#7
0
        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"));
        }
示例#8
0
        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_IsKey_8()
        {
            int    size = 16;
            string key1 = "";

            NativeDictionary <int> nat = new NativeDictionary <int>(size);

            Assert.AreEqual(false, nat.IsKey(""));

            nat.Put(key1, 1);

            Assert.AreEqual(true, nat.IsKey(""));
        }
        public void TestA_IsKey_6()
        {
            int size = 4;

            NativeDictionary <int> nat = new NativeDictionary <int>(size);

            nat.Put("one", 1);
            nat.Put("two", 2);
            nat.Put("three", 3);
            nat.Put("four", 4);

            Assert.AreEqual(true, nat.IsKey("one"));
            Assert.AreEqual(true, nat.IsKey("two"));
            Assert.AreEqual(true, nat.IsKey("three"));
            Assert.AreEqual(true, nat.IsKey("four"));
        }
        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 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 Test1_FirstStartTest()
        {
            int size = 16;

            string key1  = "key1";
            int    item1 = 1;

            string key2  = "key2";
            string item2 = "1";

            string key3  = "key3";
            BitBag item3 = new BitBag(1);

            string  key4  = "key4";
            BitBagE item4 = new BitBagE(1);

            NativeDictionary <int>    nat1 = new NativeDictionary <int>(size);
            NativeDictionary <string> nat2 = new NativeDictionary <string>(size);
            NativeDictionary <BitBag> nat3 = new NativeDictionary <BitBag>(size);

            nat1.Put(key1, item1);
            nat2.Put(key2, item2);
            nat3.Put(key3, item3);
            nat3.Put(key4, item4);

            Assert.AreEqual(true, nat1.IsKey(key1));
            Assert.AreEqual(item1, nat1.Get(key1));

            Assert.AreEqual(true, nat2.IsKey(key2));
            Assert.AreEqual(item2, nat2.Get(key2));

            Assert.AreEqual(true, nat3.IsKey(key3));
            Assert.AreEqual(item3, nat3.Get(key3));
            Assert.AreEqual(true, nat3.IsKey(key4));
            Assert.AreEqual(item4, nat3.Get(key4));
        }
        public void TestA_IsKey_7()
        {
            int size = 1;

            NativeDictionary <int> nat1 = new NativeDictionary <int>(size);
            NativeDictionary <int> nat2 = new NativeDictionary <int>(size);
            NativeDictionary <int> nat3 = new NativeDictionary <int>(size);

            nat1.Put("one", 1);
            nat2.Put("two", 1);
            nat3.Put("four", 1);

            Assert.AreEqual(true, nat1.IsKey("one"));
            Assert.AreEqual(true, nat2.IsKey("two"));
            Assert.AreEqual(true, nat3.IsKey("four"));
        }
        public void TestA_IsKey_2()
        {
            int size = 16;

            NativeDictionary <int> nat = new NativeDictionary <int>(size);

            for (int i = 0; i < size; i++)
            {
                nat.Put("key" + i, i);
            }

            for (int i = 0; i < size; i++)
            {
                Assert.AreEqual(true, nat.IsKey("key" + 1));
            }
        }
        public void TestA_15()
        {
            int size = 8;

            NativeDictionary <int> nat = new NativeDictionary <int>(size);

            nat.Put("1", 1);
            nat.Put("2", 2);
            nat.Put("3", 3);
            nat.Put("4", 4);
            nat.Put("5", 5);
            nat.Put("6", 6);
            nat.Put("7", 7);
            nat.Put("8", 8);

            Assert.AreEqual(true, nat.IsKey("1"));
            Assert.AreEqual(true, nat.IsKey("2"));
            Assert.AreEqual(true, nat.IsKey("3"));
            Assert.AreEqual(true, nat.IsKey("4"));
            Assert.AreEqual(true, nat.IsKey("5"));
            Assert.AreEqual(true, nat.IsKey("6"));
            Assert.AreEqual(true, nat.IsKey("7"));
            Assert.AreEqual(true, nat.IsKey("8"));

            for (int i = 0; i < 100000; i++)
            {
                nat.Put("a" + 1, 7);
            }

            Assert.AreEqual(true, nat.IsKey("1"));
            Assert.AreEqual(true, nat.IsKey("2"));
            Assert.AreEqual(true, nat.IsKey("3"));
            Assert.AreEqual(true, nat.IsKey("4"));
            Assert.AreEqual(true, nat.IsKey("5"));
            Assert.AreEqual(true, nat.IsKey("6"));
            Assert.AreEqual(true, nat.IsKey("7"));
            Assert.AreEqual(true, nat.IsKey("8"));

            for (int i = 0; i < 100000; i++)
            {
                nat.Put("7", 10 + i);
            }

            Assert.AreEqual(true, nat.IsKey("1"));
            Assert.AreEqual(true, nat.IsKey("2"));
            Assert.AreEqual(true, nat.IsKey("3"));
            Assert.AreEqual(true, nat.IsKey("4"));
            Assert.AreEqual(true, nat.IsKey("5"));
            Assert.AreEqual(true, nat.IsKey("6"));
            Assert.AreEqual(true, nat.IsKey("7"));
            Assert.AreEqual(true, nat.IsKey("8"));

            for (int i = 1; i < 100000; i++)
            {
                nat.Put("" + i, 10 + i);
            }

            Assert.AreEqual(true, nat.IsKey("1"));
            Assert.AreEqual(true, nat.IsKey("2"));
            Assert.AreEqual(true, nat.IsKey("3"));
            Assert.AreEqual(true, nat.IsKey("4"));
            Assert.AreEqual(true, nat.IsKey("5"));
            Assert.AreEqual(true, nat.IsKey("6"));
            Assert.AreEqual(true, nat.IsKey("7"));
            Assert.AreEqual(true, nat.IsKey("8"));
        }
        public void TestC_IsKey_1()
        {
            int     size = 16;
            BitBag  bb1  = new BitBag(1);
            BitBag  bb2  = new BitBag(2);
            BitBagE bb3  = new BitBagE(3);
            BitBagE bb4  = new BitBagE(4);
            BitBag  bb5  = new BitBag(5);
            BitBag  bb6  = new BitBag(6);
            BitBag  bb7  = new BitBag(7);
            BitBagE bb8  = new BitBagE(8);
            BitBagE bb9  = new BitBagE(9);
            BitBagE bb10 = new BitBagE(10);
            BitBag  bb11 = new BitBag(11);
            BitBagE bb12 = new BitBagE(12);
            BitBag  bb13 = new BitBag(13);
            BitBag  bb14 = new BitBag(14);
            BitBagE bb15 = new BitBagE(15);
            BitBagE bb16 = new BitBagE(16);

            string key1  = "key1";
            string key2  = "key2";
            string key3  = "key3";
            string key4  = "key4";
            string key5  = "key5";
            string key6  = "key6";
            string key7  = "key7";
            string key8  = "key8";
            string key9  = "key9";
            string key10 = "key10";
            string key11 = "key11";
            string key12 = "key12";
            string key13 = "key13";
            string key14 = "key14";
            string key15 = "key15";
            string key16 = "key16";

            NativeDictionary <BitBag> nat = new NativeDictionary <BitBag>(size);

            nat.Put(key1, bb1);
            nat.Put(key2, bb2);
            nat.Put(key3, bb3);
            nat.Put(key4, bb4);
            nat.Put(key5, bb5);
            nat.Put(key6, bb6);
            nat.Put(key7, bb7);
            nat.Put(key8, bb8);
            nat.Put(key9, bb9);
            nat.Put(key10, bb10);
            nat.Put(key11, bb11);
            nat.Put(key12, bb12);
            nat.Put(key13, bb13);
            nat.Put(key14, bb14);
            nat.Put(key15, bb15);
            nat.Put(key16, bb16);

            Assert.AreEqual(true, nat.IsKey(key1));
            Assert.AreEqual(true, nat.IsKey(key2));
            Assert.AreEqual(true, nat.IsKey(key3));
            Assert.AreEqual(true, nat.IsKey(key4));
            Assert.AreEqual(true, nat.IsKey(key5));
            Assert.AreEqual(true, nat.IsKey(key6));
            Assert.AreEqual(true, nat.IsKey(key7));
            Assert.AreEqual(true, nat.IsKey(key8));
            Assert.AreEqual(true, nat.IsKey(key9));
            Assert.AreEqual(true, nat.IsKey(key10));
            Assert.AreEqual(true, nat.IsKey(key11));
            Assert.AreEqual(true, nat.IsKey(key12));
            Assert.AreEqual(true, nat.IsKey(key13));
            Assert.AreEqual(true, nat.IsKey(key14));
            Assert.AreEqual(true, nat.IsKey(key15));
            Assert.AreEqual(true, nat.IsKey(key16));
        }