-
Notifications
You must be signed in to change notification settings - Fork 41
/
utils_test.go
52 lines (39 loc) · 855 Bytes
/
utils_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
package elmobd
import (
"fmt"
"testing"
)
/*==============================================================================
* Utils
*/
func assert(t *testing.T, assertion bool, msg string) {
if assertion {
return
}
t.Fatal(fmt.Sprintf("Assertion %s failed", msg))
}
func assertEqual(t *testing.T, a interface{}, b interface{}) {
assert(
t,
a == b,
fmt.Sprintf("'%v == %v'", a, b),
)
}
func assertSuccess(t *testing.T, err error) {
assert(
t,
err == nil,
fmt.Sprintf("'err == nil' (%v)", err),
)
}
func assertOBDParseSuccess(t *testing.T, command OBDCommand, outputs []string) OBDCommand {
result, err := parseOBDResponse(command, outputs)
assertSuccess(t, err)
if result != nil {
err = result.Validate(command)
assertSuccess(t, err)
err = command.SetValue(result)
assertSuccess(t, err)
}
return command
}