forked from quickfixgo/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_boolean_test.go
More file actions
44 lines (37 loc) · 840 Bytes
/
fix_boolean_test.go
File metadata and controls
44 lines (37 loc) · 840 Bytes
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
package quickfix
import (
"bytes"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBooleanWrite(t *testing.T) {
var tests = []struct {
val FIXBoolean
expected []byte
}{
{FIXBoolean(true), []byte("Y")},
{FIXBoolean(false), []byte("N")},
}
for _, test := range tests {
b := test.val.Write()
assert.True(t, bytes.Equal(b, test.expected), fmt.Sprintf("got %v; want %v", b, test.expected))
}
}
func TestFIXBooleanRead(t *testing.T) {
var tests = []struct {
bytes []byte
expected bool
expectError bool
}{
{[]byte("Y"), true, false},
{[]byte("N"), false, false},
{[]byte("blah"), false, true},
}
for _, test := range tests {
var val FIXBoolean
err := val.Read(test.bytes)
assert.Equal(t, test.expectError, err != nil)
assert.Equal(t, test.expected, val.Bool())
}
}