Skip to content

Commit

Permalink
Add test wrt parser.getValueAsString() implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 4, 2025
1 parent ec36d96 commit dfe6870
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,13 @@ public void testColumnReordering() throws IOException {
assertEquals(JsonToken.START_OBJECT, parser.nextToken());
assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
assertEquals("b", parser.currentName());
assertEquals("b", parser.getText());
assertEquals("b", parser.getValueAsString());
assertEquals("b", parser.getValueAsString("x"));
assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
assertEquals("vb", parser.getValueAsString());
assertEquals("vb", parser.getValueAsString());
assertEquals("vb", parser.getValueAsString("x"));
assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
assertEquals("a",parser.currentName());
assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public void testParsing() throws Exception
assertNotNull(p.currentLocation()); // N/A
assertNotNull(p.currentTokenLocation()); // N/A
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("foo", p.currentName());
assertEquals("foo", p.getText());
assertEquals("foo", p.getValueAsString());
assertEquals("foo", p.getValueAsString("x"));
assertToken(JsonToken.VALUE_STRING, p.nextToken());
StringWriter sw = new StringWriter();
assertEquals(3, p.getText(sw));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;

import com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException;
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
import com.fasterxml.jackson.dataformat.yaml.YAMLAnchorReplayingFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLAnchorReplayingParser;
import org.yaml.snakeyaml.LoaderOptions;

public class StreamingYAMLAnchorReplayingParseTest extends ModuleTestBase {

public class StreamingYAMLAnchorReplayingParseTest extends ModuleTestBase
{
private final YAMLAnchorReplayingFactory YAML_F = new YAMLAnchorReplayingFactory();

public void testBasic() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ public void testBasic() throws Exception
assertToken(JsonToken.START_OBJECT, p.nextToken());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("string", p.currentName());
assertEquals("string", p.getText());
assertEquals("string", p.getValueAsString());
assertEquals("string", p.getValueAsString("x"));
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("text", p.getText());
assertEquals("text", p.getValueAsString());
assertEquals("text", p.getValueAsString("x"));
JsonLocation loc = p.currentTokenLocation();
assertEquals(1, loc.getLineNr());
assertEquals(9, loc.getColumnNr());
Expand Down

0 comments on commit dfe6870

Please sign in to comment.