MCPcopy Create free account
hub / github.com/goccy/go-yaml / TestEncodeStructIncludeMap

Function TestEncodeStructIncludeMap

encode_test.go:973–993  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

971}
972
973func TestEncodeStructIncludeMap(t *testing.T) {
974 type U struct {
975 M map[string]string
976 }
977 type T struct {
978 A U
979 }
980 bytes, err := yaml.Marshal(T{
981 A: U{
982 M: map[string]string{"x": "y"},
983 },
984 })
985 if err != nil {
986 t.Fatalf("%+v", err)
987 }
988 expect := "a:\n m:\n x: \"y\"\n"
989 actual := string(bytes)
990 if actual != expect {
991 t.Fatalf("unexpected output. expect:[%s] actual:[%s]", expect, actual)
992 }
993}
994
995func TestEncodeDefinedTypeKeyMap(t *testing.T) {
996 type K string

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…