ms-runner/runner/runner_test.go
2024-06-22 21:29:19 +05:00

33 lines
724 B
Go

package runner
import (
"testing"
)
type ENTestPair struct {
test string
result []int
}
var ENTests = []ENTestPair {
{"123", []int{123}},
{"abc123abc", []int{123}},
{"", []int{}},
{"0", []int{0}},
{"1a2a3a6", []int{1, 2, 3, 6}},
}
func TestExtractNumbers(t *testing.T) {
for _, test := range(ENTests) {
result := extractNumbers(test.test)
if(len(result) != len(test.result)) {
t.Error("for", test.test, "expected", test.result, "got", result)
}
for i := 0; i < len(result); i++ {
if(result[i] != test.result[i]) {
t.Error("for", test.test, "expected", test.result, "got", result)
}
}
}
}