Skip to content

Commit

Permalink
Add test for parsing long with underscores for yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
conor-ward authored and cowtowncoder committed Jun 25, 2020
1 parent 3f2dd65 commit 2cf9d0a
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLParser;
Expand Down Expand Up @@ -299,6 +300,15 @@ public void testIntParsingUnderscoresSm() throws Exception
p.close();
}

public void testYamlLongWithUnderscores() throws Exception
{
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
LongHolder longHolder = mapper.readValue("v: 1_000_000", LongHolder.class);
assertNotNull(longHolder);
assertEquals(LongHolder.class, longHolder.getClass());
assertEquals(Long.valueOf(1000000), longHolder.getV());
}

// [cbor#4]: accidental recognition as double, with multiple dots
public void testDoubleParsing() throws Exception
{
Expand Down Expand Up @@ -571,4 +581,19 @@ public void testTimeLikeValues() throws Exception
assertNull(p.nextToken());
p.close();
}

static class LongHolder
{
private Long v;

public Long getV()
{
return v;
}

public void setV(Long v)
{
this.v = v;
}
}
}

0 comments on commit 2cf9d0a

Please sign in to comment.