Use try-with-resources

This commit is contained in:
Gary Gregory 2024-09-14 09:41:39 -04:00
parent ae79aeaa0b
commit e75b90a17e
1 changed files with 5 additions and 4 deletions

View File

@ -84,10 +84,11 @@ public class CSVRecordTest {
@Test
public void testCSVRecordNULLValues() throws IOException {
final CSVParser parser = CSVParser.parse("A,B\r\nONE,TWO", CSVFormat.DEFAULT.withHeader());
final CSVRecord csvRecord = new CSVRecord(parser, null, null, 0L, 0L);
assertEquals(0, csvRecord.size());
assertThrows(IllegalArgumentException.class, () -> csvRecord.get("B"));
try (CSVParser parser = CSVParser.parse("A,B\r\nONE,TWO", CSVFormat.DEFAULT.withHeader())) {
final CSVRecord csvRecord = new CSVRecord(parser, null, null, 0L, 0L);
assertEquals(0, csvRecord.size());
assertThrows(IllegalArgumentException.class, () -> csvRecord.get("B"));
}
}
@Test