-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconvert_test.go
60 lines (51 loc) · 1.29 KB
/
convert_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package _generated
import (
"bytes"
"testing"
"github.com/algorand/msgp/msgp"
)
func TestConvertFromEncodeError(t *testing.T) {
e := ConvertErr{ConvertErrVal(fromFailStr)}
var buf bytes.Buffer
w := msgp.NewWriter(&buf)
err := e.EncodeMsg(w)
if msgp.Cause(err) != errConvertFrom {
t.Fatalf("expected conversion error, found '%v'", err.Error())
}
}
func TestConvertToEncodeError(t *testing.T) {
var in, out ConvertErr
in = ConvertErr{ConvertErrVal(toFailStr)}
var buf bytes.Buffer
w := msgp.NewWriter(&buf)
err := in.EncodeMsg(w)
if err != nil {
t.FailNow()
}
w.Flush()
r := msgp.NewReader(&buf)
err = (&out).DecodeMsg(r)
if msgp.Cause(err) != errConvertTo {
t.Fatalf("expected conversion error, found %v", err.Error())
}
}
func TestConvertFromMarshalError(t *testing.T) {
e := ConvertErr{ConvertErrVal(fromFailStr)}
var b []byte
_, err := e.MarshalMsg(b)
if msgp.Cause(err) != errConvertFrom {
t.Fatalf("expected conversion error, found %v", err.Error())
}
}
func TestConvertToMarshalError(t *testing.T) {
var in, out ConvertErr
in = ConvertErr{ConvertErrVal(toFailStr)}
b, err := in.MarshalMsg(nil)
if err != nil {
t.FailNow()
}
_, err = (&out).UnmarshalMsg(b)
if msgp.Cause(err) != errConvertTo {
t.Fatalf("expected conversion error, found %v", err.Error())
}
}