当前位置: 首页>>代码示例>>C#>>正文


C# CharSetSolver.MkCharSetFromRanges方法代码示例

本文整理汇总了C#中CharSetSolver.MkCharSetFromRanges方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.MkCharSetFromRanges方法的具体用法?C# CharSetSolver.MkCharSetFromRanges怎么用?C# CharSetSolver.MkCharSetFromRanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CharSetSolver的用法示例。


在下文中一共展示了CharSetSolver.MkCharSetFromRanges方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestRanges3

        public void TestRanges3()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
            BDD cond = solver.MkCharSetFromRegexCharClass(@"\d");
            int cnt = cond.CountNodes();
            Pair<uint, uint>[] ranges = solver.ToRanges(cond);
            BDD set = solver.MkCharSetFromRanges(ranges);
            int nodes = set.CountNodes();
            var ranges2 = new List<Pair<uint, uint>>(ranges);
            ranges2.Reverse();
            BDD set2 = solver.MkCharSetFromRanges(ranges2);
            int nodes2 = set.CountNodes();
            var ranges3 = solver.ToRanges(set2);
            BDD set3 = solver.MkCharSetFromRanges(ranges3);

            int cnt2 = set2.CountNodes();
            int cnt3 = set3.CountNodes();
            Assert.IsTrue(set2 == set3);

            Assert.AreEqual<int>(nodes, nodes2);
            Assert.AreSame(set,set2);

            set.ToDot("digits.dot");

            //check equivalence
            bool equiv = solver.MkOr(solver.MkAnd(cond, solver.MkNot(set)), solver.MkAnd(set, solver.MkNot(cond))) == solver.False;

            Assert.AreEqual<int>(31, ranges.Length);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:29,代码来源:CharSetTests.cs

示例2: TestRanges2b

 public void TestRanges2b()
 {
     BitWidth enc = BitWidth.BV16;
     CharSetSolver solver = new CharSetSolver(enc);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\w");
     var ranges1 = solver.ToRanges(cond);
     var cond1 = solver.MkCharSetFromRanges(ranges1);
     Pair<uint, uint>[] ranges = solver.ToRanges(cond1);
     var cond2 = solver.MkCharSetFromRanges(ranges);
     Assert.AreSame(cond1, cond2);
     Assert.AreSame(cond, cond1);
     //cond.ToDot("cond.dot");
     Assert.AreEqual<uint>((uint)'0', ranges[0].First);
     Assert.AreEqual<uint>((uint)'9', ranges[0].Second);
     Assert.AreEqual<uint>((uint)'A', ranges[1].First);
     Assert.AreEqual<uint>((uint)'Z', ranges[1].Second);
     Assert.AreEqual<uint>((uint)'_', ranges[2].First);
     Assert.AreEqual<uint>((uint)'_', ranges[2].Second);
     Assert.AreEqual<uint>((uint)'a', ranges[3].First);
     Assert.AreEqual<uint>((uint)'z', ranges[3].Second);
     Assert.AreEqual<int>(426, ranges.Length);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:22,代码来源:CharSetTests.cs

示例3: TestRanges2

 public void TestRanges2()
 {
     BitWidth enc = BitWidth.BV7;
     CharSetSolver solver = new CharSetSolver(enc);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\w");
     int nodes = cond.CountNodes();
     Pair<uint, uint>[] ranges = solver.ToRanges(cond);
     BDD cond2 = solver.MkCharSetFromRanges(ranges);
     Assert.AreSame(cond, cond2);
     int nodes2 = cond2.CountNodes();
     Assert.AreEqual<uint>((uint)'0', ranges[0].First);
     Assert.AreEqual<uint>((uint)'9', ranges[0].Second);
     Assert.AreEqual<uint>((uint)'A', ranges[1].First);
     Assert.AreEqual<uint>((uint)'Z', ranges[1].Second);
     Assert.AreEqual<uint>((uint)'_', ranges[2].First);
     Assert.AreEqual<uint>((uint)'_', ranges[2].Second);
     Assert.AreEqual<uint>((uint)'a', ranges[3].First);
     Assert.AreEqual<uint>((uint)'z', ranges[3].Second);
     Assert.AreEqual<int>(4, ranges.Length);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:20,代码来源:CharSetTests.cs

示例4: TestCardinality3

 public void TestCardinality3()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"[\w-[\d]]");
     int cnt = cond.CountNodes();
     Pair<uint, uint>[] ranges = solver.ToRanges(cond);
     BDD set = solver.MkCharSetFromRanges(ranges);
     int nodes = set.CountNodes();
     int size = (int)solver.ComputeDomainSize(set);
     int expected = 0;
     foreach (var range in ranges)
         expected += ((int)(range.Second - range.First) + 1);
     Assert.AreEqual<int>(expected, size);
     int wCnt = 0;
     for (int i = 0; i <= 0xFFFF; i++)
     {
         int cat = (int)char.GetUnicodeCategory((char)i);
         if (cat == 0 || cat == 1 || cat == 2 || cat == 3 || cat == 4 || cat == 5 ||
              cat == 8 || cat == 18) //same as \w in regex
             if (!char.IsDigit((char)i))
                 wCnt += 1;
     }
     Assert.AreEqual<int>(wCnt, size);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:24,代码来源:CharSetTests.cs

示例5: TestCardinality

 public void TestCardinality()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\d");
     int cnt = cond.CountNodes();
     Pair<uint, uint>[] ranges = solver.ToRanges(cond);
     BDD set = solver.MkCharSetFromRanges(ranges);
     int nodes = set.CountNodes();
     int size = (int)solver.ComputeDomainSize(set);
     int expected = 0;
     foreach (var range in ranges)
         expected += ((int)(range.Second - range.First) + 1);
     Assert.AreEqual<int>(expected, size);
     int digitCnt = 0;
     for (int i = 0; i <= 0xFFFF; i++)
     {
         if (char.IsDigit(((char)i)))
             digitCnt += 1;
     }
     Assert.AreEqual<int>(digitCnt, size);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:21,代码来源:CharSetTests.cs

示例6: GenerateMembersTest2

        public void GenerateMembersTest2()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
            var ranges = new char[][] {
                new char[] { 'a', 'c' },
                new char[] {'\u5555', '\u55A5'},
                new char[] { 'e', 'h' },
                new char[] {'\u55A0', '\u55AA'},
            };
            BDD s = solver.MkRangesConstraint(false, ranges);
            s.ToDot("bug.dot");

            var r = solver.ToRanges(s);
            var s2 = solver.MkCharSetFromRanges(r);

            var members = new List<char>(solver.GenerateAllCharacters(s2, false));
            var smallest = (char)solver.GetMin(s2);

            Assert.AreEqual<int>(93, members.Count, "wrong number of members in the range [a-ce-h\\u5555-\\u55AA]");
            Assert.AreEqual<char>('a', members[0], "the smallest character in the range must be 'a'");
            Assert.AreEqual<char>('\u55AA', members[members.Count - 1], "the largest character in the range must be '\\u55AA'");

            var membersInReverse = new List<char>(solver.GenerateAllCharacters(s, true));

            Assert.AreEqual<int>(93, membersInReverse.Count, "wrong number of members in the range [a-ce-h\\u5555-\\u55AA]");
            Assert.AreEqual<char>('\u55AA', membersInReverse[0], "the first character in the reverse enumeration must be '\\u55AA'");
            Assert.AreEqual<char>('a', membersInReverse[membersInReverse.Count-1], "the last character in the reverse enumeration must be 'a'");
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:28,代码来源:CharSetSolverTests.cs


注:本文中的CharSetSolver.MkCharSetFromRanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。