encoder_decoder_test.go 415 B

12345678910111213141516171819
  1. package protocol
  2. import (
  3. "bytes"
  4. "testing"
  5. )
  6. // no actual tests, just helper functions for testing structures that
  7. // implement the encoder or decoder interfaces
  8. func testEncodable(t *testing.T, name string, in encoder, result []byte) {
  9. packet, err := encode(in)
  10. if err != nil {
  11. t.Error(err)
  12. }
  13. if !bytes.Equal(packet, result) {
  14. t.Error("Encoding", name, "failed\ngot ", packet, "\nwant", result)
  15. }
  16. }