-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathprint_test.go
More file actions
57 lines (53 loc) · 1.52 KB
/
Copy pathprint_test.go
File metadata and controls
57 lines (53 loc) · 1.52 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
package canlib
import (
"testing"
)
// TestRawCanFrameToString will verify that a CAN message is formatted properly
func TestRawCanFrameToString(t *testing.T) {
testFrame := RawCanFrame{
OID: 1,
ID: 1,
Dlc: 1,
Eff: false,
Rtr: false,
Err: false,
Data: []byte{1},
Timestamp: 1000000000,
CaptureInterface: "test",
}
expected := "test,1,1,NOEFF,NORTR,NOERR,1,1,01"
result := RawCanFrameToString(testFrame, ",")
if expected != result {
t.Errorf("%s != %s", expected, result)
}
}
// TestTimestampToSeconds makes sure that the function works
func TestTimestampToSeconds(t *testing.T) {
fakeTime := int64(1000000000)
expected := float64(1)
result := TimestampToSeconds(fakeTime)
if expected != result {
t.Errorf("%v != %v", expected, result)
}
}
// TestProcessedCanFrameToString makes sure that ProcessedCanFrameToString works
func TestProcessedCanFrameToString(t *testing.T) {
testRawFrame := RawCanFrame{
OID: 1,
ID: 1,
Dlc: 1,
Eff: false,
Rtr: false,
Err: false,
Data: []byte{1},
Timestamp: 1000000000,
CaptureInterface: "test",
}
testProcessedFrame := ProcessedCanFrame{Packet: testRawFrame,
PacketHash: "testHash"}
expected := "testHash,test,1,1,NOEFF,NORTR,NOERR,1,1,01"
result := ProcessedCanFrameToString(testProcessedFrame, ",")
if expected != result {
t.Errorf("%s != %s", expected, result)
}
}