Exemplo n.º 1
0
        public void TestAddRange()
        {
            // Generate random strings
            var randoms = Enumerable.Range(0, 10000).Select(_ => Guid.NewGuid().ToString()).Select(r => new KeyValuePair <string, string>(r, r)).ToArray();

            // Insert them
            var trie = new PatriciaTrie <string>();

            trie.AddRange(randoms);

            // Get and test them
            foreach (var random in randoms)
            {
                trie[random.Key].Is(random.Value);
                trie.ContainsKey(random.Key).IsTrue();
            }
        }
Exemplo n.º 2
0
        public void TestRandom()
        {
            // Generate random strings
            var randoms = Enumerable.Range(0, 10000).Select(_ => Guid.NewGuid().ToString()).ToArray();

            // Insert them
            var trie = new PatriciaTrie <string>();

            foreach (var random in randoms)
            {
                trie.Add(random, random);
            }

            // Get and test them
            foreach (var random in randoms)
            {
                trie[random].Is(random);
                trie.ContainsKey(random).IsTrue();
            }
        }
        public void TestPutAll()
        {
            // Generate random strings
            Dictionary <string, string> randoms = new Dictionary <string, string>();

            for (int i = 0; i < 1000; i++)
            {
                string random = System.Guid.NewGuid().ToString();
                randoms[random] = random;
            }
            // Insert them
            PatriciaTrie <string> trie = new PatriciaTrie <string>();

            trie.PutAll(randoms);

            // Get and test them
            foreach (KeyValuePair <string, string> random in randoms)
            {
                Assert.AreEqual(random.Value, trie[random.Key]);
                Assert.IsTrue(trie.ContainsKey(random.Key));
            }
        }
        public void TestRandom()
        {
            // Generate random strings
            List <string> randoms = new List <string>();

            for (int i = 0; i < 10000; i++)
            {
                randoms.Add(System.Guid.NewGuid().ToString());
            }
            // Insert them
            PatriciaTrie <string> trie = new PatriciaTrie <string>();

            foreach (string random in randoms)
            {
                trie[random] = random;
            }
            // Get and test them
            foreach (string random in randoms)
            {
                Assert.AreEqual(random, trie[random]);
                Assert.IsTrue(trie.ContainsKey(random));
            }
        }