本文整理汇总了C#中CharSetSolver.ComputeDomainSize方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.ComputeDomainSize方法的具体用法?C# CharSetSolver.ComputeDomainSize怎么用?C# CharSetSolver.ComputeDomainSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharSetSolver
的用法示例。
在下文中一共展示了CharSetSolver.ComputeDomainSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSurrogateRange
public void TestSurrogateRange()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
//high and low surrogate pair elements
BDD cond = solver.MkCharSetFromRegexCharClass(@"\p{Cs}");
cond.ToDot("surr.dot");
int elems = (int)solver.ComputeDomainSize(cond);
int nodes = cond.CountNodes();
Assert.AreEqual<int>(7, nodes); //highly compact BDD representation
var ranges = solver.ToRanges(cond);
Assert.AreEqual<int>(1, ranges.Length);
Assert.AreEqual<uint>(ranges[0].First, 0xd800);
Assert.AreEqual<uint>(ranges[0].Second, 0xdFFF);
//the total number of surrogates (there are 1024 low surrogates and 1024 high surrogates)
Assert.AreEqual<int>(2048, elems);
}
示例2: TestLargeRange2
public void TestLargeRange2()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
BDD cond = solver.MkCharSetFromRegexCharClass(@"[\u0000-\u7FFF\uA000-\uA00F]");
uint elems = (uint)solver.ComputeDomainSize(cond);
int nodes = cond.CountNodes();
Assert.AreEqual<int>(14, nodes);
var ranges = solver.ToRanges(cond);
Assert.AreEqual<int>(2, ranges.Length);
Assert.AreEqual<uint>(ranges[0].First, 0);
Assert.AreEqual<uint>(ranges[0].Second, 0x7FFF);
Assert.AreEqual<uint>(ranges[1].First, 0xA000);
Assert.AreEqual<uint>(ranges[1].Second, 0xA00F);
Assert.AreEqual<uint>(((uint)1 << 15) + ((uint)1 << 4), elems);
}
示例3: TestLargeRange
public void TestLargeRange()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
BDD cond = solver.MkCharSetFromRegexCharClass(@"[\u0000-\u7FFF]");
int elems = (int)solver.ComputeDomainSize(cond);
int nodes = cond.CountNodes();
Assert.AreEqual<int>(3, nodes);
Assert.AreEqual<int>((1 << 15), elems);
}
示例4: TestDotGen
public void TestDotGen()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV7);
BDD cond = solver.MkCharSetFromRange('\0', '\x0F');
int cnt = (int)solver.ComputeDomainSize(cond);
cond.ToDot(@"bdd2.dot");
}
示例5: 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);
}
示例6: 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);
}