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


C# CharSetSolver.MkRangeConstraint方法代码示例

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


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

示例1: TestIgnoreCaseTransformer

 public void TestIgnoreCaseTransformer()
 {
     CharSetSolver solver = new CharSetSolver();
     int t = System.Environment.TickCount;
     IgnoreCaseTransformer ic = new IgnoreCaseTransformer(solver);
     //simple test first:
     BDD a2c = solver.MkRangeConstraint('a', 'c');
     BDD a2cA2C = ic.Apply(a2c);
     BDD a2cA2C_expected = a2c.Or(solver.MkRangeConstraint('A', 'C'));
     Assert.AreEqual<BDD>(a2cA2C, a2cA2C_expected);
     //
     //comprehensive test:
     //
     //test that the whole array is correct:
     // Microsoft.Automata.Internal.Generated.IgnoreCaseRelation.ignorecase
     //  (generated by:)
     //
     // IgnoreCaseRelationGenerator.Generate(
     //    "Microsoft.Automata.Internal.Generated",
     //    "IgnoreCaseRelation",
     //    @"C:\GitHub\AutomataDotNet\Automata\src\Automata\Internal\Generated");
     //
     //test that all characters in it are truly equivalent wrt the igore-case option of regex
     //
     for (int i = 0; i <= 0xFFFF; i++)
     {
         char c = (char)i;
         if (ic.IsInDomain(c))
         {
             BDD cC = ic.Apply(solver.MkCharConstraint(c));
             foreach (char d in solver.GenerateAllCharacters(cC))
             {
                 Assert.IsTrue(Regex.IsMatch(d.ToString(), "^(?i:" + StringUtility.Escape(c) + ")$"));
             }
         }
     }
     //
     //second, test that all characters outside the domain are only equivalent (up-to-case) to themsevles
     //
     // for some reson this does not succeed, ??? some characters, e.g. '\xF7', are
     // equivalent to some other characters in the below test, but not when tested individually
     // there is a bug in Regex.IsMatch with ignore-case combined with intervals
     //
     //for (int i = 2; i <= 0xFFFD; i++)
     //{
     //    char c = (char)i;
     //    if (!ic.IsInDomain(c))
     //    {
     //        if (Regex.IsMatch(c.ToString(), @"^([\0-" + StringUtility.Escape((char)(i - 1)) + StringUtility.Escape((char)(i + 1)) + @"-\uFFFF])$", RegexOptions.IgnoreCase))
     //            Console.WriteLine(StringUtility.Escape(c));
     //    }
     //}
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:53,代码来源:UtilitiesTests.cs

示例2: ChooseUnifromlyTest

        public void ChooseUnifromlyTest()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV16);

            BDD set1 = solver.MkRangeConstraint('\0', '\x01', true);
            BDD set2 = solver.MkRangeConstraint( '\u0FFF', '\u0FFF');
            string set2str = solver.PrettyPrint(set2);
            BDD set3 = solver.MkRangeConstraint( '\u00FF', '\u00FF');
            BDD set4 = solver.MkRangeConstraint( '\u000F', '\u000F');

            BDD set = solver.MkOr(new BDD[]{set2, set3, set4, set1});

            string setstr = solver.PrettyPrint(set);

            set.ToDot(@"foo.dot");

            var map = new Dictionary<char, int>();
            map['\0'] = 0;
            map['\x01'] = 0;
            map['\u0FFF'] = 0;
            map['\u00FF'] = 0;
            map['\u000F'] = 0;

            for (int i = 0; i < 50000; i++)
            {
                var c = solver.ChooseUniformly(set);
                map[c] += 1;
            }
            foreach (var kv in map)
                Assert.IsTrue(kv.Value > 9700);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:31,代码来源:CharSetSolverTests.cs

