You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
457 B

  1. package types
  2. import (
  3. "bytes"
  4. "testing"
  5. "github.com/gogo/protobuf/proto"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestWriteReadMessage(t *testing.T) {
  9. cases := []proto.Message{
  10. &RequestEcho{"hello"},
  11. // TODO: add the rest
  12. }
  13. for _, c := range cases {
  14. buf := new(bytes.Buffer)
  15. err := WriteMessage(c, buf)
  16. assert.Nil(t, err)
  17. msg := new(RequestEcho)
  18. err = ReadMessage(buf, msg)
  19. assert.Nil(t, err)
  20. assert.Equal(t, c, msg)
  21. }
  22. }