Skip to content

Commit

Permalink
Sort members
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jan 28, 2023
1 parent f00b91b commit c69016a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/apache/commons/csv/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ static long copyLarge(final Reader input, final Writer output, final char[] buff
return count;
}

/** No instances. */
private IOUtils() {
// Noop
}

/**
* Throws the given throwable.
*
Expand All @@ -144,4 +139,9 @@ static <T extends Throwable> RuntimeException rethrow(final Throwable throwable)
throw (T) throwable;
}

/** No instances. */
private IOUtils() {
// Noop
}

}
68 changes: 34 additions & 34 deletions src/test/java/org/apache/commons/csv/CSVDuplicateHeaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,40 @@
*/
public class CSVDuplicateHeaderTest {

/**
* Return test cases for duplicate header data for use in CSVFormat.
* <p>
* This filters the parsing test data to all cases where the allow missing column
* names flag is true and ignore header case is false: these flags are exclusively for parsing.
* CSVFormat validation applies to both parsing and writing and thus validation
* is less strict and behaves as if the allow missing column names constraint and
* the ignore header case behavior are absent.
* The filtered data is then returned with the parser flags set to both true and false
* for each test case.
* </p>
*
* @return the stream of arguments
*/
static Stream<Arguments> duplicateHeaderAllowsMissingColumnsNamesData() {
return duplicateHeaderData()
.filter(arg -> Boolean.TRUE.equals(arg.get()[1]) && Boolean.FALSE.equals(arg.get()[2]))
.flatMap(arg -> {
// Return test case with flags as all true/false combinations
final Object[][] data = new Object[4][];
final Boolean[] flags = {Boolean.TRUE, Boolean.FALSE};
int i = 0;
for (final Boolean a : flags) {
for (final Boolean b : flags) {
data[i] = arg.get().clone();
data[i][1] = a;
data[i][2] = b;
i++;
}
}
return Arrays.stream(data).map(Arguments::of);
});
}

/**
* Return test cases for duplicate header data for use in parsing (CSVParser). Uses the order:
* <pre>
Expand Down Expand Up @@ -225,40 +259,6 @@ static Stream<Arguments> duplicateHeaderData() {
);
}

/**
* Return test cases for duplicate header data for use in CSVFormat.
* <p>
* This filters the parsing test data to all cases where the allow missing column
* names flag is true and ignore header case is false: these flags are exclusively for parsing.
* CSVFormat validation applies to both parsing and writing and thus validation
* is less strict and behaves as if the allow missing column names constraint and
* the ignore header case behavior are absent.
* The filtered data is then returned with the parser flags set to both true and false
* for each test case.
* </p>
*
* @return the stream of arguments
*/
static Stream<Arguments> duplicateHeaderAllowsMissingColumnsNamesData() {
return duplicateHeaderData()
.filter(arg -> Boolean.TRUE.equals(arg.get()[1]) && Boolean.FALSE.equals(arg.get()[2]))
.flatMap(arg -> {
// Return test case with flags as all true/false combinations
final Object[][] data = new Object[4][];
final Boolean[] flags = {Boolean.TRUE, Boolean.FALSE};
int i = 0;
for (final Boolean a : flags) {
for (final Boolean b : flags) {
data[i] = arg.get().clone();
data[i][1] = a;
data[i][2] = b;
i++;
}
}
return Arrays.stream(data).map(Arguments::of);
});
}

/**
* Tests duplicate headers with the CSVFormat.
*
Expand Down

0 comments on commit c69016a

Please sign in to comment.