Skip to content

Commit

Permalink
More test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 26, 2022
1 parent b50ac1f commit 6e06b38
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ protected void assertToken(JsonToken expToken, JsonParser p)
assertToken(expToken, p.getCurrentToken());
}

protected void assertNameToken(JsonToken actToken)
{
assertToken(JsonToken.FIELD_NAME, actToken);
}

protected void assertType(Object ob, Class<?> expType)
{
if (ob == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ public void _testNullHandling(int minNulls) throws Exception
try (JsonParser p = MAPPER.createParser(DOC)) {
assertToken(JsonToken.START_OBJECT, p.nextToken());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD1, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("a", p.getText());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD2, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("b", p.getText());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD3, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("c", p.getText());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD4, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("d", p.getText());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD5, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("e", p.getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ protected void assertToken(JsonToken expToken, JsonParser p)
assertToken(expToken, p.getCurrentToken());
}

protected void assertNameToken(JsonToken actToken)
{
assertToken(JsonToken.FIELD_NAME, actToken);
}

protected void assertType(Object ob, Class<?> expType)
{
if (ob == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ public void _testNullHandling(int minNulls) throws Exception
try (JsonParser p = MAPPER.createParser(DOC)) {
assertToken(JsonToken.START_OBJECT, p.nextToken());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD1, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("a", p.getText());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD2, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("b", p.getText());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD3, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("c", p.getText());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD4, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("d", p.getText());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertNameToken(p.nextToken());
_assertNullStrings(FIELD5, p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("e", p.getText());
Expand Down

0 comments on commit 6e06b38

Please sign in to comment.