MCPcopy
hub / github.com/go-playground/validator / TestMultipleRecursiveExtractStructCache

Function TestMultipleRecursiveExtractStructCache

validator_test.go:10179–10204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10177}
10178
10179func TestMultipleRecursiveExtractStructCache(t *testing.T) {
10180 validate := New()
10181
10182 type Recursive struct {
10183 Field *string `validate:"required,len=5,ne=string"`
10184 }
10185
10186 var test Recursive
10187
10188 current := reflect.ValueOf(test)
10189 name := "Recursive"
10190 proceed := make(chan struct{})
10191
10192 sc := validate.extractStructCache(current, name)
10193 ptr := fmt.Sprintf("%p", sc)
10194
10195 for i := 0; i < 100; i++ {
10196 go func() {
10197 <-proceed
10198 sc := validate.extractStructCache(current, name)
10199 Equal(t, ptr, fmt.Sprintf("%p", sc))
10200 }()
10201 }
10202
10203 close(proceed)
10204}
10205
10206// Thanks @robbrockbank, see https://github.com/go-playground/validator/issues/249
10207func TestPointerAndOmitEmpty(t *testing.T) {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
extractStructCacheMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…