@@ -2217,42 +2217,27 @@ func TestRequiredFieldsCannotHaveDefaults(t *testing.T) {
2217
2217
2218
2218
func TestInvalidDefaultElementInSliceRaiseError (t * testing.T ) {
2219
2219
type D struct {
2220
- A []int `schema:"a,default:0|notInt"`
2221
- B []bool `schema:"b,default:true|notInt"`
2222
- C []* float32 `schema:"c,default:1.1|notInt"`
2220
+ A []int `schema:"a,default:0|notInt"`
2221
+ B []bool `schema:"b,default:true|notInt"`
2223
2222
// //uint types
2224
2223
D []uint `schema:"d,default:1|notInt"`
2225
2224
E []uint8 `schema:"e,default:2|notInt"`
2226
2225
F []uint16 `schema:"f,default:3|notInt"`
2227
2226
G []uint32 `schema:"g,default:4|notInt"`
2228
2227
H []uint64 `schema:"h,default:5|notInt"`
2229
- // // uint types pointers
2230
- I []* uint `schema:"i,default:6|notInt"`
2231
- J []* uint8 `schema:"j,default:7|notInt"`
2232
- K []* uint16 `schema:"k,default:12|notInt"`
2233
- L []* uint32 `schema:"l,default:129|notInt"`
2234
- M []* uint64 `schema:"m,default:11111|notInt"`
2235
2228
// // int types
2236
2229
N []int `schema:"n,default:11|notInt"`
2237
2230
O []int8 `schema:"o,default:12|notInt"`
2238
2231
P []int16 `schema:"p,default:13|notInt"`
2239
2232
Q []int32 `schema:"q,default:14|notInt"`
2240
2233
R []int64 `schema:"r,default:15|notInt"`
2241
- // // int types pointers
2242
- S []* int `schema:"s,default:1000|notInt"`
2243
- T []* int8 `schema:"t,default:1000|notInt"`
2244
- U []* int16 `schema:"u,default:1000|notInt"`
2245
- V []* int32 `schema:"v,default:22222|notInt"`
2246
- W []* int64 `schema:"w,default:11111|notInt"`
2247
2234
// // float
2248
- X []float32 `schema:"c,default:2.2|notInt"`
2249
- Y []float64 `schema:"c,default:3.3|notInt"`
2250
- Z []* float64 `schema:"c,default:4.4|notInt"`
2235
+ X []float32 `schema:"c,default:2.2|notInt"`
2236
+ Y []float64 `schema:"c,default:3.3|notInt"`
2251
2237
}
2252
2238
d := D {}
2253
2239
2254
2240
data := map [string ][]string {}
2255
- pErrMsg := "default option is supported only on: bool, float variants, string, unit variants types or their corresponding pointers or slices"
2256
2241
eng := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2257
2242
2258
2243
decoder := NewDecoder ()
@@ -2264,17 +2249,13 @@ func TestInvalidDefaultElementInSliceRaiseError(t *testing.T) {
2264
2249
}
2265
2250
2266
2251
e , ok := err .(MultiError )
2267
- if ! ok || len (e ) != 26 {
2268
- t .Errorf ("Expected 26 errors, got %#v" , err )
2252
+ if ! ok || len (e ) != 14 {
2253
+ t .Errorf ("Expected 14 errors, got %#v" , err )
2269
2254
}
2270
2255
for _ , v := range eng {
2271
2256
fieldKey := "default-" + string (v )
2272
2257
errMsg := fmt .Sprintf ("failed setting default: notInt is not compatible with field %s type" , string (v ))
2273
2258
if ferr , ok := e [fieldKey ]; ok {
2274
- // check pointer type field
2275
- if ferr .Error () == pErrMsg {
2276
- continue
2277
- }
2278
2259
if strings .Compare (ferr .Error (), errMsg ) != 0 {
2279
2260
t .Errorf ("%s: expected %s, got %#v" , fieldKey , ferr .Error (), errMsg )
2280
2261
}
0 commit comments