MCPcopy Create free account
hub / github.com/google/go-querystring / TestValues_EmbeddedStructs

Function TestValues_EmbeddedStructs

query/encode_test.go:372–425  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

370}
371
372func TestValues_EmbeddedStructs(t *testing.T) {
373 type Inner struct {
374 V string
375 }
376 type Outer struct {
377 Inner
378 }
379 type OuterPtr struct {
380 *Inner
381 }
382 type Mixed struct {
383 Inner
384 V string
385 }
386 type unexported struct {
387 Inner
388 V string
389 }
390 type Exported struct {
391 unexported
392 }
393
394 tests := []struct {
395 input interface{}
396 want url.Values
397 }{
398 {
399 Outer{Inner{V: "a"}},
400 url.Values{"V": {"a"}},
401 },
402 {
403 OuterPtr{&Inner{V: "a"}},
404 url.Values{"V": {"a"}},
405 },
406 {
407 Mixed{Inner: Inner{V: "a"}, V: "b"},
408 url.Values{"V": {"b", "a"}},
409 },
410 {
411 // values from unexported embed are still included
412 Exported{
413 unexported{
414 Inner: Inner{V: "bar"},
415 V: "foo",
416 },
417 },
418 url.Values{"V": {"foo", "bar"}},
419 },
420 }
421
422 for _, tt := range tests {
423 testValue(t, tt.input, tt.want)
424 }
425}
426
427func TestValues_InvalidInput(t *testing.T) {
428 _, err := Values("")

Callers

nothing calls this directly

Calls 1

testValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…