Skip to content

Handle negative zero and exponential numbers in Canonical JSON verification#424

Merged
S7evinK merged 5 commits intomainfrom
json-numbers
Dec 12, 2023
Merged

Handle negative zero and exponential numbers in Canonical JSON verification#424
S7evinK merged 5 commits intomainfrom
json-numbers

Conversation

@devonh
Copy link
Contributor

@devonh devonh commented Dec 8, 2023

No description provided.

@codecov
Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2aa5890) 58.99% compared to head (d5e13a2) 59.09%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #424      +/-   ##
==========================================
+ Coverage   58.99%   59.09%   +0.10%     
==========================================
  Files          51       51              
  Lines        7113     7124      +11     
==========================================
+ Hits         4196     4210      +14     
+ Misses       2528     2526       -2     
+ Partials      389      388       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@devonh
Copy link
Contributor Author

devonh commented Dec 8, 2023

There are commented out test cases for other invalid canonical json that we don't currently detect.
In the future we should detect them, but for now I have left them out in order to get these simple and clear violations fixed.

got := string(bytes)
if got != want {
t.Errorf("CompactJSON(%q):\n want: %q\n got: %q", input, want, got)
t.Errorf("CompactJSON(%q):\n want: %q\n got: %q\n bytes: % X", input, want, got, bytes)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Errorf("CompactJSON(%q):\n want: %q\n got: %q\n bytes: % X", input, want, got, bytes)
t.Errorf("CompactJSON(%q):\n want: %q\n got: %q\n bytes: %x", input, want, got, bytes)

I assume? (with the recent lower-/uppercase thing?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://pkg.go.dev/fmt

' '	(space) leave a space for elided sign in numbers (% d);
	put spaces between bytes printing strings or slices in hex (% x, % X)

So this is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants