-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstructs_test.go
More file actions
58 lines (48 loc) · 1.1 KB
/
structs_test.go
File metadata and controls
58 lines (48 loc) · 1.1 KB
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
package extcap
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
)
func TestStructs(t *testing.T) {
testCases := []struct {
name string
in interface{}
expected string
}{
{"Interface",
&Interface{"example1", "Example interface 1 for extcap"},
"interface {value=example1}{display=Example interface 1 for extcap}",
},
{"DLT",
&LinkType{147, "USER1", "Demo Implementation for Extcap"},
"dlt {number=147}{name=USER1}{display=Demo Implementation for Extcap}",
},
}
type m interface {
marshal() string
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
actual := (tc.in).(m).marshal()
assert.Equal(t, tc.expected, actual)
})
}
}
func TestVersionPrint(t *testing.T) {
testCases := []struct {
name string
ver string
help string
expected string
}{
{"Version set", "0.0.1", "VerHelp",
"extcap {version=0.0.1}{help=VerHelp}",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
require.Equal(t, tc.expected, versionString(tc.ver, tc.help))
})
}
}