MCPcopy
hub / github.com/protocolbuffers/protobuf-go / TestExtensionLazyDeterministic

Function TestExtensionLazyDeterministic

internal/impl/lazy_test.go:201–223  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func TestExtensionLazyDeterministic(t *testing.T) {
202 if !flags.LazyUnmarshalExtensions {
203 t.Skip("lazy extension unmarshaling disabled; not built with the protolegacy tag")
204 }
205
206 tree := proto.Clone(treeTemplate)
207 proto.SetExtension(tree, lazytestpb.E_Bat, &lazytestpb.FlyingFox{Species: &spGH})
208 proto.SetExtension(tree, lazytestpb.E_BatPup, &lazytestpb.FlyingFox{Species: &spP})
209
210 nt := roundtrip(t, tree).(*lazytestpb.Tree)
211
212 if extensionIsInitialized(t, nt, lazytestpb.E_Bat) {
213 t.Errorf("Extension unexpectedly initialized after Unmarshal")
214 }
215 proto.Size(nt)
216 if extensionIsInitialized(t, nt, lazytestpb.E_Bat) {
217 t.Errorf("Extension unexpectedly initialized after Size")
218 }
219 proto.MarshalOptions{Deterministic: true}.Size(nt)
220 if !extensionIsInitialized(t, nt, lazytestpb.E_Bat) {
221 t.Errorf("Extension unexpectedly not initialized after deterministic Size")
222 }
223}
224
225func TestExtensionNestedScopeLazy(t *testing.T) {
226 if !flags.LazyUnmarshalExtensions {

Callers

nothing calls this directly

Calls 7

CloneFunction · 0.92
SetExtensionFunction · 0.92
SizeFunction · 0.92
extensionIsInitializedFunction · 0.85
roundtripFunction · 0.70
SkipMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected