-
Notifications
You must be signed in to change notification settings - Fork 111
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
Adds support for reading binary Ion 1.1 decimals. #653
Conversation
/** | ||
* Reads into a BigDecimal the decimal value that begins at `peekIndex` and ends at `valueMarker.endIndex`. | ||
* @return the value. | ||
*/ | ||
private BigDecimal readBigDecimal_1_1() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need this, given that Decimal
extends BigDecimal
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for performance reasons. See the comment in readDecimal_1_1()
.
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a few test cases for reading numbers that are encoded with a longer-than-necessary length or using the variable length op code for a small number? E.g.
14, 64 01 0E 00 00
14, F6 05 01 0E
0., F6 03 01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next test covers the latter two. I can add some overpadded examples too.
" 3.141592653589793238462643383, F6 1B CB B7 3C 92 86 40 9F 1B 01 1F AA 26 0A", | ||
" 3.14159265358979323846264338327950, F6 1F C1 8E 29 E5 E3 56 D5 DF C5 10 8F 55 3F 7D 0F", | ||
}) | ||
public void readDecimalValue(@ConvertWith(TestUtils.StringToDecimal.class) Decimal expectedValue, String inputBytes) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test has only variable-length encoding cases. Did the test names get swapped by mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
92365d7
to
d749378
Compare
Description of changes:
Read Ion 1.1 decimals as BigDecimal or Decimal. Only the latter supports negative zero. The changes to IonTypeID are to comply with amazon-ion/ion-docs#286.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.