(t *testing.T)
| 1593 | } |
| 1594 | |
| 1595 | func TestExtensionMapFieldMarshalDeterministic(t *testing.T) { |
| 1596 | m := &pb2.MyMessage{Count: proto.Int(123)} |
| 1597 | if err := proto.SetExtension(m, pb2.E_Ext_More, &pb2.Ext{MapField: map[int32]int32{1: 1, 2: 2, 3: 3, 4: 4}}); err != nil { |
| 1598 | t.Fatalf("SetExtension: %v", err) |
| 1599 | } |
| 1600 | marshal := func(m proto.Message) []byte { |
| 1601 | var b proto.Buffer |
| 1602 | b.SetDeterministic(true) |
| 1603 | if err := b.Marshal(m); err != nil { |
| 1604 | t.Fatalf("Marshal failed: %v", err) |
| 1605 | } |
| 1606 | return b.Bytes() |
| 1607 | } |
| 1608 | |
| 1609 | want := marshal(m) |
| 1610 | for i := 0; i < 100; i++ { |
| 1611 | if got := marshal(m); !bytes.Equal(got, want) { |
| 1612 | t.Errorf("Marshal produced inconsistent output with determinism enabled (pass %d).\n got %v\nwant %v", i, got, want) |
| 1613 | } |
| 1614 | } |
| 1615 | } |
| 1616 | |
| 1617 | func TestUnmarshalMergesMessages(t *testing.T) { |
| 1618 | // If a nested message occurs twice in the input, |
nothing calls this directly
no test coverage detected