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.

59 lines
1.2 KiB

  1. package _generated
  2. import (
  3. "bytes"
  4. "testing"
  5. "github.com/tinylib/msgp/msgp"
  6. )
  7. func TestConvertFromEncodeError(t *testing.T) {
  8. e := ConvertErr{ConvertErrVal(fromFailStr)}
  9. var buf bytes.Buffer
  10. w := msgp.NewWriter(&buf)
  11. err := e.EncodeMsg(w)
  12. if err != errConvertFrom {
  13. t.Fatalf("expected conversion error, found %v", err.Error())
  14. }
  15. }
  16. func TestConvertToEncodeError(t *testing.T) {
  17. var in, out ConvertErr
  18. in = ConvertErr{ConvertErrVal(toFailStr)}
  19. var buf bytes.Buffer
  20. w := msgp.NewWriter(&buf)
  21. err := in.EncodeMsg(w)
  22. if err != nil {
  23. t.FailNow()
  24. }
  25. w.Flush()
  26. r := msgp.NewReader(&buf)
  27. err = (&out).DecodeMsg(r)
  28. if err != errConvertTo {
  29. t.Fatalf("expected conversion error, found %v", err.Error())
  30. }
  31. }
  32. func TestConvertFromMarshalError(t *testing.T) {
  33. e := ConvertErr{ConvertErrVal(fromFailStr)}
  34. var b []byte
  35. _, err := e.MarshalMsg(b)
  36. if err != errConvertFrom {
  37. t.Fatalf("expected conversion error, found %v", err.Error())
  38. }
  39. }
  40. func TestConvertToMarshalError(t *testing.T) {
  41. var in, out ConvertErr
  42. in = ConvertErr{ConvertErrVal(toFailStr)}
  43. b, err := in.MarshalMsg(nil)
  44. if err != nil {
  45. t.FailNow()
  46. }
  47. _, err = (&out).UnmarshalMsg(b)
  48. if err != errConvertTo {
  49. t.Fatalf("expected conversion error, found %v", err.Error())
  50. }
  51. }