Skip to content

Commit

Permalink
Merge pull request #707 from kingthorin/capt-grp
Browse files Browse the repository at this point in the history
Fix non-capturing groups
  • Loading branch information
kingthorin committed Feb 12, 2023
2 parents 85e37a2 + 8e8dd0b commit f6d4c7b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
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

0 comments on commit f6d4c7b

Please sign in to comment.