mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-21 02:33:32 +00:00
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:
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user