@@ -223,6 +223,29 @@ func TestBindArgsReportsConversionFailures(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBindArgsRejectsNumericOverflow(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
arg string
|
||||
dst any
|
||||
}{
|
||||
{name: "int8 positive", arg: "128", dst: &struct{ Value int8 }{}},
|
||||
{name: "int8 negative", arg: "-129", dst: &struct{ Value int8 }{}},
|
||||
{name: "uint8 positive", arg: "256", dst: &struct{ Value uint8 }{}},
|
||||
{name: "uint8 negative", arg: "-1", dst: &struct{ Value uint8 }{}},
|
||||
{name: "float32", arg: "3.5e39", dst: &struct{ Value float32 }{}},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctx := &MessageContext{Args: []string{tt.arg}}
|
||||
if err := ctx.BindArgs(tt.dst); !errors.Is(err, ErrBindArgsConversion) {
|
||||
t.Fatalf("expected ErrBindArgsConversion, got %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBindArgsRejectsUnsupportedFieldTypes(t *testing.T) {
|
||||
type input struct {
|
||||
Tags []string
|
||||
|
||||
Reference in New Issue
Block a user