Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IonParser.getNumberType() returns null for IonType.FLOAT #142

Merged
merged 1 commit into from
Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}