test: Add edge case tests for coerceUint64 function

Add 6 new test cases covering previously untested branches:
- float64 at MaxUint64 boundary (clamping behavior)
- float64 exceeding MaxUint64 (overflow protection)
- String with quoted "null" value
- String with quoted empty value ("")
- String with single quoted empty value ('')
- Invalid float parsing in scientific notation

Coverage improved from 92.3% to 97.4%.
This commit is contained in:
rcourtman 2025-12-01 22:36:03 +00:00
parent 05b9c3ab2d
commit 1e9fbdfdcc

View file

@ -603,6 +603,42 @@ func TestCoerceUint64(t *testing.T) {
value: "not a number",
wantErr: true,
},
{
name: "string invalid float in scientific notation",
field: "test",
value: "1.2.3e4",
wantErr: true,
},
{
name: "string quoted null",
field: "test",
value: `"null"`,
want: 0,
},
{
name: "string quoted empty",
field: "test",
value: `""`,
want: 0,
},
{
name: "string single quoted empty",
field: "test",
value: `''`,
want: 0,
},
{
name: "float64 at MaxUint64 boundary",
field: "test",
value: float64(math.MaxUint64),
want: math.MaxUint64,
},
{
name: "float64 exceeding MaxUint64",
field: "test",
value: float64(math.MaxUint64) * 2,
want: math.MaxUint64,
},
// unsupported type
{
name: "unsupported type bool",