public static void GenerateMembers_WithWhiteSpaceAndDigitsForAsciiEncoding_ExecutesRoundTrip() { const int seed = 123; const string regex = @"^\s{3}\d{4} -\s+\d{3}$"; var engine = new RexEngine(Encoding.ASCII, seed); var result = engine.GenerateMembers(regex, 1).Single(); var matches = Regex.IsMatch(result, regex); Assert.That(matches, Is.True, $"Generated result '{ result }' does not match regular expression '{ regex }'"); }
public static void GenerateMembers_WithDigitsForUnicodeEncoding_ExecutesRoundTrip() { const int seed = 123; const string regex = @"^\d\d\d - \d\d\d\d$"; var engine = new RexEngine(Encoding.Unicode, seed); var result = engine.GenerateMembers(regex, 1).Single(); var matches = Regex.IsMatch(result, regex); Assert.That(matches, Is.True, $"Generated result '{ result }' does not match regular expression '{ regex }'"); }
protected override void BeforeGenerateValues(Project project, Column column, int count, int nullCount) { CharacterEncoding encoding = Encoding; if (!IsUnicode(column)) { encoding = CharacterEncoding.ASCII; } _engine = new RexEngine(encoding, -1); _generator = _engine.GenerateMembers(RegexOptions, count, RegexPattern).GetEnumerator(); }
protected override void BeforeGenerateValues(Project project, Column column, int count, int nullCount) { CharacterEncoding encoding = Encoding; if (!IsUnicode(column)) { encoding = CharacterEncoding.ASCII; } _engine = new RexEngine(encoding, -1); _generator = _engine.GenerateMembers(RegexOptions, count, RegexPattern).GetEnumerator(); }
public static void GenerateMembers_WithWhiteSpaceAndDigitsForAsciiEncodingWithLargeSuite_ExecutesRoundTrip() { const int seed = 123; const string regex = @"^\s{3}\d{4} -\s+\d{3}$"; const int suiteSize = 100; var engine = new RexEngine(Encoding.ASCII, seed); var results = engine.GenerateMembers(regex, suiteSize); Assert.Multiple(() => { foreach (var result in results) { var matches = Regex.IsMatch(result, regex); Assert.That(matches, Is.True, $"Generated result '{ result }' does not match regular expression '{ regex }'"); } }); }
public void TestRegexCompile() { Regex[] regexes = Array.ConvertAll(File.ReadAllLines(regexesFile), x => new Regex(x)); for (int i = 0; i < regexes.Length && i < 50; i++) { var regex = regexes[i]; var rex = new RexEngine(BitWidth.BV16); var aut = rex.CreateFromRegexes(regex.ToString()); var comp = regex.Compile(100000); if (comp == null) { continue; } foreach (var s in rex.GenerateMembers(aut, 10)) { Assert.IsTrue(regex.IsMatch(s)); Assert.IsTrue(comp.IsMatch(s)); } } }