@@ -26,10 +26,38 @@ type LimitTestData struct {
2626// Test field limits vs file limits precedence
2727// File limits: arrays:100 maps:50
2828type FieldOverrideTestData struct {
29- TightSlice []int `msg:"tight_slice,limit=10"` // Field limit (10) < file limit (100)
30- LooseSlice []string `msg:"loose_slice,limit=200"` // Field limit (200) > file limit (100)
31- TightMap map [string ]int `msg:"tight_map,limit=5"` // Field limit (5) < file limit (50)
32- LooseMap map [int ]string `msg:"loose_map,limit=80"` // Field limit (80) > file limit (50)
33- DefaultSlice []byte `msg:"default_slice"` // No field limit, uses file limit (100)
34- DefaultMap map [string ]string `msg:"default_map"` // No field limit, uses file limit (50)
29+ TightSlice []int `msg:"tight_slice,limit=10"` // Field limit (10) < file limit (100)
30+ LooseSlice []string `msg:"loose_slice,limit=200"` // Field limit (200) > file limit (100)
31+ TightMap map [string ]int `msg:"tight_map,limit=5"` // Field limit (5) < file limit (50)
32+ LooseMap map [int ]string `msg:"loose_map,limit=80"` // Field limit (80) > file limit (50)
33+ DefaultSlice []byte `msg:"default_slice"` // No field limit, uses file limit (100)
34+ DefaultMap map [string ]string `msg:"default_map"` // No field limit, uses file limit (50)
3535}
36+
37+ // Test allownil functionality with limits
38+ // File limits: arrays:100 maps:50
39+ type AllowNilTestData struct {
40+ NilSlice []byte `msg:"nil_slice,allownil"` // Can be nil, uses file limit (100)
41+ NilTightSlice []int `msg:"nil_tight_slice,allownil,limit=5"` // Can be nil, field limit (5) < file limit (100)
42+ NilLooseSlice []string `msg:"nil_loose_slice,allownil,limit=200"` // Can be nil, field limit (200) > file limit (100)
43+ NilZCSlice []byte `msg:"nil_zc_slice,allownil,zerocopy"` // Can be nil, zerocopy, uses file limit (100)
44+ NilZCTightSlice []byte `msg:"nil_zc_tight_slice,allownil,zerocopy,limit=5"` // Can be nil, zerocopy, field limit (5)
45+ NilMap map [string ]int `msg:"nil_map,allownil"` // Can be nil, uses file limit (50)
46+ NilTightMap map [string ]int `msg:"nil_tight_map,allownil,limit=3"` // Can be nil, field limit (3) < file limit (50)
47+ NilLooseMap map [int ]string `msg:"nil_loose_map,allownil,limit=75"` // Can be nil, field limit (75) > file limit (50)
48+ RegularSlice []byte `msg:"regular_slice"` // Cannot be nil, uses file limit (100)
49+ RegularMap map [string ]int `msg:"regular_map"` // Cannot be nil, uses file limit (50)
50+ ObjSlice []LimitedData `msg:"obj_slice"` // Cannot be nil, uses file limit (100)
51+ ObjMap map [string ]LimitedData `msg:"obj_map"` // Cannot be nil, uses file limit (50)
52+ }
53+
54+ type ObjSlices []LimitedData
55+ type ObjMaps map [string ]LimitedData
56+
57+ // Test allownil with zero-sized allocations
58+ type AllowNilZeroTestData struct {
59+ NilBytes []byte `msg:"nil_bytes,allownil"` // Can be nil, should allocate zero-sized slice
60+ RegularBytes []byte `msg:"regular_bytes"` // Cannot be nil
61+ }
62+
63+ type StandaloneBytesLimited []byte
0 commit comments