2023-12-04 17:23:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-12-04 18:45:30 +00:00
|
|
|
"strings"
|
2023-12-04 17:23:02 +00:00
|
|
|
"testing"
|
2023-12-04 18:45:30 +00:00
|
|
|
"unicode"
|
2023-12-04 17:23:02 +00:00
|
|
|
|
2023-12-04 18:45:30 +00:00
|
|
|
"github.com/go-playground/assert"
|
2023-12-04 17:23:02 +00:00
|
|
|
)
|
|
|
|
|
2023-12-04 18:45:30 +00:00
|
|
|
func TestCompare(t *testing.T) {
|
2023-12-04 17:23:02 +00:00
|
|
|
//t.Skip("skipping test")
|
|
|
|
|
2023-12-05 01:47:44 +00:00
|
|
|
winning1 := "41 48 83 86 17"
|
|
|
|
mynums1 := "83 86 6 31 17 9 48 53"
|
2023-12-04 18:45:30 +00:00
|
|
|
|
2023-12-05 01:47:44 +00:00
|
|
|
winning2 := "13 32 20 16 61"
|
|
|
|
mynums2 := "61 30 68 82 17 32 24 19"
|
2023-12-04 18:45:30 +00:00
|
|
|
|
|
|
|
f := func(c rune) bool {
|
|
|
|
return !unicode.IsDigit(c)
|
|
|
|
}
|
|
|
|
res1, _ := compare(strings.FieldsFunc(winning1, f), strings.FieldsFunc(mynums1, f))
|
|
|
|
res2, _ := compare(strings.FieldsFunc(winning2, f), strings.FieldsFunc(mynums2, f))
|
|
|
|
|
|
|
|
t.Run("Should return 4 matches", func(t *testing.T) {
|
|
|
|
assert.Equal(t, 4, res1)
|
2023-12-04 17:23:02 +00:00
|
|
|
})
|
|
|
|
|
2023-12-04 18:45:30 +00:00
|
|
|
t.Run("Should return 2 matches", func(t *testing.T) {
|
|
|
|
assert.Equal(t, 2, res2)
|
2023-12-04 17:23:02 +00:00
|
|
|
})
|
|
|
|
}
|