Skip to content

Commit

Permalink
knownvalue: add whole number (integer) test
Browse files Browse the repository at this point in the history
  • Loading branch information
bschaatsbergen committed Jan 20, 2025
1 parent eb27aaf commit cd4d9e3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion knownvalue/number_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestNumberFunc_CheckValue(t *testing.T) {
other: json.Number("1.667114241575161769818551140818851511176942075"),
expectedError: fmt.Errorf("1.667114241575161769818551140818851511176942075 was not 1.797693134862315797693134862315797693134862315"),
},
"success": {
"success-precise-number": {
self: knownvalue.NumberFunc(func(i *big.Float) error {
if i.Cmp(expected) != 0 {
return fmt.Errorf("%s was not %s", i.Text('f', -1), expected.Text('f', -1))
Expand All @@ -60,6 +60,15 @@ func TestNumberFunc_CheckValue(t *testing.T) {
}),
other: json.Number("1.797693134862315797693134862315797693134862315"),
},
"success-whole-number": {
self: knownvalue.NumberFunc(func(i *big.Float) error {
if i.Cmp(big.NewFloat(1)) != 0 {
return fmt.Errorf("%s was not %s", i.Text('f', -1), big.NewFloat(1).Text('f', -1))
}
return nil
}),
other: json.Number("1"),
},
}

for name, testCase := range testCases {
Expand Down

0 comments on commit cd4d9e3

Please sign in to comment.