Updated actions, fix some lint issues and introduce translate package
testing / check and test (push) Failing after 9m19s

This commit is contained in:
2024-04-13 02:40:32 +00:00
parent d05fa2e90a
commit 04c5f52e6f
8 changed files with 128 additions and 35 deletions
+32
View File
@@ -0,0 +1,32 @@
package tiles
import (
"fmt"
"log"
"reflect"
"testing"
)
func TestShortToArray(t *testing.T) {
type testcase struct {
Name string
Arg string
Want []string
}
testcases := []testcase{
{Name: "自创格式", Arg: "12W56T456B1234567Z", Want: []string{"1W", "2W", "5T", "6T", "4B", "5B", "6B", "DO", "XI", "NA", "BE", "ZH", "FA", "BA"}},
{Name: "日麻格式", Arg: "1134m4p24s123677z6m", Want: []string{"1W", "1W", "3W", "4W", "4B", "2T", "4T", "DO", "NA", "XI", "FA", "ZH", "ZH", "6W"}},
}
for _, tc := range testcases {
t.Run(tc.Name, func(t *testing.T) {
result, err := shortToArray(tc.Arg)
if err != nil {
log.Fatalf("Failed in translating tiles %s , error: %s", tc.Arg, err)
}
fmt.Println(result)
if !reflect.DeepEqual(result, tc.Want) {
log.Fatalf("Failed in translating tiles %s , expectd: %v, got %v", tc.Arg, tc.Want, result)
}
})
}
}