Test that we encode nil-valued fields of a repeated bytes field correctly. Since entries in a repeated field cannot be nil, nil must mean empty value.
(t *testing.T)
| 865 | // Test that we encode nil-valued fields of a repeated bytes field correctly. |
| 866 | // Since entries in a repeated field cannot be nil, nil must mean empty value. |
| 867 | func TestEncodeDecodeBytes2(t *testing.T) { |
| 868 | pb := initGoTest(false) |
| 869 | |
| 870 | // Create our bytes |
| 871 | pb.F_BytesRepeated = [][]byte{nil} |
| 872 | |
| 873 | d, err := proto.Marshal(pb) |
| 874 | if err != nil { |
| 875 | t.Error(err) |
| 876 | } |
| 877 | |
| 878 | pbd := new(pb2.GoTest) |
| 879 | if err := proto.Unmarshal(d, pbd); err != nil { |
| 880 | t.Error(err) |
| 881 | } |
| 882 | |
| 883 | if len(pbd.F_BytesRepeated) != 1 || pbd.F_BytesRepeated[0] == nil { |
| 884 | t.Error("Unexpected value for repeated bytes field") |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | // All required fields set, defaults provided, all repeated fields given two values. |
| 889 | func TestSkippingUnrecognizedFields(t *testing.T) { |
nothing calls this directly
no test coverage detected