Skip to content

Commit

Permalink
Merge pull request #142 from mmilkin/float-number-type
Browse files Browse the repository at this point in the history
TokenBuffer.copyCurrentEvent does not expect getNumberType return null.
  • Loading branch information
cowtowncoder authored Sep 5, 2018
2 parents 1bf2140 + a98159f commit 4fea433
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ public NumberType getNumberType() throws IOException
} else {
return NumberType.INT;
}
case FLOAT:
return NumberType.DOUBLE;
default:
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
*/

package com.fasterxml.jackson.dataformat.ion;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.ObjectReadContext;
import com.fasterxml.jackson.dataformat.ion.IonFactory;
import com.fasterxml.jackson.dataformat.ion.IonParser;

import org.junit.Assert;
import software.amazon.ion.IonReader;
import software.amazon.ion.IonSystem;
import software.amazon.ion.IonValue;
import software.amazon.ion.system.IonSystemBuilder;

import java.io.IOException;
import java.math.BigInteger;
import org.junit.Test;

Expand Down Expand Up @@ -58,4 +58,23 @@ public void testGetNumberType() throws Exception {
Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, floatParser.nextToken());
Assert.assertEquals(JsonParser.NumberType.DOUBLE, floatParser.getNumberType());
}

@Test
public void testFloatType() throws IOException
{
final ObjectReadContext ctxt = ObjectReadContext.empty();

final byte[] data = "{ score:0.291e0 }".getBytes();
IonSystem ion = IonSystemBuilder.standard().build();
final IonValue ionFloat = ion.newFloat(Float.MAX_VALUE);
IonReader reader = ionFloat.getSystem().newReader(data, 0, data.length);
// Find the object
reader.next();
// Step into the object
reader.stepIn();
// Step next.
reader.next();
final IonParser floatParser = new IonFactory().createParser(ctxt, reader);
Assert.assertEquals(JsonParser.NumberType.DOUBLE, floatParser.getNumberType());
}
}

0 comments on commit 4fea433

Please sign in to comment.