You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spring cloud version: 2.1.0.RELEASE. I added new methods to XegerTest which reproduce minimal failing test cases:
packagerepackaged.nl.flotsam.xeger;
importjava.util.ArrayList;
importjava.util.List;
importjava.util.Random;
importorg.junit.Test;
importstaticorg.junit.Assert.assertEquals;
importstaticorg.junit.Assert.assertTrue;
importstaticorg.junit.Assert.assertFalse;
publicclassXegerTest {
/** * Add general expectations for developers with different knowledge background about regex */@TestpublicvoidgeneralExpectationsAboutPipeAndCompiledFlag() {
StringregexAbc = "|abc";
assertTrue("".matches(regexAbc));
assertTrue("abc".matches(regexAbc));
// note that regex is compiled with a flag of zero. Which means that this is false:assertFalse("aabc".matches(regexAbc));
}
@TestpublicvoidshouldGenerateTextCorrectlyWithDollarSignInTheEnd() {
Stringregex = ".*$";
// baseline assumption:assertTrue("".matches(regex));
assertTrue("a".matches(regex));
Xegergenerator = newXeger(regex);
for (inti = 0; i < 100; i++) {
Stringtext = generator.generate();
assertTrue(text.matches(regex));
}
}
@TestpublicvoidshouldGenerateTextCorrectlyWithCapSignInTheBegging() {
Stringregex = "^b*";
// baseline assumption:assertTrue("".matches(regex));
assertTrue("b".matches(regex));
Xegergenerator = newXeger(regex);
for (inti = 0; i < 100; i++) {
Stringtext = generator.generate();
assertTrue(text.matches(regex));
}
}
@TestpublicvoidshouldGenerateTextCorrectlyWithPipeAndDollarSign() {
Stringregex = ".$|bca";
// baseline assumption:assertTrue("b".matches(regex));
assertTrue("bca".matches(regex));
assertFalse("".matches(regex));
assertFalse("bc".matches(regex));
Xegergenerator = newXeger(regex);
for (inti = 0; i < 100; i++) {
Stringtext = generator.generate();
assertTrue(text.matches(regex));
}
}
@TestpublicvoidshouldGenerateTextCorrectlyWithPipeAndEmptyExpression() {
Stringregex = "|bca";
// baseline assumption:assertTrue("".matches(regex));
assertTrue("bca".matches(regex));
assertFalse(" ".matches(regex));
Xegergenerator = newXeger(regex);
for (inti = 0; i < 100; i++) {
Stringtext = generator.generate();
assertTrue(text.matches(regex));
}
}
}
For me, it looks like if a developer doesn't know those details about a regex engine beihind, he or she is doomed to spend a lot of time debugging things. Please, take a closer look at Xeger.
The text was updated successfully, but these errors were encountered:
@mikhail-putilov Thanks for reporting this. We have looked at various regex engines and have not found anything better. However, I guess we should add this info to the documentation. Would you be interested in contributing a short paragraph about the possible expected vs. actual behaviours of the engine to our docs as PR?
Bug report
Spring cloud version:
2.1.0.RELEASE
. I added new methods toXegerTest
which reproduce minimal failing test cases:For me, it looks like if a developer doesn't know those details about a regex engine beihind, he or she is doomed to spend a lot of time debugging things. Please, take a closer look at
Xeger
.The text was updated successfully, but these errors were encountered: