-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfield_test.go
30 lines (27 loc) · 833 Bytes
/
field_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
package hl7
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewField(t *testing.T) {
tests := []struct {
name string
compSep byte
subCompSep byte
escape byte
data []byte
want Field
}{
{"empty (nil)", '^', '&', '\\', []byte(nil), Field(nil)},
{"empty (not nil)", '^', '&', '\\', []byte{}, Field(nil)},
{"one part", '^', '&', '\\', []byte("foo"), Field{{SubComponent("foo")}}},
{"two parts", '^', '&', '\\', []byte("foo^bar"), Field{{SubComponent("foo")}, {SubComponent("bar")}}},
{"two parts", '@', '&', '\\', []byte("foo@bar"), Field{{SubComponent("foo")}, {SubComponent("bar")}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := newField(tt.compSep, tt.subCompSep, tt.escape, tt.data)
assert.Equal(t, tt.want, got)
})
}
}