Skip to content

Commit

Permalink
Add test for trailing junk
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Haraldsen committed Jan 28, 2024
1 parent 2618dec commit 3b229c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/test/java/com/ethlo/time/ExternalParameterizedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

import java.io.IOException;
import java.time.DateTimeException;
Expand Down Expand Up @@ -70,6 +71,11 @@ void testAll(TestParam param)
result = ITU.parseDateTime(param.getInput());
}

if (param.getError() != null)
{
fail("Expected error '%s' when parsing '%s'", param.getError(), param.getInput());
}

// Compare to Java's parser result
final Instant expected = getExpected(param);
if (result instanceof DateTime)
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/test-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@
"error": "Trailing junk data after position 25: 2017-02-21T15:00:00.123ZGGG",
"error_index": 24
},
{
"input": "2020-12-31T00:00:00-05:00 x",
"error": "Trailing junk data after position 27: 2020-12-31T00:00:00-05:00 x",
"lenient": true
},
{
"input": "2020-12-31T22:22:2",
"error": "Unexpected end of input: 2020-12-31T22:22:2",
Expand Down

0 comments on commit 3b229c9

Please sign in to comment.