Exemplo n.º 1
0
        public void Match_DistanceTest3()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 1000));

            Assert.AreEqual(0, dmp.Match("abcdefghijklmnopqrstuvwxyz", "abcdefg", 24),
                            "match_bitap: Distance test #3.");
        }
Exemplo n.º 2
0
        public void InitAlphabet_UniqueSet_ReturnsExpectedBitmask()
        {
            var bitmask = new Dictionary <char, int>
            {
                { 'a', 4 },
                { 'b', 2 },
                { 'c', 1 }
            };

            CollectionAssert.AreEqual(bitmask, BitapAlgorithm.InitAlphabet("abc"), "match_alphabet: Unique.");
        }
Exemplo n.º 3
0
        public void InitAlphabet_UniqueSet_ReturnsExpectedBitmask()
        {
            var bitmask = new Dictionary <char, int>
            {
                { 'a', 4 },
                { 'b', 2 },
                { 'c', 1 }
            };

            Assert.Equal(bitmask, BitapAlgorithm.InitAlphabet("abc"));
        }
Exemplo n.º 4
0
        public void InitAlphabet_SetWithDuplicates_ReturnsExpectedBitmask()
        {
            var bitmask = new Dictionary <char, int>
            {
                { 'a', 37 },
                { 'b', 18 },
                { 'c', 8 }
            };

            Assert.Equal(bitmask, BitapAlgorithm.InitAlphabet("abcaba"));
        }
Exemplo n.º 5
0
        public void Match_Overflow()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(2, dmp.Match("123456789xx0", "3456789x0", 2));
        }
Exemplo n.º 6
0
        public void Match_Fuzzy3()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(-1, dmp.Match("abcdefghijk", "bxy", 1));
        }
Exemplo n.º 7
0
        public void Match_Fuzzy2()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(2, dmp.Match("abcdefghijk", "cdefxyhijk", 5));
        }
Exemplo n.º 8
0
        public void Match_Fuzzy1()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(4, dmp.Match("abcdefghijk", "efxhi", 0));
        }
Exemplo n.º 9
0
        public void Match_Exact2()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(5, dmp.Match("abcdefghijk", "fgh", 0));
        }
Exemplo n.º 10
0
        public void Match_MultipleSelect1()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.AreEqual(0, dmp.Match("abcdexyzabcde", "abccde", 3), "match_bitap: Multiple select #1.");
        }
Exemplo n.º 11
0
        public void Match_BeyondEndMatch()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(3, dmp.Match("abcdef", "defyy", 4));
        }
Exemplo n.º 12
0
        public void Match_MultipleSelect2()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(8, dmp.Match("abcdexyzabcde", "abccde", 5));
        }
Exemplo n.º 13
0
        public void Match_Treshold3()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.0f, 100));

            Assert.Equal(1, dmp.Match("abcdefghijk", "bcdef", 1));
        }
Exemplo n.º 14
0
        public void Match_Treshold2()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.3f, 100));

            Assert.Equal(-1, dmp.Match("abcdefghijk", "efxyhi", 1));
        }
Exemplo n.º 15
0
        public void Match_Exact1()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.AreEqual(5, dmp.Match("abcdefghijk", "fgh", 5), "match_bitap: Exact match #1.");
        }
Exemplo n.º 16
0
        public void Match_BeforeStartMatch()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(0, dmp.Match("abcdef", "xxabc", 4));
        }
Exemplo n.º 17
0
        public void Match_DistanceTest2()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 10));

            Assert.Equal(0, dmp.Match("abcdefghijklmnopqrstuvwxyz", "abcdxxefg", 1));
        }
Exemplo n.º 18
0
        public void Match_OversizedPattern()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.5f, 100));

            Assert.Equal(0, dmp.Match("abcdef", "xabcdefy", 0));
        }
Exemplo n.º 19
0
        public void Match_Treshold1()
        {
            var dmp = new BitapAlgorithm(new MatchSettings(0.4f, 100));

            Assert.AreEqual(4, dmp.Match("abcdefghijk", "efxyhi", 1), "match_bitap: Threshold #1.");
        }