示例3: ChooseTest2

        public void ChooseTest2()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV16);

            BDD set1 = solver.MkRangeConstraint('a', 'a', true);
            string set1str = solver.PrettyPrint(set1);
            BDD set2 = solver.MkRangeConstraint('a', 'a');
            string set2str = solver.PrettyPrint(set2);
            BDD set3 = solver.MkRangeConstraint('A', 'A');
            string set3str = solver.PrettyPrint(set3);

            BDD set1a = solver.MkOr(set2, set3);

            Assert.AreEqual<string>("[Aa]", set1str);
            Assert.AreEqual<string>("a", set2str);
            Assert.AreEqual<string>("A", set3str);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:17,代码来源:CharSetSolverTests.cs

示例4: HelperPredicates

 public HelperPredicates(CharSetSolver solver, bool OptimzeForAsciiInput)
 {
     this.solver = solver;
     helper_predicates = new List<string>();
     predicate_cache = new Dictionary<BDD, string>();
     ascii = solver.MkRangeConstraint('\0', '\x7F');
     this.OptimzeForASCIIinput = OptimzeForAsciiInput;
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:8,代码来源:HelperPredicates.cs

示例5: ChooseTest

        public void ChooseTest()
        {
            for (int i = 0; i < 10; i++)
            {
                CharSetSolver solver = new CharSetSolver(BitWidth.BV16);

                BDD set1 = solver.MkRangeConstraint('a', 'c', true);
                string set1str = solver.PrettyPrint(set1);
                BDD set2 = solver.MkRangeConstraint('a', 'c');
                string set2str = solver.PrettyPrint(set2);
                BDD set3 = solver.MkRangeConstraint( 'A', 'C');
                string set3str = solver.PrettyPrint(set3);

                BDD set1a = solver.MkOr(set2, set3);

                Assert.AreEqual<string>("[A-Ca-c]",set1str);
                Assert.AreEqual<string>("[a-c]", set2str);
                Assert.AreEqual<string>("[A-C]", set3str);

                int h1 = set1.GetHashCode();
                int h2 = set1a.GetHashCode();
                bool same = (h1 == h2);
                Assert.AreSame(set1, set1a);
                Assert.IsTrue(same);
                Assert.IsTrue(solver.AreEquivalent(set1, set1a));

                //int seed = solver.Chooser.RandomSeed;
                char choice1 = (char)solver.Choose(set1);
                char choice2 = (char)solver.Choose(set1);
                char choice3 = (char)solver.Choose(set1);
                char choice4 = (char)solver.Choose(set1);

                //solver.Chooser.RandomSeed = seed;
                //char choice1a = solver.Choose(set1a);
                //char choice2a = solver.Choose(set1a);
                //char choice3a = solver.Choose(set1a);
                //char choice4a = solver.Choose(set1a);

                //string s = new String(new char[] { choice1, choice2, choice3, choice4 });
                //string sa = new String(new char[] { choice1a, choice2a, choice3a, choice4a });

                //Assert.AreEqual<string>(s, sa);
            }
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:44,代码来源:CharSetSolverTests.cs

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

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

示例8: GenerateMintermsTest2

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

            BDD a = bddb.MkRangeConstraint( 'b', 'c');
            BDD b = bddb.MkRangeConstraint( 'b', 'b');
            BDD b2 = bddb.MkRangeConstraint( 'b', 'b');
            BDD c = bddb.MkRangeConstraint( 'c', 'c');
            BDD b3 = bddb.MkRangeConstraint( 'b', 'b');

            var combinations = new List<Pair<bool[], BDD>>(bddb.GenerateMinterms(new BDD[] { a, b, b2, c, b3 }));
            Assert.AreEqual<int>(3, combinations.Count, "only three combinations are possible");
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:13,代码来源:CharSetSolverTests.cs

示例9: GenerateMintermsTest1

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

            BDD a = bddb.MkRangeConstraint( 'a', 'a');
            BDD b = bddb.MkRangeConstraint( 'b', 'b');
            BDD c = bddb.MkRangeConstraint( 'c', 'c');

            var combinations = new List<Pair<bool[], BDD>>(bddb.GenerateMinterms(new BDD[] { a, b, c }));
            Assert.AreEqual<int>(4, combinations.Count);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:11,代码来源:CharSetSolverTests.cs


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