mirror of
https://github.com/syumai/workers.git
synced 2025-03-11 01:39:11 +00:00
45 lines
701 B
Go
45 lines
701 B
Go
![]() |
package d1
|
||
|
|
||
|
import (
|
||
|
"math"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func Test_isIntegralNumber(t *testing.T) {
|
||
|
tests := map[string]struct {
|
||
|
f float64
|
||
|
want bool
|
||
|
}{
|
||
|
"valid integral value": {
|
||
|
f: 1,
|
||
|
want: true,
|
||
|
},
|
||
|
"invalid float value": {
|
||
|
f: 1.1,
|
||
|
want: false,
|
||
|
},
|
||
|
"invalid NaN": {
|
||
|
f: math.NaN(),
|
||
|
want: false,
|
||
|
},
|
||
|
"invalid +Inf": {
|
||
|
f: math.Inf(+1),
|
||
|
want: false,
|
||
|
},
|
||
|
"invalid -Inf": {
|
||
|
f: math.Inf(-1),
|
||
|
want: false,
|
||
|
},
|
||
|
}
|
||
|
for name, tc := range tests {
|
||
|
name := name
|
||
|
tc := tc
|
||
|
t.Run(name, func(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
if got := isIntegralNumber(tc.f); got != tc.want {
|
||
|
t.Errorf("isIntegralNumber() = %v, want %v", got, tc.want)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|