public void DoMatchesTest()
        {
            var matcher1 = new DirectMatchProvider(false);
            var matcher2 = new ChineseZhCnPinYinInitialsMatchProvider(false);
            var test     = new MatchCache("多重hello world");

            matcher1.AppendDescriptions(ref test);
            matcher2.AppendDescriptions(ref test);

            {
                bool throwException = false;
                try
                {
                    var ret = matcher1.DoMatches(new MatchCache("123"), new List <string>()
                    {
                        "dc"
                    });
                    var ret2 = matcher1.DoMatches(new MatchCache("abc"), new List <string>()
                    {
                        "dc"
                    });
                    ret.Merge(ret2);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throwException = true;
                }

                Assert.IsTrue(throwException);
            }

            {
                var ret = matcher1.DoMatches(test, new List <string>()
                {
                    "dc"
                });
                var ret2 = matcher2.DoMatches(test, new List <string>()
                {
                    "dc"
                });
                ret.Merge(ret2);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "dc");
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == test.StringLength &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false &&
                              m[6] == false &&
                              m[7] == false &&
                              m[8] == false &&
                              m[9] == false &&
                              m[10] == false &&
                              m[11] == false &&
                              m[12] == false);
            }

            {
                var kws = new List <string>()
                {
                    "dc"
                };
                var ret  = matcher1.DoMatches(test, kws);
                var ret2 = matcher2.DoMatches(test, kws);
                ret.Merge(ret2);
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "dc");
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == test.StringLength &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false &&
                              m[6] == false &&
                              m[7] == false &&
                              m[8] == false &&
                              m[9] == false &&
                              m[10] == false &&
                              m[11] == false &&
                              m[12] == false);
            }


            {
                var ret = matcher1.DoMatches(test, new List <string>()
                {
                    "wor"
                });
                var ret2 = matcher2.DoMatches(test, new List <string>()
                {
                    "Dc"
                });
                ret.Merge(ret2);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(ret.Keywords.Count == 2 && ret.Keywords.Any(x => x == "Dc") && ret.Keywords.Any(x => x == "wor"));
                Assert.IsTrue(m.Count == test.StringLength &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false &&
                              m[6] == false &&
                              m[7] == false &&
                              m[8] == true &&
                              m[9] == true &&
                              m[10] == true &&
                              m[11] == false &&
                              m[12] == false);
            }

            {
                var ret = matcher2.DoMatches(test, new List <string>()
                {
                    "dc"
                });
                ret.Merge(matcher1.DoMatches(test, new List <string>()
                {
                    "wor", "abs"
                }));
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
                Assert.IsTrue(ret.Keywords.Count == 3);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == test.StringLength &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false &&
                              m[6] == false &&
                              m[7] == false &&
                              m[8] == true &&
                              m[9] == true &&
                              m[10] == true &&
                              m[11] == false &&
                              m[12] == false);
            }
        }
        public void DoMatchesTest()
        {
            var matcher     = new DirectMatchProvider(false);
            var matcherCase = new DirectMatchProvider(true);

            Assert.IsTrue(matcher.GetProviderName() == nameof(DirectMatchProvider));
            var dspen = matcher.GetProviderDescriptionEn();
            var dsp   = matcher.GetProviderDescription();

            {
                var ret = matcher.DoMatches(new MatchCache(""), new[] { "" });
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
            }

            {
                string org = "abcdefg";
                var    str = new MatchCache(org);
                matcher.AppendDescriptions(ref str);
                matcherCase.AppendDescriptions(ref str);
            }

            {
                string org = "abcdefg";
                var    kws = new[] { "a" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "a");
                Assert.IsTrue(m.Count == org.Length && m[0] == true && m[1] == false);
            }

            {
                string org = "abcdefg";
                var    kws = new[] { "A" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "A");
                Assert.IsTrue(m.Count == org.Length && m[0] == true && m[1] == false);
            }

            {
                string org = "abcdefg";
                var    kws = new[] { "a" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "a");
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length && m[0] == true && m[1] == false);
            }

            {
                string org = "abcdefg";
                var    kws = new[] { "A" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "A");
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
                var m = ret.HitFlags;
                Assert.IsTrue(m.All(x => x == false));
            }

            {
                string org = "abcdefgabcdefg";
                var    kws = new[] { "defg", "abc" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m.All(x => x == true));
            }

            {
                string org = "abcDefgabcdefg";
                var    kws = new[] { "Defg", "abc" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              !m.All(x => x == true));
            }

            {
                string org = "abaaa";
                var    kws = new[] { "aa" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == true);
            }
            {
                string org = "abaa a";
                var    kws = new[] { "aa" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == false &&
                              m[5] == false);
            }
            {
                string org = "abaa a";
                var    kws = new[] { " " };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == true &&
                              m[5] == false);
            }
            {
                string org = "abAAa";
                var    kws = new[] { "aa" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == true);
            }

            {
                string org = "abAA a";
                var    kws = new[] { "aa" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == false &&
                              m[5] == false);
            }

            {
                string org = "abAA a";
                var    kws = new[] { "aA" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
            }

            {
                string org = "abAA a";
                var    kws = new[] { "AA" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == false &&
                              m[5] == false);
            }



            {
                string org = "abAA a";
                var    kws = new[] { "ab", "AB" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false);
            }
        }