8135091: (fs) java/nio/file/Files/StreamLinesTest.java should test empty files
Summary: In lines() add zero length case and rearrange first loop to avoid duplicate cases.
Reviewed-by: rriggs
--- a/jdk/test/java/nio/file/Files/StreamLinesTest.java Fri Sep 04 19:55:40 2015 +0000
+++ b/jdk/test/java/nio/file/Files/StreamLinesTest.java Fri Sep 04 14:16:34 2015 -0700
@@ -138,18 +138,25 @@
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));
}
}
}