-
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 nulls, booleans, ints, and floats. #641
Conversation
" -2147483648, 54 00 00 00 80", // Integer.MIN_VALUE | ||
" -72624976668147841, 58 7F BF DF EF F7 FB FD FE", | ||
" -9223372036854775808, 58 00 00 00 00 00 00 00 80", // Long.MIN_VALUE | ||
}) |
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.
Should there be cases for reading variable-length integers as int
and long
?
For example "1, F5 03 01"
and "1, F5 09 01 00 00 00"
and "0, F5 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.
Yes there should be, somewhere. I hadn't intended these unit test parameters to cover all edge cases, thinking that would be a better job for the ion-tests files. But I'm happy to add some more cases here for now, giving us a head start on developing a more exhaustive Ion 1.1 ion-tests corpus.
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.
" NaN, 5C 7F C0 00 00", | ||
" Infinity, 5C 7F 80 00 00", | ||
" -Infinity, 5C FF 80 00 00", |
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.
Should be able to read these as any size of float.
" NaN, 5C 7F C0 00 00", | |
" Infinity, 5C 7F 80 00 00", | |
" -Infinity, 5C FF 80 00 00", | |
" NaN, 5C 7F C0 00 00", | |
" Infinity, 5C 7F 80 00 00", | |
" -Infinity, 5C FF 80 00 00", | |
" NaN, 5D 7F C0 00 00 00 00 00 00", | |
" Infinity, 5D 7F 80 00 00 00 00 00 00", | |
" -Infinity, 5D FF 80 00 00 00 00 00 00", |
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.
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
" 0.0, 5A", |
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.
Test cases to make sure it can read 0 of any size.
" 0.0, 5A", | |
" 0.0, 5A", | |
" 0.0, 5B 00 00", | |
" 0.0, 5C 00 00 00 00", | |
" 0.0, 5D 00 00 00 00 00 00 00 00", |
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.
" 0, 50", | ||
" 1, 51 01", | ||
" 17, 51 11", | ||
" 127, 51 7F", |
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.
Numbers such as 127 can be encoded using more than one op code. We should add tests for that here (and in the other integer tests).
" 127, 51 7F", | |
" 127, 51 7F", | |
" 127, 52 7F 00", | |
" 127, 54 7F 00 00 00", | |
" 127, 58 7F 00 00 00 00 00 00 00", |
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.
…o address PR feedback.
…s more tests for numeric types.
Description of changes:
Adds support for reading binary Ion 1.1 nulls, booleans, ints, and floats.
The trickiest part of this was actually the typed nulls, since they now require looking ahead one byte rather than relying on the type being baked into the precomputed type ID. For convenience and simplicity, we solve this by replacing the reader's type ID with the Ion 1.0 typed null IonTypeID instance for the given type, once the type is determined.
Note that for float values, the only changes required were in the type ID assignments, which happened in #639.
The test parameters are once again copied from IonEncoder_1_1Test.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.