MCPcopy
hub / github.com/google/go-cmp / project4Tests

Function project4Tests

cmp/compare_test.go:2877–2958  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2875}
2876
2877func project4Tests() []test {
2878 const label = "Project4"
2879
2880 allowVisibility := cmp.AllowUnexported(
2881 ts.Cartel{},
2882 ts.Headquarter{},
2883 ts.Poison{},
2884 )
2885
2886 transformProtos := cmp.Transformer("λ", func(x pb.Restrictions) *pb.Restrictions {
2887 return &x
2888 })
2889
2890 createCartel := func() ts.Cartel {
2891 var p ts.Poison
2892 p.SetPoisonType(5)
2893 p.SetExpiration(now)
2894 p.SetManufacturer("acme")
2895
2896 var hq ts.Headquarter
2897 hq.SetID(5)
2898 hq.SetLocation("moon")
2899 hq.SetSubDivisions([]string{"alpha", "bravo", "charlie"})
2900 hq.SetMetaData(&pb.MetaData{Stringer: pb.Stringer{X: "metadata"}})
2901 hq.SetPublicMessage([]byte{1, 2, 3, 4, 5})
2902 hq.SetHorseBack("abcdef")
2903 hq.SetStatus(44)
2904
2905 var c ts.Cartel
2906 c.Headquarter = hq
2907 c.SetSource("mars")
2908 c.SetCreationTime(now)
2909 c.SetBoss("al capone")
2910 c.SetPoisons([]*ts.Poison{&p})
2911
2912 return c
2913 }
2914
2915 return []test{{
2916 label: label + "/PanicUnexported1",
2917 x: createCartel(),
2918 y: createCartel(),
2919 wantPanic: "cannot handle unexported field",
2920 reason: "struct contains unexported fields",
2921 }, {
2922 label: label + "/PanicUnexported2",
2923 x: createCartel(),
2924 y: createCartel(),
2925 opts: []cmp.Option{allowVisibility, cmp.Comparer(pb.Equal)},
2926 wantPanic: "cannot handle unexported field",
2927 reason: "struct contains references to simulated protobuf types with unexported fields",
2928 }, {
2929 label: label + "/Equal",
2930 x: createCartel(),
2931 y: createCartel(),
2932 opts: []cmp.Option{allowVisibility, transformProtos, cmp.Comparer(pb.Equal)},
2933 wantEqual: true,
2934 reason: "transformer used to create reference to protobuf message so it works with pb.Equal",

Callers 1

TestDiffFunction · 0.85

Calls 15

SetPoisonTypeMethod · 0.95
SetExpirationMethod · 0.95
SetManufacturerMethod · 0.95
SetIDMethod · 0.95
SetLocationMethod · 0.95
SetSubDivisionsMethod · 0.95
SetMetaDataMethod · 0.95
SetPublicMessageMethod · 0.95
SetHorseBackMethod · 0.95
SetStatusMethod · 0.95
SetSourceMethod · 0.95
SetBossMethod · 0.95

Tested by

no test coverage detected