-
Notifications
You must be signed in to change notification settings - Fork 0
/
importer_test.go
56 lines (43 loc) · 1.29 KB
/
importer_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
package acmelib
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_ImportDBCFile(t *testing.T) {
assert := assert.New(t)
inputFile, err := os.Open(expectedDBCFilename)
assert.NoError(err)
bus, err := ImportDBCFile(expectedDBCFilename, inputFile)
assert.NoError(err)
inputFile.Close()
// // exporting the bus
// fileBuf := &strings.Builder{}
// ExportBus(fileBuf, bus)
// testFile, err := os.Open(expectedDBCFilename)
// assert.NoError(err)
// testFileBuf := &strings.Builder{}
// _, err = io.Copy(testFileBuf, testFile)
// assert.NoError(err)
// testFile.Close()
// // thanks to Windows that puts \r after \n
// re := regexp.MustCompile(`\r?\n`)
// expectedFileStr := re.ReplaceAllString(testFileBuf.String(), "")
// fileStr := strings.ReplaceAll(fileBuf.String(), "\n", "")
// assert.Equal(expectedFileStr, fileStr)
// testing signal types aggregation
sigTypeIDs := make(map[EntityID]bool)
for _, tmpNodeInt := range bus.NodeInterfaces() {
for _, tmpMsg := range tmpNodeInt.SentMessages() {
for _, sig := range tmpMsg.signals.getValues() {
if sig.Kind() != SignalKindStandard {
continue
}
stdSig, err := sig.ToStandard()
assert.NoError(err)
sigTypeIDs[stdSig.Type().EntityID()] = true
}
}
}
assert.Len(sigTypeIDs, 1)
}