Skip to content

Commit

Permalink
fix typo in test name
Browse files Browse the repository at this point in the history
+ occasionally, simplify the test itself :)
  • Loading branch information
asolntsev committed Oct 31, 2024
1 parent ec609be commit 42e6105
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/test/java/net/datafaker/providers/base/LoremTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.Set;
import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -44,17 +45,17 @@ void testCharacterIncludeUpperCase() {
}

@Test
void testCharactersShouldIncludeMinAndMaxLenght() {
List<String> results = new ArrayList<>();
void testCharactersShouldIncludeMinAndMaxLength() {
Pattern RE = Pattern.compile("[a-z\\d]{1,10}");

Set<Integer> allLengths = new HashSet<>();
for (int i = 0; i < 300; i++) {
results.add(lorem.characters(1, 10));
String characters = lorem.characters(1, 10);
assertThat(characters).matches(RE);
allLengths.add(characters.length());
}

final List<String> min = results.stream().filter(x -> x.length() == 1).collect(Collectors.toList());
final List<String> max = results.stream().filter(x -> x.length() == 10).collect(Collectors.toList());

assertThat(min).isNotEmpty();
assertThat(max).isNotEmpty();
assertThat(allLengths).contains(1, 10);
}

@Test
Expand Down

0 comments on commit 42e6105

Please sign in to comment.