Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-capturing groups #707

Merged
merged 1 commit into from Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/test/java/net/datafaker/providers/base/AppTest.java
Expand Up @@ -14,12 +14,12 @@ class AppTest extends BaseFakerTest<BaseFaker> {

@Test
void testVersion() {
assertThat(app.version()).matches("\\d\\.(\\d){1,2}(\\.\\d)?");
assertThat(app.version()).matches("\\d\\.(?:\\d){1,2}(?:\\.\\d)?");
}

@Test
void testAuthor() {
assertThat(app.author()).matches("([\\w']+[-&,.]? ?){2,9}");
assertThat(app.author()).matches("(?:[\\w']+[-&,.]? ?){2,9}");
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/net/datafaker/providers/base/HackerTest.java
Expand Up @@ -9,9 +9,9 @@ class HackerTest extends BaseFakerTest<BaseFaker> {
protected Collection<TestSpec> providerListTest() {
Hacker hacker = faker.hacker();
return List.of(TestSpec.of(hacker::abbreviation, "hacker.abbreviation", "[A-Z]{2,4}"),
TestSpec.of(hacker::adjective, "hacker.adjective", "(:?\\w+[- ]?){1,2}"),
TestSpec.of(hacker::adjective, "hacker.adjective", "(?:\\w+[- ]?){1,2}"),
TestSpec.of(hacker::noun, "hacker.noun"),
TestSpec.of(hacker::verb, "hacker.verb"),
TestSpec.of(hacker::ingverb, "hacker.ingverb", "\\w+ing(:? \\w+)?"));
TestSpec.of(hacker::ingverb, "hacker.ingverb", "\\w+ing(?: \\w+)?"));
}
}
2 changes: 1 addition & 1 deletion src/test/java/net/datafaker/providers/base/JobTest.java
Expand Up @@ -11,6 +11,6 @@ protected Collection<TestSpec> providerListTest() {
return List.of(TestSpec.of(job::field, "job.field"),
TestSpec.of(job::seniority, "job.seniority"),
TestSpec.of(job::position, "job.position"),
TestSpec.of(job::keySkills, "job.key_skills", "(:?[A-Za-z-]+ ?){1,3}"));
TestSpec.of(job::keySkills, "job.key_skills", "(?:[A-Za-z-]+ ?){1,3}"));
}
}
Expand Up @@ -6,7 +6,7 @@

class SlackEmojiTest extends BaseFakerTest<BaseFaker> {

private static final String EMOTICON_REGEX = ":(:?[\\w-]+):";
private static final String EMOTICON_REGEX = ":(?:[\\w-]+):";
private final SlackEmoji slackEmoji = faker.slackEmoji();

@Test
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/net/datafaker/providers/base/SpaceTest.java
Expand Up @@ -9,7 +9,7 @@

class SpaceTest extends BaseFakerTest<BaseFaker> {

private static final String SPACE_REGEX = "(\\w+ ?){2,3}";
private static final String SPACE_REGEX = "(?:\\w+ ?){2,3}";

@Override
protected Collection<TestSpec> providerListTest() {
Expand All @@ -18,18 +18,18 @@ protected Collection<TestSpec> providerListTest() {
TestSpec.of(space::moon, "space.moon", SPACE_REGEX),
TestSpec.of(space::galaxy, "space.galaxy", SPACE_REGEX),
TestSpec.of(space::nebula, "space.nebula", SPACE_REGEX),
TestSpec.of(space::starCluster, "space.star_cluster", "(:?\\w+[ -]?){1,3}"),
TestSpec.of(space::starCluster, "space.star_cluster", "(?:\\w+[ -]?){1,3}"),
TestSpec.of(space::constellation, "space.constellation", SPACE_REGEX),
TestSpec.of(space::star, "space.star", "(\\w+[ -]?){2,3}"),
TestSpec.of(space::agency, "space.agency", "(:?\\w+ ?){2,5}"),
TestSpec.of(space::agency, "space.agency", "(?:\\w+ ?){2,5}"),
TestSpec.of(space::agencyAbbreviation, "space.agency_abv", SPACE_REGEX),
TestSpec.of(space::nasaSpaceCraft, "space.nasa_space_craft", SPACE_REGEX),
TestSpec.of(space::company, "space.company", "(:?(:?\\w|')+ ?){2,4}"),
TestSpec.of(space::meteorite, "space.meteorite", "(?U)(:?[\\w()]+[ -–]?){1,4}"));
TestSpec.of(space::company, "space.company", "(?:(?:\\w|')+ ?){2,4}"),
TestSpec.of(space::meteorite, "space.meteorite", "(?U)(?:[\\w()]+[ -–]?){1,4}"));
}

@Test
void distanceMeasurement() {
assertThat(faker.space().distanceMeasurement()).matches("(:?\\w+ ?){2,3}");
assertThat(faker.space().distanceMeasurement()).matches("(?:\\w+ ?){2,3}");
}
}
2 changes: 1 addition & 1 deletion src/test/java/net/datafaker/providers/base/TeamTest.java
Expand Up @@ -25,7 +25,7 @@ void testState() {
@Override
protected Collection<TestSpec> providerListTest() {
return List.of(TestSpec.of(team::creature, "team.creature"),
TestSpec.of(team::sport, "team.sport", "(:?\\p{L}|\\s)+"));
TestSpec.of(team::sport, "team.sport", "(?:\\p{L}|\\s)+"));
}

@Test
Expand Down