Example #1
0
        public void VerifyAllWordsAreLoaded()
        {
            int WordsCount          = HSpell.Loader.GetWordCountInHSpellFolder(hspellPath);
            DictRadix <MorphData> d = HSpell.Loader.LoadDictionaryFromHSpellFolder(hspellPath, true);

            Assert.Equal(WordsCount, d.Count); // Compare expected words count with the cached counter

            // Verify the cached counter equals to the count of elements retrieved by actual enumeration,
            // and that the nodes are alphabetically sorted
            int    enCount  = 0;
            string nodeText = string.Empty;

            DictRadix <MorphData> .RadixEnumerator en = d.GetEnumerator() as DictRadix <MorphData> .RadixEnumerator;
            while (en.MoveNext())
            {
                Assert.True(string.Compare(nodeText, en.CurrentKey, StringComparison.Ordinal) < 0);
                nodeText = en.CurrentKey;
                enCount++;
            }
            Assert.Equal(WordsCount, enCount); // Compare expected words count with count yielded by iteration
        }
Example #2
0
        private void btnTestRadix_Click(object sender, EventArgs e)
        {
            DictRadix <object> r = new DictRadix <object>();;

            r.AddNode("abcdef", 5);
            r.AddNode("ab", 11);
            r.AddNode("abcd", 115);
            r.AddNode("aaa", 41);
            r.AddNode("abc", 111);
            r.AddNode("a", 101);
            r.AddNode("bba", 22);
            r.AddNode("bbc", 22);
            r.AddNode("bb", 221);
            r.AddNode("def", 22);
            r.AddNode("deg", 33);
            r.AddNode("deg", 33);
            r.AddNode("cfg", 3222);

            DictRadix <object> .RadixEnumerator en = r.GetEnumerator() as DictRadix <object> .RadixEnumerator;
            while (en.MoveNext())
            {
                System.Diagnostics.Trace.WriteLine(string.Format("{0} {1}", en.CurrentKey, en.Current.ToString()));
            }
        }