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