本文整理汇总了C#中CharSetSolver.Accepts方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.Accepts方法的具体用法?C# CharSetSolver.Accepts怎么用?C# CharSetSolver.Accepts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharSetSolver
的用法示例。
在下文中一共展示了CharSetSolver.Accepts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestLoopThatStartsWith0
public void TestLoopThatStartsWith0()
{
string regex = @"(w(a|bc){0,2})";
CharSetSolver css = new CharSetSolver(BitWidth.BV7);
var aut = css.Convert(regex,RegexOptions.Singleline,true);
//css.ShowGraph(aut, "CornerCase");
var str = "w.-J_";
var actual = css.Accepts(aut, str);
var expected = Regex.IsMatch(str, regex);
Assert.AreEqual(expected, actual);
}
示例2: TestWordBoundaryCase
public void TestWordBoundaryCase()
{
string s = "abc";
string r = @"\b";
CharSetSolver css = new CharSetSolver(BitWidth.BV7);
var aut = css.Convert(r,RegexOptions.Singleline,true);
//css.ShowGraph(aut, "test1");
css.RegexConverter.EliminateBoundaryStates(aut);
//css.ShowGraph(aut,"test2");
Assert.IsTrue(css.Accepts(aut, s));
Assert.IsTrue(Regex.IsMatch(s, r, RegexOptions.Singleline));
}
示例3: TestTrivialWordBoundary4
public void TestTrivialWordBoundary4()
{
Regex r = new Regex(@"^\b[[email protected]]\b$",RegexOptions.None);
CharSetSolver css = new CharSetSolver(BitWidth.BV16);
var aut = css.Convert(r.ToString(), RegexOptions.Singleline, true);
//css.ShowGraph(aut, "TrivialWordBoundary4_with_b");
css.RegexConverter.EliminateBoundaryStates(aut);
var aut1 = aut.RemoveEpsilons().Determinize().Minimize();
//css.ShowGraph(aut, "TrivialWordBoundary4");
string s = "@";
bool ismatchExpected = r.IsMatch(s);
bool ismatchActual = css.Accepts(aut1, s);
CheckValidity(css, aut, r);
}
示例4: TestWordBoundary
public void TestWordBoundary()
{
CharSetSolver css = new CharSetSolver(BitWidth.BV7);
var regex = @"\b(@|A)B\b";
Assert.IsTrue(Regex.IsMatch("AB", regex));
Assert.IsTrue(Regex.IsMatch("[email protected]", regex));
Assert.IsTrue(Regex.IsMatch("[email protected]&", regex));
Assert.IsTrue(Regex.IsMatch("+AB+", regex));
Assert.IsFalse(Regex.IsMatch("@B", regex));
Assert.IsFalse(Regex.IsMatch("[email protected]_", regex));
var aut = css.Convert(regex);//.RemoveEpsilons(css.MkOr).Determinize(css).Minimize(css);
//css.ShowGraph(aut, "aut");
Assert.IsTrue(css.Accepts(aut, "AB"));
Assert.IsTrue(css.Accepts(aut, "[email protected]"));
Assert.IsTrue(css.Accepts(aut, "[email protected]&"));
Assert.IsTrue(css.Accepts(aut, "+AB+"));
Assert.IsFalse(css.Accepts(aut, "@B"));
Assert.IsFalse(css.Accepts(aut, "[email protected]_"));
CheckValidity(css, aut, new Regex(regex, RegexOptions.Singleline));
}
示例5: Accepts
//returns true iff dfa accepts str
private static bool Accepts(Automaton<BDD> dfa1, string str, HashSet<char> al, CharSetSolver solver)
{
return solver.Accepts(dfa1, str);
//int currState = dfa1.InitialState;
//for (int i = 0; i < str.Length; i++)
//{
// currState = GetNextState(currState, str[i], dfa1, solver);
// if (currState < 0)
// return false;
//}
//return dfa1.GetFinalStates().ToList().Contains(currState);
}