本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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'");
}