Skip to content

Commit

Permalink
Added additional tests to csv parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikollai committed May 18, 2026
1 parent 25088a1 commit 81a8164
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/test/java/millions/CSVStockFileParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,21 @@ public void NumberConversionExceptionTest() {
}

@Test
public void EmptyFieldExceptionTest() {
exampleString += ",,1";
public void EmptySymbolFieldExceptionTest() {
exampleString += ",test,1";
List<String> testList = List.of(exampleString.split("\n"));
Exception e = assertThrows(InvalidFormatException.class, () -> {parser.parse(testList);});
String expectedMessage = "Illegal argument on line: ,,1\n" +
String expectedMessage = "Illegal argument on line: ,test,1\n" +
"Symbol cannot be null or blank";
assertEquals(expectedMessage, e.getMessage());
}
@Test
public void EmptyCompanyNameFieldExceptionTest() {
exampleString += "test,,1";
List<String> testList = List.of(exampleString.split("\n"));
Exception e = assertThrows(InvalidFormatException.class, () -> {parser.parse(testList);});
String expectedMessage = "Illegal argument on line: test,,1\n" +
"Company cannot be null or blank";
assertEquals(expectedMessage, e.getMessage());
}
}

0 comments on commit 81a8164

Please sign in to comment.