8135091: (fs) java/nio/file/Files/StreamLinesTest.java should test empty files
In lines() add zero length case and rearrange first loop to avoid duplicate cases. Reviewed-by: rriggs
This commit is contained in:
parent
2f2b4c27ee
commit
005143e035
@ -138,18 +138,25 @@ public class StreamLinesTest extends OpTestCase {
|
|||||||
StandardCharsets.ISO_8859_1,
|
StandardCharsets.ISO_8859_1,
|
||||||
StandardCharsets.UTF_16);
|
StandardCharsets.UTF_16);
|
||||||
String[] lines = {"", "A", "AB", "ABC", "ABCD"};
|
String[] lines = {"", "A", "AB", "ABC", "ABCD"};
|
||||||
int[] linesSizes = {1, 2, 3, 4, 16, 256, 1024};
|
int[] linesSizes = {0, 1, 2, 3, 4, 16, 256, 1024};
|
||||||
|
|
||||||
for (Charset charset : charsets) {
|
for (Charset charset : charsets) {
|
||||||
for (String line : lines) {
|
for (int linesSize : linesSizes) {
|
||||||
for (int linesSize : linesSizes) {
|
if (linesSize > 0) {
|
||||||
for (LineSeparator ls : EnumSet.complementOf(EnumSet.of(LineSeparator.NONE))) {
|
for (String line : lines) {
|
||||||
String description = String.format("%d lines of \"%s\" with separator %s", linesSize, line, ls);
|
for (LineSeparator ls : EnumSet.complementOf(EnumSet.of(LineSeparator.NONE))) {
|
||||||
l.add(of(description,
|
String description = String.format("%d lines of \"%s\" with separator %s", linesSize, line, ls);
|
||||||
i -> line,
|
l.add(of(description,
|
||||||
i -> ls,
|
i -> line,
|
||||||
linesSize, charset));
|
i -> ls,
|
||||||
|
linesSize, charset));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
l.add(of("Empty file: 0 lines",
|
||||||
|
i -> "",
|
||||||
|
i -> LineSeparator.NONE,
|
||||||
|
0, charset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user