[#5687] fixed BindBody FormData numeric string normalization

This commit is contained in:
Gani Georgiev
2024-10-16 10:20:06 +03:00
parent d43bcccb0b
commit ade061cc80
30 changed files with 85 additions and 48 deletions

View File

@@ -17,12 +17,32 @@ func TestUnmarshalRequestData(t *testing.T) {
t.Parallel()
mapData := map[string][]string{
"number1": {"1"},
"number2": {"2", "3"},
"number3": {"2.1", "-3.4"},
"string0": {""},
"string1": {"a"},
"string2": {"b", "c"},
"number1": {"1"},
"number2": {"2", "3"},
"number3": {"2.1", "-3.4"},
"number4": {"0", "-0", "0.0001"},
"string0": {""},
"string1": {"a"},
"string2": {"b", "c"},
"string3": {
"0.0",
"-0.0",
"000.1",
"000001",
"-000001",
"1.6E-35",
"10e100",
"1_000_000",
"1.000.000",
" 123 ",
"0b1",
"0xFF",
"1234A",
"Infinity",
"-Infinity",
"undefined",
"null",
},
"bool1": {"true"},
"bool2": {"true", "false"},
"mixed": {"true", "123", "test"},
@@ -308,7 +328,7 @@ func TestUnmarshalRequestData(t *testing.T) {
name: "*map[string]any",
data: mapData,
dst: pointer(map[string]any{}),
result: `{"bool1":true,"bool2":[true,false],"json_a":null,"json_b":123,"json_c":[1,2,3],"mixed":[true,123,"test"],"number1":1,"number2":[2,3],"number3":[2.1,-3.4],"string0":"","string1":"a","string2":["b","c"]}`,
result: `{"bool1":true,"bool2":[true,false],"json_a":null,"json_b":123,"json_c":[1,2,3],"mixed":[true,123,"test"],"number1":1,"number2":[2,3],"number3":[2.1,-3.4],"number4":[0,-0,0.0001],"string0":"","string1":"a","string2":["b","c"],"string3":["0.0","-0.0","000.1","000001","-000001","1.6E-35","10e100","1_000_000","1.000.000"," 123 ","0b1","0xFF","1234A","Infinity","-Infinity","undefined","null"]}`,
},
{
name: "valid pointer struct (all fields)",