|
1 | 1 | package com.fasterxml.jackson.dataformat.yaml.deser;
|
2 | 2 |
|
| 3 | +import java.io.StringWriter; |
| 4 | +import java.math.BigInteger; |
| 5 | + |
3 | 6 | import com.fasterxml.jackson.core.JsonParser;
|
4 | 7 | import com.fasterxml.jackson.core.JsonToken;
|
5 |
| -import com.fasterxml.jackson.databind.ObjectMapper; |
| 8 | + |
6 | 9 | import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
|
7 | 10 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
8 | 11 | import com.fasterxml.jackson.dataformat.yaml.YAMLParser;
|
9 | 12 |
|
10 |
| -import java.io.StringWriter; |
11 |
| -import java.math.BigInteger; |
12 |
| - |
13 | 13 | /**
|
14 | 14 | * Unit tests for checking functioning of the underlying
|
15 | 15 | * parser implementation.
|
16 | 16 | */
|
17 | 17 | public class StreamingParseTest extends ModuleTestBase
|
18 | 18 | {
|
19 |
| - final YAMLFactory YAML_F = new YAMLFactory(); |
| 19 | + private final YAMLFactory YAML_F = new YAMLFactory(); |
20 | 20 |
|
21 | 21 | public void testBasic() throws Exception
|
22 | 22 | {
|
@@ -300,16 +300,19 @@ public void testIntParsingUnderscoresSm() throws Exception
|
300 | 300 | p.close();
|
301 | 301 | }
|
302 | 302 |
|
| 303 | + // for [dataformats-text#146] |
303 | 304 | public void testYamlLongWithUnderscores() throws Exception
|
304 | 305 | {
|
305 |
| - ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); |
306 |
| - LongHolder longHolder = mapper.readValue("v: 1_000_000", LongHolder.class); |
307 |
| - assertNotNull(longHolder); |
308 |
| - assertEquals(LongHolder.class, longHolder.getClass()); |
309 |
| - assertEquals(Long.valueOf(1000000), longHolder.getV()); |
| 306 | + try (JsonParser p = YAML_F.createParser("v: 1_000_000")) { |
| 307 | + assertToken(JsonToken.START_OBJECT, p.nextToken()); |
| 308 | + assertToken(JsonToken.FIELD_NAME, p.nextToken()); |
| 309 | + assertEquals("v", p.currentName()); |
| 310 | + assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken()); |
| 311 | + assertEquals(1000000, p.getIntValue()); |
| 312 | + } |
310 | 313 | }
|
311 | 314 |
|
312 |
| - // [cbor#4]: accidental recognition as double, with multiple dots |
| 315 | + // accidental recognition as double, with multiple dots |
313 | 316 | public void testDoubleParsing() throws Exception
|
314 | 317 | {
|
315 | 318 | // First, test out valid use case.
|
@@ -581,19 +584,4 @@ public void testTimeLikeValues() throws Exception
|
581 | 584 | assertNull(p.nextToken());
|
582 | 585 | p.close();
|
583 | 586 | }
|
584 |
| - |
585 |
| - static class LongHolder |
586 |
| - { |
587 |
| - private Long v; |
588 |
| - |
589 |
| - public Long getV() |
590 |
| - { |
591 |
| - return v; |
592 |
| - } |
593 |
| - |
594 |
| - public void setV(Long v) |
595 |
| - { |
596 |
| - this.v = v; |
597 |
| - } |
598 |
| - } |
599 | 587 | }
|
0 commit comments