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


C# CharSetSolver.MkRangesConstraint方法代码示例

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


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

示例1: MinMaxTest

 public void MinMaxTest()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     var ranges = new char[][] {
         new char[] {'\u55A0', '\u55AA'},
         new char[] { 'a', 'c' },
         new char[] {'\u5555', '\u55A5'},
         new char[] { 'e', 'h' }
     };
     BDD s = solver.MkRangesConstraint(false, ranges);
     char c = solver.GetMax(s);
     Assert.AreEqual<char>('\u55AA', c, "not the maximum character");
     c = (char)solver.GetMin(s);
     Assert.AreEqual<char>('a', c, "not the minimum character");
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:15,代码来源:CharSetSolverTests.cs

示例2: GenerateMintermsTest4

        public void GenerateMintermsTest4()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV7);

            BDD a = solver.MkRangeConstraint( '\0', '\x7E');
            BDD b = solver.MkRangeConstraint( '1', '1');
            BDD c = solver.MkRangeConstraint( '1', '3');

            var Z = new List<Pair<bool[], BDD>>(solver.GenerateMinterms(new BDD[] { a, b, c })).ToArray();
            var Y = Array.ConvertAll(Z, x => x.Second);
            var X = new HashSet<BDD>(Y);
            Assert.AreEqual<int>(4, X.Count);

            Assert.IsTrue(X.Contains(solver.MkRangeConstraint( '1', '1')));
            Assert.IsTrue(X.Contains(solver.MkRangeConstraint( '2', '3')));
            Assert.IsTrue(X.Contains(solver.MkRangesConstraint(false, new char[][] {new char[] { '\x7F', '\x7F' } })));
            Assert.IsTrue(X.Contains(solver.MkRangesConstraint(false, new char[][] { new char[] { '4', '\x7E' }, new char[] { '\0', '0' } })));
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:18,代码来源:CharSetSolverTests.cs

示例3: 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

示例4: GenerateMintermsTest3

        public void GenerateMintermsTest3()
        {
            CharSetSolver bddb = new CharSetSolver(BitWidth.BV16);

            BDD A = bddb.MkRangeConstraint( '1', '4');
            BDD A1 = bddb.MkRangesConstraint(false, new char[][] { new char[] { '1', '3' }, new char[] { '3', '4' }});
            BDD B = bddb.MkRangesConstraint(false, new char[][] { new char[] { '2', '3' }, new char[] { '5', '6' }, new char[] { '8', '8' } });
            BDD C = bddb.MkRangesConstraint(false, new char[][] { new char[] { '3', '4' }, new char[] { '6', '7' }, new char[] { '9', '9' } });
            BDD D = bddb.MkRangesConstraint(false, new char[][] { new char[] { '0', '0' }, new char[] { '8', '9' } });

            var combinations = new List<Pair<bool[], BDD>>(bddb.GenerateMinterms(new BDD[] { A, B, C, A1, D }));
            Assert.AreEqual<int>(11, combinations.Count, "exactly 11 combinations must be possible");
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:13,代码来源:CharSetSolverTests.cs

示例5: GenerateMembersTest

        public void GenerateMembersTest()
        {
            foreach (var encoding in new BitWidth[]{
                BitWidth.BV7, BitWidth.BV8, BitWidth.BV16})
            {
                CharSetSolver solver = new CharSetSolver(encoding);
                var ranges = new char[][] {
                new char[] { 'a', 'c' },
                new char[] {'0', '5'},
                new char[] { 'e', 'h' },
                new char[] {'6', '9'},};
                BDD s = solver.MkRangesConstraint(false, ranges);

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

                Assert.AreEqual<int>(17, members.Count, "wrong number of members in the range [a-ce-h0-9]");
                Assert.AreEqual<char>('0', members[0], "the smallest character in the range must be '0'");
                Assert.AreEqual<char>('h', members[16], "the largest character in the range must be 'h'");

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

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


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