forked from deoxxa/hl7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount_test.go
100 lines (91 loc) · 4.35 KB
/
count_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package hl7
import (
"testing"
"github.com/stretchr/testify/assert"
)
type countTestCase struct {
q string
c int
m []byte
}
var countTestCases = []countTestCase{
countTestCase{"MSH", 1, []byte(longTestMessageContent)},
countTestCase{"OBX", 47, []byte(longTestMessageContent)},
countTestCase{"WWW", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(1)", 16, []byte(longTestMessageContent)},
countTestCase{"OBX(1)", 7, []byte(longTestMessageContent)},
countTestCase{"WWW(1)", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(2)", 0, []byte(longTestMessageContent)},
countTestCase{"OBX(2)", 6, []byte(longTestMessageContent)},
countTestCase{"WWW(2)", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(30)", 0, []byte(longTestMessageContent)},
countTestCase{"OBX(30)", 6, []byte(longTestMessageContent)},
countTestCase{"WWW(30)", 0, []byte(longTestMessageContent)},
countTestCase{"MSH-1", 1, []byte(longTestMessageContent)},
countTestCase{"OBX-1", 1, []byte(longTestMessageContent)},
countTestCase{"WWW-1", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(1)-1", 1, []byte(longTestMessageContent)},
countTestCase{"OBX(1)-1", 1, []byte(longTestMessageContent)},
countTestCase{"WWW(1)-1", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(2)-1", 0, []byte(longTestMessageContent)},
countTestCase{"OBX(2)-1", 1, []byte(longTestMessageContent)},
countTestCase{"WWW(2)-1", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(30)-1", 0, []byte(longTestMessageContent)},
countTestCase{"OBX(30)-1", 1, []byte(longTestMessageContent)},
countTestCase{"WWW(30)-1", 0, []byte(longTestMessageContent)},
countTestCase{"MSH-100", 0, []byte(longTestMessageContent)},
countTestCase{"OBX-100", 0, []byte(longTestMessageContent)},
countTestCase{"WWW-100", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(1)-100", 0, []byte(longTestMessageContent)},
countTestCase{"OBX(1)-100", 0, []byte(longTestMessageContent)},
countTestCase{"WWW(1)-100", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(2)-100", 0, []byte(longTestMessageContent)},
countTestCase{"OBX(2)-100", 0, []byte(longTestMessageContent)},
countTestCase{"WWW(2)-100", 0, []byte(longTestMessageContent)},
countTestCase{"MSH(30)-100", 0, []byte(longTestMessageContent)},
countTestCase{"OBX(30)-100", 0, []byte(longTestMessageContent)},
countTestCase{"WWW(30)-100", 0, []byte(longTestMessageContent)},
countTestCase{"MSH-1", 1, []byte(longTestMessageContent)},
countTestCase{"OBX-1", 1, []byte(longTestMessageContent)},
countTestCase{"PID-1", 0, []byte(longTestMessageContent)},
countTestCase{"PID-2", 0, []byte(longTestMessageContent)},
countTestCase{"PID-3", 3, []byte(longTestMessageContent)},
countTestCase{"PID-4", 0, []byte(longTestMessageContent)},
countTestCase{"PID-5", 1, []byte(longTestMessageContent)},
countTestCase{"PID-3(1)", 5, []byte(longTestMessageContent)},
countTestCase{"PID-3(2)", 5, []byte(longTestMessageContent)},
countTestCase{"PID-3(3)", 5, []byte(longTestMessageContent)},
countTestCase{"PID-3(4)", 0, []byte(longTestMessageContent)},
countTestCase{"PID-3(1)-1", 1, []byte(longTestMessageContent)},
countTestCase{"PID-3(2)-1", 1, []byte(longTestMessageContent)},
countTestCase{"PID-3(3)-1", 1, []byte(longTestMessageContent)},
countTestCase{"PID-3(4)-1", 0, []byte(longTestMessageContent)},
countTestCase{"PID-5(1)", 7, []byte(longTestMessageContent)},
countTestCase{"PID-5(2)", 0, []byte(longTestMessageContent)},
countTestCase{"PID-5(3)", 0, []byte(longTestMessageContent)},
countTestCase{"PID-5-1", 1, []byte(longTestMessageContent)},
countTestCase{"PID-5(1)-1", 1, []byte(longTestMessageContent)},
countTestCase{"PID-5(2)-1", 0, []byte(longTestMessageContent)},
countTestCase{"NK1(1)", 4, []byte(longTestMessageContent)},
countTestCase{"NK1(2)", 7, []byte(longTestMessageContent)},
countTestCase{"NK1(3)", 0, []byte(longTestMessageContent)},
countTestCase{"WWW-1", 0, []byte(longTestMessageContent)},
countTestCase{"WWW-1-1", 0, []byte(longTestMessageContent)},
countTestCase{"WWW-1-2-3", 0, []byte(longTestMessageContent)},
}
func TestCount(t *testing.T) {
for i := range countTestCases {
c := countTestCases[i]
t.Run(c.q, func(t *testing.T) {
a := assert.New(t)
q, err := ParseQuery(c.q)
a.NoError(err)
m, _, err := ParseMessage(c.m)
a.NoError(err)
if a.NotNil(q) && a.NotNil(m) {
l := q.Count(m)
a.Equal(c.c, l, q.String())
}
})
}
}