timetable-mgr/cif/convert_test.go
Fred Boniface 4a7bcd7f80
Some checks failed
Go Test / test (push) Failing after 1m26s
Increase use of pointers to minimise memory usage
2024-04-07 20:59:41 +01:00

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
}