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:
Brian Burkhalter 2015-09-04 14:16:34 -07:00
parent 2f2b4c27ee
commit 005143e035

View File

@ -138,18 +138,25 @@ public class StreamLinesTest extends OpTestCase {
StandardCharsets.ISO_8859_1,
StandardCharsets.UTF_16);
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 (String line : lines) {
for (int linesSize : linesSizes) {
for (LineSeparator ls : EnumSet.complementOf(EnumSet.of(LineSeparator.NONE))) {
String description = String.format("%d lines of \"%s\" with separator %s", linesSize, line, ls);
l.add(of(description,
i -> line,
i -> ls,
linesSize, charset));
for (int linesSize : linesSizes) {
if (linesSize > 0) {
for (String line : lines) {
for (LineSeparator ls : EnumSet.complementOf(EnumSet.of(LineSeparator.NONE))) {
String description = String.format("%d lines of \"%s\" with separator %s", linesSize, line, ls);
l.add(of(description,
i -> line,
i -> ls,
linesSize, charset));
}
}
} else {
l.add(of("Empty file: 0 lines",
i -> "",
i -> LineSeparator.NONE,
0, charset));
}
}
}