MCPcopy
hub / github.com/golang/protobuf / checkInitialized

Function checkInitialized

proto/proto_test.go:370–399  ·  view source on GitHub ↗

Check that all fields are nil. Clearly silly, and a residue from a more interesting test with an earlier, different initialization property, but it once caught a compiler bug so it lives.

(pb *pb2.GoTest, t *testing.T)

Source from the content-addressed store, hash-verified

368// different initialization property, but it once caught a compiler bug so
369// it lives.
370func checkInitialized(pb *pb2.GoTest, t *testing.T) {
371 switch {
372 case pb.F_BoolDefaulted != nil:
373 t.Error("New or Reset did not set boolean:", *pb.F_BoolDefaulted)
374 case pb.F_Int32Defaulted != nil:
375 t.Error("New or Reset did not set int32:", *pb.F_Int32Defaulted)
376 case pb.F_Int64Defaulted != nil:
377 t.Error("New or Reset did not set int64:", *pb.F_Int64Defaulted)
378 case pb.F_Fixed32Defaulted != nil:
379 t.Error("New or Reset did not set fixed32:", *pb.F_Fixed32Defaulted)
380 case pb.F_Fixed64Defaulted != nil:
381 t.Error("New or Reset did not set fixed64:", *pb.F_Fixed64Defaulted)
382 case pb.F_Uint32Defaulted != nil:
383 t.Error("New or Reset did not set uint32:", *pb.F_Uint32Defaulted)
384 case pb.F_Uint64Defaulted != nil:
385 t.Error("New or Reset did not set uint64:", *pb.F_Uint64Defaulted)
386 case pb.F_FloatDefaulted != nil:
387 t.Error("New or Reset did not set float:", *pb.F_FloatDefaulted)
388 case pb.F_DoubleDefaulted != nil:
389 t.Error("New or Reset did not set double:", *pb.F_DoubleDefaulted)
390 case pb.F_StringDefaulted != nil:
391 t.Error("New or Reset did not set string:", *pb.F_StringDefaulted)
392 case pb.F_BytesDefaulted != nil:
393 t.Error("New or Reset did not set bytes:", string(pb.F_BytesDefaulted))
394 case pb.F_Sint32Defaulted != nil:
395 t.Error("New or Reset did not set int32:", *pb.F_Sint32Defaulted)
396 case pb.F_Sint64Defaulted != nil:
397 t.Error("New or Reset did not set int64:", *pb.F_Sint64Defaulted)
398 }
399}
400
401// Does Reset() reset?
402func TestReset(t *testing.T) {

Callers 1

TestResetFunction · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected