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:
parent
0527f151a6
commit
0b0d43c638
1 changed files with 36 additions and 0 deletions
|
|
@ -603,6 +603,42 @@ func TestCoerceUint64(t *testing.T) {
|
||||||
value: "not a number",
|
value: "not a number",
|
||||||
wantErr: true,
|
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
|
// unsupported type
|
||||||
{
|
{
|
||||||
name: "unsupported type bool",
|
name: "unsupported type bool",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue