MCPcopy
hub / github.com/pquerna/ffjson / TestEmbedded

Function TestEmbedded

tests/ff_test.go:789–843  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

787}
788
789func TestEmbedded(t *testing.T) {
790 a := TEmbeddedStructures{}
791 a.X = make([]interface{}, 0)
792 a.X = append(a.X, "testString")
793 a.Y.X = 73
794 a.Z = make([]struct{ X int }, 2)
795 a.Z[0].X = 12
796 a.Z[1].X = 34
797 a.U = make(map[string]struct{ X int })
798 a.U["sample"] = struct{ X int }{X: 56}
799 a.U["value"] = struct{ X int }{X: 78}
800 a.V = make([]map[string]struct{ X int }, 3)
801 for i := range a.V {
802 a.V[i] = make(map[string]struct{ X int })
803 a.V[i]["sample"] = struct{ X int }{X: i * 3}
804 }
805 for i := range a.W {
806 a.W[i] = make(map[string]struct{ X int })
807 a.W[i]["sample"] = struct{ X int }{X: i * 3}
808 a.W[i]["value"] = struct{ X int }{X: i * 5}
809 }
810 a.Q = make([][]string, 3)
811 for i := range a.Q {
812 a.Q[i] = make([]string, 1)
813 a.Q[i][0] = fmt.Sprintf("thestring #%d", i)
814 }
815
816 b := XEmbeddedStructures{}
817 b.X = make([]interface{}, 0)
818 b.X = append(b.X, "testString")
819 b.Y.X = 73
820 b.Z = make([]struct{ X int }, 2)
821 b.Z[0].X = 12
822 b.Z[1].X = 34
823 b.U = make(map[string]struct{ X int })
824 b.U["sample"] = struct{ X int }{X: 56}
825 b.U["value"] = struct{ X int }{X: 78}
826 b.V = make([]map[string]struct{ X int }, 3)
827 for i := range b.V {
828 b.V[i] = make(map[string]struct{ X int })
829 b.V[i]["sample"] = struct{ X int }{X: i * 3}
830 }
831 for i := range b.W {
832 b.W[i] = make(map[string]struct{ X int })
833 b.W[i]["sample"] = struct{ X int }{X: i * 3}
834 b.W[i]["value"] = struct{ X int }{X: i * 5}
835 }
836 b.Q = make([][]string, 3)
837 for i := range a.Q {
838 b.Q[i] = make([]string, 1)
839 b.Q[i][0] = fmt.Sprintf("thestring #%d", i)
840 }
841 testSameMarshal(t, &a, &b)
842 testCycle(t, &a, &b)
843}
844
845func TestRenameTypes(t *testing.T) {
846 testType(t, &TRenameTypes{}, &XRenameTypes{})

Callers

nothing calls this directly

Calls 2

testSameMarshalFunction · 0.85
testCycleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…