2024-04-07 20:59:41 +01:00
|
|
|
package cif
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestParseSpeed(t *testing.T) {
|
|
|
|
testCases := []struct {
|
2024-04-07 21:28:48 +01:00
|
|
|
input string
|
2024-04-07 20:59:41 +01:00
|
|
|
expected int32
|
|
|
|
}{
|
2024-04-07 21:28:48 +01:00
|
|
|
{"075", 75},
|
|
|
|
{"125", 125},
|
|
|
|
{"40", 40},
|
|
|
|
{"040", 40},
|
|
|
|
{"134", 60},
|
|
|
|
{"179", 80},
|
|
|
|
{"186", 186},
|
|
|
|
{"417", 186},
|
2024-04-07 20:59:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
2024-04-07 21:28:48 +01:00
|
|
|
result := parseSpeed(&tc.input)
|
2024-04-07 20:59:41 +01:00
|
|
|
|
|
|
|
if result != tc.expected {
|
|
|
|
t.Errorf("For speed: %s, expected: %d, but got: %d", tc.input, tc.expected, result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|