public void SimpleNegation() { ENFA_Controller regex = new ENFA_Controller(ParserType.Regex); string regexPattern = @"./b" + Constants.ExitContext; if (regex.Tokenizer.Tokenize("UnitTest", new StreamReader(regexPattern.ToStream()))) { Assert.True(regex.Parser.Parse(new StreamReader("a".ToStream())).ToList().Count > 0); Assert.True(regex.Parser.Parse(new StreamReader("c".ToStream())).ToList().Count > 0); Assert.False(regex.Parser.Parse(new StreamReader("b".ToStream())).ToList().Count > 0); } }
public void SimpleConcatination() { ENFA_Controller regex = new ENFA_Controller(ParserType.Regex); string regexPattern = @"ab" + Constants.ExitContext; if (regex.Tokenizer.Tokenize("UnitTest", new StreamReader(regexPattern.ToStream()))) { Console.WriteLine(regex.PrintHierarchy); Assert.True(regex.Parser.Parse(new StreamReader("ab".ToStream())).ToList().Count > 0); Assert.False(regex.Parser.Parse(new StreamReader("a".ToStream())).ToList().Count > 0); Assert.False(regex.Parser.Parse(new StreamReader("b".ToStream())).ToList().Count > 0); Assert.False(regex.Parser.Parse(new StreamReader("ba".ToStream())).ToList().Count > 0); } }
public void CreateGrammarInstanceWithoutError() { Exception expected = null; Exception actual = null; ENFA_Controller controller; try { controller = new ENFA_Controller(ParserType.Grammar); } catch (Exception ex) { actual = ex; } Assert.Equal(expected, actual); }
public void SetTokenizer() { Exception expected = null; Exception actual = null; ENFA_Controller controller; try { controller = new ENFA_Controller(ParserType.Regex); controller.Tokenizer = new ENFA_Regex_Tokenizer(controller); } catch (Exception ex) { actual = ex; } Assert.Equal(expected, actual); }
public void QuestionMarkFirst_NotAllowed() { ENFA_Controller regex = new ENFA_Controller(ParserType.Regex); string regexPattern = @"?" + Constants.ExitContext; Exception ex = Assert.Throws <ENFA_RegexBuild_Exception>(() => regex.Tokenizer.Tokenize("UnitTest", new StreamReader(regexPattern.ToStream()))); }
public void GroupingLookbehind_MissingMathingType_NotAllowed() { ENFA_Controller regex = new ENFA_Controller(ParserType.Regex); string regexPattern = @"(?<b)a" + Constants.ExitContext; Exception ex = Assert.Throws <ENFA_RegexBuild_Exception>(() => regex.Tokenizer.Tokenize("UnitTest", new StreamReader(regexPattern.ToStream()))); }
public void GroupingNamed_BackreferenceNumberDoesNotExist_NotAllowed() { ENFA_Controller regex = new ENFA_Controller(ParserType.Regex); string regexPattern = @"a\4" + Constants.ExitContext; Exception ex = Assert.Throws <ENFA_RegexBuild_Exception>(() => regex.Tokenizer.Tokenize("UnitTest", new StreamReader(regexPattern.ToStream()))); }
public void SquareBracketEscaped_Negate_NotAllowed() { ENFA_Controller regex = new ENFA_Controller(ParserType.Regex); string regexPattern = @"[^\9\c]" + Constants.ExitContext; Exception ex = Assert.Throws <ENFA_RegexBuild_Exception>(() => regex.Tokenizer.Tokenize("UnitTest", new StreamReader(regexPattern.ToStream()))); }
public void CurlyBracketNonDigitOnSecondPosition_NotAllowed() { ENFA_Controller regex = new ENFA_Controller(ParserType.Regex); string regexPattern = @"a{2,a}" + Constants.ExitContext; Exception ex = Assert.Throws <ENFA_RegexBuild_Exception>(() => regex.Tokenizer.Tokenize("UnitTest", new StreamReader(regexPattern.ToStream()))); }