Skip to content

Commit

Permalink
Minor test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 24, 2023
1 parent aa5c887 commit 1928b07
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public enum ParserVariant
true,
false,
true
);
)
;

ParserVariant(
ParserGenerator parserGenerator,
Expand Down Expand Up @@ -105,15 +106,15 @@ public JsonParser createParser(String input) throws Exception
),
new InvalidJson(
"Comma after key in object property",
"{\"invalid\", \"json\"}",
a2q("{'invalid', 'json'}"),
10,
10,
1,
11
),
new InvalidJson(
"Missing comma between object properties",
"{\"key1\":\"value1\" \"key2\":\"value2\"}",
a2q("{'key1':'value1' 'key2':'value2'}"),
17,
17,
1,
Expand Down Expand Up @@ -269,18 +270,22 @@ public void testParserBackendWithInvalidJson(ParserVariant variant, InvalidJson

JsonLocation location = e.getLocation();
assertEquals(invalidJson.lineNr, location.getLineNr());
final String msg = e.getOriginalMessage();

if (variant.supportsByteOffset)
{
assertEquals("Incorrect byte offset", invalidJson.byteOffset, location.getByteOffset());
assertEquals("Incorrect byte offset (for '"+msg+"')",
invalidJson.byteOffset, location.getByteOffset());
}
if (variant.supportsCharOffset)
{
assertEquals("Incorrect char offset",invalidJson.charOffset, location.getCharOffset());
assertEquals("Incorrect char offset (for '"+msg+"')",
invalidJson.charOffset, location.getCharOffset());
}
if (variant.supportsColumnNr)
{
assertEquals("Incorrect column", invalidJson.columnNr, location.getColumnNr());
assertEquals("Incorrect column (for '"+msg+"')",
invalidJson.columnNr, location.getColumnNr());
}
}
}
Expand Down

0 comments on commit 1928b07

Please sign in to comment.