Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: simplify json examples in number tests
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed May 31, 2025
commit 2f121f2f536d1e22b1ab92c585ef2adaa01191ff
11 changes: 3 additions & 8 deletions number_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ func generateNumberTestCases(samples []any) []testCase {
_ = underflowString
_ = overflowString

var jsonEight, jsonEightNegative, jsonEightPointZero json.Number
_ = json.Unmarshal([]byte("8"), &jsonEight)
_ = json.Unmarshal([]byte("-8"), &jsonEightNegative)
_ = json.Unmarshal([]byte("8.0"), &jsonEightPointZero)

kind := reflect.TypeOf(zero).Kind()
isUint := kind == reflect.Uint || kind == reflect.Uint8 || kind == reflect.Uint16 || kind == reflect.Uint32 || kind == reflect.Uint64

Expand Down Expand Up @@ -219,9 +214,9 @@ func generateNumberTestCases(samples []any) []testCase {
{nil, zero, false},

// JSON
{jsonEight, eight, false},
{jsonEightNegative, eightNegative, isUint},
{jsonEightPointZero, eight, false},
{json.Number("8"), eight, false},
{json.Number("-8"), eightNegative, isUint},
{json.Number("8.0"), eight, false},

// Failure cases
{"test", zero, true},
Expand Down