Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions _generated/field_limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package _generated

//go:generate msgp

// Aliased types for testing
type AliasedSlice []string
type AliasedMap map[string]bool
type AliasedIntSlice []int

// Test structures for field-level limit tags
type FieldLimitTestData struct {
SmallSlice []int `msg:"small_slice,limit=5"`
LargeSlice []string `msg:"large_slice,limit=100"`
SmallMap map[string]int `msg:"small_map,limit=3"`
LargeMap map[int]string `msg:"large_map,limit=20"`
NoLimit []byte `msg:"no_limit"` // Uses file-level limits if any
FixedArray [10]int `msg:"fixed_array,limit=2"` // Should be ignored
}

// Test structure with aliased types and field limits
type AliasedFieldLimitTestData struct {
SmallAliasedSlice AliasedSlice `msg:"small_aliased_slice,limit=3"`
LargeAliasedSlice AliasedSlice `msg:"large_aliased_slice,limit=50"`
SmallAliasedMap AliasedMap `msg:"small_aliased_map,limit=2"`
LargeAliasedMap AliasedMap `msg:"large_aliased_map,limit=25"`
IntSliceAlias AliasedIntSlice `msg:"int_slice_alias,limit=10"`
NoLimitAlias AliasedSlice `msg:"no_limit_alias"` // Uses file-level limits
}
35 changes: 35 additions & 0 deletions _generated/limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//msgp:limit arrays:100 maps:50

package _generated

//go:generate msgp

// Test structures for limit directive
type LimitedData struct {
SmallArray [10]int `msg:"small_array"`
LargeSlice []byte `msg:"large_slice"`
SmallMap map[string]int `msg:"small_map"`
}

type UnlimitedData struct {
BigArray [1000]int `msg:"big_array"`
BigSlice []string `msg:"big_slice"`
BigMap map[string][]int `msg:"big_map"`
}

type LimitTestData struct {
SmallArray [10]int `msg:"small_array"`
LargeSlice []byte `msg:"large_slice"`
SmallMap map[string]int `msg:"small_map"`
}

// Test field limits vs file limits precedence
// File limits: arrays:100 maps:50
type FieldOverrideTestData struct {
TightSlice []int `msg:"tight_slice,limit=10"` // Field limit (10) < file limit (100)
LooseSlice []string `msg:"loose_slice,limit=200"` // Field limit (200) > file limit (100)
TightMap map[string]int `msg:"tight_map,limit=5"` // Field limit (5) < file limit (50)
LooseMap map[int]string `msg:"loose_map,limit=80"` // Field limit (80) > file limit (50)
DefaultSlice []byte `msg:"default_slice"` // No field limit, uses file limit (100)
DefaultMap map[string]string `msg:"default_map"` // No field limit, uses file limit (50)
}
23 changes: 23 additions & 0 deletions _generated/limits2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package _generated

//go:generate msgp

//msgp:limit arrays:200 maps:100

type LimitTestData2 struct {
BigArray [20]int `msg:"big_array"`
BigMap map[string]int `msg:"big_map"`
}

// Test field limits vs file limits precedence with different file limits
// File limits: arrays:200 maps:100
type FieldOverrideTestData2 struct {
TightSlice []int `msg:"tight_slice,limit=30"` // Field limit (30) < file limit (200)
MediumSlice []string `msg:"medium_slice,limit=150"` // Field limit (150) < file limit (200)
LooseSlice []byte `msg:"loose_slice,limit=300"` // Field limit (300) > file limit (200)
TightMap map[string]int `msg:"tight_map,limit=20"` // Field limit (20) < file limit (100)
MediumMap map[int]string `msg:"medium_map,limit=75"` // Field limit (75) < file limit (100)
LooseMap map[string][]int `msg:"loose_map,limit=150"` // Field limit (150) > file limit (100)
DefaultSlice []int `msg:"default_slice"` // No field limit, uses file limit (200)
DefaultMap map[int]int `msg:"default_map"` // No field limit, uses file limit (100)
}
Loading
Loading