(t *testing.T)
| 755 | } |
| 756 | |
| 757 | func TestEncodeNested(t *testing.T) { |
| 758 | t.Run("valid message", func(t *testing.T) { |
| 759 | var ( |
| 760 | name = "test" |
| 761 | val int32 = 42 |
| 762 | expected = []byte{0xa, 0x8, 0xa, 0x4, 0x74, 0x65, 0x73, 0x74, 0x10, 0x2a} |
| 763 | ) |
| 764 | m := testNestedMsg{ |
| 765 | Name: &name, |
| 766 | Value: &val, |
| 767 | } |
| 768 | |
| 769 | sz := m.Size() |
| 770 | buf := make([]byte, 1+csproto.SizeOfVarint(uint64(sz))+sz) |
| 771 | enc := csproto.NewEncoder(buf) |
| 772 | |
| 773 | err := enc.EncodeNested(1, &m) |
| 774 | |
| 775 | assert.NoError(t, err) |
| 776 | assert.Equal(t, expected, buf) |
| 777 | }) |
| 778 | t.Run("nil message", func(t *testing.T) { |
| 779 | t.Skip() |
| 780 | var m *testNestedMsg |
| 781 | |
| 782 | buf := make([]byte, 10) |
| 783 | enc := csproto.NewEncoder(buf) |
| 784 | |
| 785 | err := enc.EncodeNested(1, m) |
| 786 | |
| 787 | assert.NoError(t, err) |
| 788 | assert.Equal(t, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, buf) |
| 789 | }) |
| 790 | } |
| 791 | |
| 792 | func TestEncodeRaw(t *testing.T) { |
| 793 | var ( |
nothing calls this directly
no test coverage detected