4 ms·
I just tested it using Pex for fun and - to my surprise - Pex was able to deal with regular expression and this AFAIK without any build-in knowledge of regular
by danbruc 14y ago
I just tested it using Pex for fun and - to my surprise - Pex was able to deal with regular expression and this AFAIK without any build-in knowledge of regular expressions.
using System;
using System.Text.RegularExpressions;
public class Program
{
public static String Puzzle(String input)
{
if (new Regex("123(foo|bar){3}456[0-9]{5}789").IsMatch(input))
{
throw new ArgumentException();
}
else
{
return input;
}
}
}
Pex reported three test cases.
null ArgumentNullException
"" okay
"123foobarbar45600000789bb" ArgumentException
Try this example yourself.
http://www.pexforfun.com/default.aspx?language=CSharp&code=HgHsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee__997o7nU4n99%2f%2fP1xmZAFs9s5K2smeIYCqyB8%2ffnwfPyLWTbG8SF9fN22_OEz8v8Zv8nft_FV_sS6z_vTdqs6bpqiWzWGSrNaTspim0zJrmvRlXV3U2SL5xUma6hdNm7X043VbA9zL9Q9_UOZb_lexXK3bO9QW7dO0OE_3lvlVSv3k77Y_2t27t3VeVT8zyeo7v%2fjeL9m%2f%2f_n3drYffv8X3%2f8lDw4efnRnfNZ8kbXT_ZZAucMgBFCatvO6ukoB7Li_WC%2fyZXv6bpqvWkJ6684hN%2fol%2fG9eNnnwZp2363opqLmGvyT5Jf9PAAAA%2f%2f8%3d http://www.pexforfun.com/default.aspx?language=CSharp&co...
UPDATE: I was wrong - Rex was integrated into Pex in 2010 and this made Pex much smarter when it has to deal with regular expressions.