forked from quickfixgo/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_string_test.go
48 lines (40 loc) · 844 Bytes
/
fix_string_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
package quickfix
import (
"bytes"
"testing"
)
func TestFIXStringWrite(t *testing.T) {
var tests = []struct {
field FIXString
val []byte
}{
{"CWB", []byte("CWB")},
}
for _, test := range tests {
b := test.field.Write()
if !bytes.Equal(b, test.val) {
t.Errorf("got %v; want %v", b, test.val)
}
}
}
func TestFIXStringRead(t *testing.T) {
var tests = []struct {
bytes []byte
value string
expectError bool
}{
{[]byte("blah"), "blah", false},
}
for _, test := range tests {
var field FIXString
err := field.Read(test.bytes)
if test.expectError && err == nil {
t.Errorf("Expected error for %v", test.bytes)
} else if !test.expectError && err != nil {
t.Errorf("UnExpected '%v'", err)
}
if string(field) != test.value {
t.Errorf("got %v want %v", field, test.value)
}
}
}