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