Ejemplo n.º 1
0
        public void DeleteTest()
        {
            trie.Insert("Word3", null);
            trie.Insert("Word2", 22);
            trie.Insert("Word1", null);
            trie.Insert("OtherWord3");
            trie.Insert("OtherWord2");
            trie.Insert("OtherWord1");

            trie.Delete("Word2");
            trie.Delete("OtherWord2");

            trie.AssertNodes(
                new TrieNode("Word3", null),
                new TrieNode("Word1", null),
                new TrieNode("OtherWord3", null),
                new TrieNode("OtherWord1", null));

            trie.Delete("OtherWord1");
            trie.Delete("Word3");
            trie.AssertNodes(
                new TrieNode("Word1", null),
                new TrieNode("OtherWord3", null));

            trie.Delete("OtherWord3");
            trie.Delete("OtherWord3");
            trie.AssertNodes(new TrieNode("Word1", null));

            trie.Delete("Word1");
            CollectionAssertEx.IsEmpty(TrieTestHelper.CollectKeys(trie));
        }
Ejemplo n.º 2
0
        public void SuffixTreeNode_DefaultsTest()
        {
            SuffixTreeNode node = new SuffixTreeNode(-1, false);

            Assert.AreEqual(-1, node.Index);
            Assert.IsFalse(node.IsTerminal);
            CollectionAssertEx.IsEmpty(node.GetKeys());
            CollectionAssertEx.IsEmpty(node.GetChildren());
        }
Ejemplo n.º 3
0
        public void DisjointSetItemsTest()
        {
            DisjointSet <int> disjointSet = new DisjointSet <int>();

            CollectionAssertEx.IsEmpty(disjointSet.Items);
            disjointSet.MakeSet(1);
            disjointSet.MakeSet(2);
            disjointSet.MakeSet(3);
            CollectionAssertEx.AreEquivalent(new int[] { 3, 1, 2 }, disjointSet.Items);
        }
        public void ValuesCollectionEnumeratorSimpleTest()
        {
            List <HashMapDataValue> valueList = new List <HashMapDataValue>();

            foreach (var value in this.hashMap.Values)
            {
                valueList.Add(value);
            }
            CollectionAssertEx.IsEmpty(valueList);
        }
        public void KeysCollectionEnumeratorSimpleTest()
        {
            List <HashMapDataKey> keyList = new List <HashMapDataKey>();

            foreach (var key in this.hashMap.Keys)
            {
                keyList.Add(key);
            }
            CollectionAssertEx.IsEmpty(keyList);
        }
Ejemplo n.º 6
0
        public void QueueToArrayTest()
        {
            Queue <int> queue = new Queue <int>();

            CollectionAssertEx.IsEmpty(queue.ToArray());
            queue.EnQueue(1);
            queue.EnQueue(2);
            queue.EnQueue(3);
            queue.EnQueue(4);
            CollectionAssert.AreEqual(new int[] { 1, 2, 3, 4 }, queue.ToArray());
        }
        public void ClearTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            CollectionAssertEx.IsNotEmpty(this.hashMap.Keys);
            CollectionAssertEx.IsNotEmpty(this.hashMap.Values);

            this.hashMap.Clear();
            CollectionAssertEx.IsEmpty(this.hashMap.Keys);
            CollectionAssertEx.IsEmpty(this.hashMap.Values);
        }
Ejemplo n.º 8
0
        public void DisjointSetRemoveSetTest()
        {
            DisjointSet <int> disjointSet = new DisjointSet <int>();

            disjointSet.MakeSet(1);
            disjointSet.MakeSet(2);
            disjointSet.MakeSet(3);
            disjointSet.MakeSet(4);
            disjointSet.MakeSet(5);
            disjointSet.Union(2, 3);
            disjointSet.Union(4, 5);
            CollectionAssertEx.AreEquivalent(new int[] { 1, 3, 5, 4, 2 }, disjointSet.Items);
            disjointSet.RemoveSet(2);
            CollectionAssertEx.AreEquivalent(new int[] { 1, 4, 5 }, disjointSet.Items);
            disjointSet.RemoveSet(5);
            CollectionAssertEx.AreEquivalent(new int[] { 1 }, disjointSet.Items);
            disjointSet.RemoveSet(1);
            CollectionAssertEx.IsEmpty(disjointSet.Items);
        }
 public void ForEachSimpleTest2()
 {
     tree.Insert("test", 1);
     tree.Delete("test");
     CollectionAssertEx.IsEmpty(tree.ToList());
 }
 public void DefaultsTest()
 {
     CollectionAssertEx.IsEmpty(this.hashMap.Keys);
     CollectionAssertEx.IsEmpty(this.hashMap.Values);
     Assert.AreEqual(0, this.hashMap.Count);
 }