public void Generate_65000To66000With66001_Fail() { // Assemble int min = 65000; int max = 66000; string testString = "some text 66001 to test"; // Act string regexPattern = RangeGenerator.Generate(min, max); // Assert Regex regex = new Regex(regexPattern); Assert.IsFalse(regex.IsMatch(testString)); }
public void Generate_777To888With899_Fail() { // Assemble int min = 777; int max = 888; string testString = "some text 899 to test"; // Act string regexPattern = RangeGenerator.Generate(min, max); // Assert Regex regex = new Regex(regexPattern); Assert.IsFalse(regex.IsMatch(testString)); }
public void AdhocTest() { // Assemble int min = 3493; int max = 5765; string testString = "some text 3555 to test"; // Act string regexPattern = RangeGenerator.Generate(min, max); // Assert Regex regex = new Regex(regexPattern); Assert.IsTrue(regex.IsMatch(testString)); }
public void Generate_1To100With99_Pass() { // Assemble int min = 1; int max = 100; string testString = "some text 99 to test"; // Act string regexPattern = RangeGenerator.Generate(min, max); // Assert Regex regex = new Regex(regexPattern); Assert.IsTrue(regex.IsMatch(testString)); }
public void Generate_Random_Pass() { // Assemble for (int i = 0; i < 1000; i++) { int absoluteMax = 10000; int min = new Random().Next(1, absoluteMax); int max = new Random().Next(min, absoluteMax); int testNumber = new Random().Next(min, max); string testString = $"some text {testNumber} to test"; // Act string regexPattern = RangeGenerator.Generate(min, max); // Assert Regex regex = new Regex(regexPattern); if (!regex.IsMatch(testString)) { throw new Exception(); } } }
public override eeObject VisitRangeExp([NotNull] EelooParser.RangeExpContext ctx) { // add this to scope Interpreter.currentScope.scopeCtx = ctx; EelooParser.ExpContext[] exps = ctx.exp(); eeObject exp1 = Visit(exps[0]), exp2 = Visit(exps[1]); if (exp1.AsNumber() == null || exp2.AsNumber() == null) { throw new Exception("TO DO"); } eeNumber start = exp1.AsNumber(), stop = exp2.AsNumber(); ICollection <eeObject> rangeObj; if (exps.Length == 2) // only two numbers provided, assume step is 1 { rangeObj = RangeGenerator.Generate(start, stop, eeNumber.ONE); } else { rangeObj = RangeGenerator.Generate(start, stop, Visit(exps[2]).AsNumber()); } eeObject exprList = new eeObject(rangeObj) { type = eeObjectType.internal_EXPRLIST }; return(eeObject.newListObject(exprList)); }