-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtick_test.go
36 lines (30 loc) · 881 Bytes
/
tick_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
package ibt
import "testing"
func TestGetTickValue(t *testing.T) {
testTick := Tick{
"Speed": float32(103.23),
"Gear": 5,
"Flag": "0x3421",
}
t.Run("test normal scenario", func(t *testing.T) {
value, err := GetTickValue[int](testTick, "Gear")
if err != nil {
t.Errorf("expected err to be nil but received: %v", err)
}
if value != 5 {
t.Errorf("expected return Gear value to be %d. received: %d", 5, value)
}
})
t.Run("test missing key", func(t *testing.T) {
_, err := GetTickValue[int](testTick, "NotFound")
if err == nil {
t.Errorf("expected an error to occur when retrieving value for key %s", "NotFound")
}
})
t.Run("test missing key", func(t *testing.T) {
_, err := GetTickValue[int](testTick, "Speed")
if err == nil {
t.Errorf("expected an error to occur when retrieving value for key %s with type int", "Speed")
}
})
}