MCPcopy Create free account
hub / github.com/EndlessCheng/codeforces-go / TestRunLeetCodeFunc

Function TestRunLeetCodeFunc

leetcode/testutil/leetcode_test.go:19–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17}
18
19func TestRunLeetCodeFunc(t *testing.T) {
20 specialF := func(a []string) []string {
21 fmt.Println("args:", a)
22 return a
23 }
24 // , in string slice
25 data := [][]string{{`["alice,20,800,mtv","alice,50,100,beijing"]`}}
26 if err := RunLeetCodeFunc(t, specialF, data, data); err != nil {
27 t.Error(err)
28 }
29
30 baseF := func(a string, b int, c float64, d bool, e byte) (string, int, float64, bool, byte) {
31 fmt.Println("args:", a, b, c, d, e)
32 return a, b, c, d, e
33 }
34 data = [][]string{{`"ac"`, `-123`, `1.23000`, `true`, `"a"`}}
35 if err := RunLeetCodeFunc(t, baseF, data, data); err != nil {
36 t.Error(err)
37 }
38
39 sliceF := func(a []string, b []int, c []float64, d []bool) ([]string, []int, []float64, []bool) {
40 fmt.Println("args:", a, b, c, d)
41 return a, b, c, d
42 }
43 data = [][]string{{`["ac","wa","tle"]`, `[-123,3,0,1]`, `[1.23000,3.00000]`, `[true,false,true]`}}
44 if err := RunLeetCodeFunc(t, sliceF, data, data); err != nil {
45 t.Error(err)
46 }
47 data = [][]string{{`[]`, `[]`, `[]`, `[]`}}
48 if err := RunLeetCodeFunc(t, sliceF, data, data); err != nil {
49 t.Error(err)
50 }
51
52 matrixF := func(a [][]string, b [][]int) ([][]string, [][]int) {
53 fmt.Println("args:", a, b)
54 return a, b
55 }
56 data = [][]string{{`[["ac","wa","tle"],["1"]]`, `[[-123,3,0,1],[1]]`}}
57 if err := RunLeetCodeFunc(t, matrixF, data, data); err != nil {
58 t.Error(err)
59 }
60 data = [][]string{{`[["ac"]]`, `[[-123]]`}}
61 if err := RunLeetCodeFunc(t, matrixF, data, data); err != nil {
62 t.Error(err)
63 }
64 data = [][]string{{`[[],[],[],[]]`, `[[],[]]`}}
65 if err := RunLeetCodeFunc(t, matrixF, data, data); err != nil {
66 t.Error(err)
67 }
68 data = [][]string{{`[[]]`, `[]`}}
69 if err := RunLeetCodeFunc(t, matrixF, data, data); err != nil {
70 t.Error(err)
71 }
72
73 treeNodeF := func(root *TreeNode) *TreeNode {
74 fmt.Println(root.toRawString())
75 return root
76 }

Callers

nothing calls this directly

Calls 2

RunLeetCodeFuncFunction · 0.85
toRawStringMethod · 0.45

Tested by

no test coverage detected