test: Add float32 NaN/Inf tests for intFromAny and floatFromAny
Add 6 test cases covering float32 special values: - intFromAny: float32 NaN, +Inf, -Inf (all return 0, false) - floatFromAny: float32 NaN, +Inf, -Inf (all return 0, false) Coverage improved: - intFromAny: 96.7% -> 100% - floatFromAny: 95.0% -> 100%
This commit is contained in:
parent
0b0d43c638
commit
84f224cc03
1 changed files with 6 additions and 0 deletions
|
|
@ -95,6 +95,9 @@ func TestIntFromAny(t *testing.T) {
|
|||
{"float32 integer", float32(42.0), 42, true},
|
||||
{"float32 round down", float32(42.4), 42, true},
|
||||
{"float32 round up", float32(42.6), 43, true},
|
||||
{"float32 NaN", float32(math.NaN()), 0, false},
|
||||
{"float32 +Inf", float32(math.Inf(1)), 0, false},
|
||||
{"float32 -Inf", float32(math.Inf(-1)), 0, false},
|
||||
{"float64 integer", float64(42.0), 42, true},
|
||||
{"float64 round half", float64(42.5), 43, true},
|
||||
{"float64 NaN", math.NaN(), 0, false},
|
||||
|
|
@ -219,6 +222,9 @@ func TestFloatFromAny(t *testing.T) {
|
|||
{"float64 +Inf", math.Inf(1), 0, false},
|
||||
{"float64 -Inf", math.Inf(-1), 0, false},
|
||||
{"float32", float32(3.14), float64(float32(3.14)), true},
|
||||
{"float32 NaN", float32(math.NaN()), 0, false},
|
||||
{"float32 +Inf", float32(math.Inf(1)), 0, false},
|
||||
{"float32 -Inf", float32(math.Inf(-1)), 0, false},
|
||||
|
||||
// int types
|
||||
{"int", int(42), 42, true},
|
||||
|
|
|
|||
Loading…
Reference in a new issue