You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
725 B
38 lines
725 B
package main
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestFromString(t *testing.T) {
|
|
type args struct {
|
|
text *string
|
|
}
|
|
|
|
var dump = "(2022-07-08 16:54:15.587099) can0 100 [8] 00 00 00 00 00 00 64 00"
|
|
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want *CanFrame
|
|
}{
|
|
// TODO: Add test cases.
|
|
{
|
|
name: "Candump parsing test",
|
|
args: args{text: &dump},
|
|
want: &CanFrame{
|
|
canid: 100,
|
|
date: "2022-07-08 16:54:15.587099",
|
|
payload: []uint8{0, 0, 0, 0, 0, 0, 0x64, 0},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := FromString(tt.args.text); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("FromString() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|