Fix large number decoding for unsigned types in JSON #338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that after merging the fix for large numbers (#334), the build was broken on the
master
branch due to a linter complaint.Problem is that the
uintDecoder
is no longer a code duplication ofintDecoder
, because the adjustments by #334 only changedintDecoder
. It’s not the linter directive that’s obsolete, but I rather think thatuintDecoder
must have that fix as well, because it suffers from the same problem.In addition to the actual fix, I slightly adjusted the tests:
int
anduint
are now covered. I think it makes sense to have them together in one single test, since they are so closely related. I enclosed each one in a block, so that they have their own scope.floatDecoder
.n
in the test, I think it’s more robust to inline the number. That way, we don’t rely on howfmt.Sprintf
would serialise the number within the test.n := 100000
would infer the type toint
, butint
is platform-dependent. It’s safer to assign the type explicitly (e.g.int64
), to make the test deterministic.One note aside: the tests don’t seem to be run on PRs. Maybe that could be fixed, which would uncover build failures before they go into the
master
branch.