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:
rcourtman 2025-12-01 22:40:08 +00:00
parent 0b0d43c638
commit 84f224cc03

View file

@ -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},