32 lines
559 B
Go
32 lines
559 B
Go
package cif
|
|
|
|
import "testing"
|
|
|
|
func TestParseSpeed(t *testing.T) {
|
|
testCases := []struct {
|
|
input *string
|
|
expected int32
|
|
}{
|
|
{strPtr("075"), 75},
|
|
{strPtr("125"), 125},
|
|
{strPtr("40"), 40},
|
|
{strPtr("040"), 40},
|
|
{strPtr("134"), 60},
|
|
{strPtr("179"), 80},
|
|
{strPtr("186"), 186},
|
|
{strPtr("417"), 186},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
result := parseSpeed(tc.input)
|
|
|
|
if result != tc.expected {
|
|
t.Errorf("For speed: %s, expected: %d, but got: %d", tc.input, tc.expected, result)
|
|
}
|
|
}
|
|
}
|
|
|
|
func strPtr(s string) *string {
|
|
return &s
|
|
}
|