Skip to content

Commit 84f988d

Browse files
author
openset
committed
Add: test case
1 parent d64419b commit 84f988d

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

problems/accounts-merge/accounts_merge_test.go

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package accounts_merge
22

33
import (
44
"reflect"
5+
"sort"
56
"testing"
67
)
78

@@ -21,12 +22,58 @@ func TestAccountsMerge(t *testing.T) {
2122
},
2223
expected: [][]string{
2324
24-
{"John", "[email protected]"}, {"Mary", "[email protected]"},
25+
{"John", "[email protected]"},
26+
{"Mary", "[email protected]"},
27+
},
28+
},
29+
{
30+
input: [][]string{
31+
32+
33+
34+
35+
36+
},
37+
expected: [][]string{
38+
39+
40+
41+
42+
},
43+
},
44+
{
45+
input: [][]string{
46+
47+
48+
49+
50+
51+
},
52+
expected: [][]string{
53+
54+
},
55+
},
56+
{
57+
input: [][]string{
58+
59+
60+
61+
62+
63+
},
64+
expected: [][]string{
65+
2566
},
2667
},
2768
}
2869
for _, tc := range tests {
2970
output := accountsMerge(tc.input)
71+
sort.Slice(output, func(i, j int) bool {
72+
if output[i][0] == output[i][0] {
73+
return output[i][1] < output[j][1]
74+
}
75+
return output[i][0] < output[i][0]
76+
})
3077
if !reflect.DeepEqual(output, tc.expected) {
3178
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
3279
}

0 commit comments

Comments
 (0)