Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
{"John", "john00@mail.com", "john_newyork@mail.com", "johnsmith@mail.com"},
24-
{"John", "johnnybravo@mail.com"}, {"Mary", "mary@mail.com"},
25+
{"John", "johnnybravo@mail.com"},
26+
{"Mary", "mary@mail.com"},
27+
},
28+
},
29+
{
30+
input: [][]string{
31+
{"Alex", "Alex5@m.co", "Alex4@m.co", "Alex0@m.co"},
32+
{"Ethan", "Ethan3@m.co", "Ethan3@m.co", "Ethan0@m.co"},
33+
{"Kevin", "Kevin4@m.co", "Kevin2@m.co", "Kevin2@m.co"},
34+
{"Gabe", "Gabe0@m.co", "Gabe3@m.co", "Gabe2@m.co"},
35+
{"Gabe", "Gabe3@m.co", "Gabe4@m.co", "Gabe2@m.co"},
36+
},
37+
expected: [][]string{
38+
{"Alex", "Alex0@m.co", "Alex4@m.co", "Alex5@m.co"},
39+
{"Ethan", "Ethan0@m.co", "Ethan3@m.co"},
40+
{"Gabe", "Gabe0@m.co", "Gabe2@m.co", "Gabe3@m.co", "Gabe4@m.co"},
41+
{"Kevin", "Kevin2@m.co", "Kevin4@m.co"},
42+
},
43+
},
44+
{
45+
input: [][]string{
46+
{"David", "David0@m.co", "David4@m.co", "David3@m.co"},
47+
{"David", "David5@m.co", "David5@m.co", "David0@m.co"},
48+
{"David", "David1@m.co", "David4@m.co", "David0@m.co"},
49+
{"David", "David0@m.co", "David1@m.co", "David3@m.co"},
50+
{"David", "David4@m.co", "David1@m.co", "David3@m.co"},
51+
},
52+
expected: [][]string{
53+
{"David", "David0@m.co", "David1@m.co", "David3@m.co", "David4@m.co", "David5@m.co"},
54+
},
55+
},
56+
{
57+
input: [][]string{
58+
{"David", "David0@m.co", "David1@m.co"},
59+
{"David", "David3@m.co", "David4@m.co"},
60+
{"David", "David4@m.co", "David5@m.co"},
61+
{"David", "David2@m.co", "David3@m.co"},
62+
{"David", "David1@m.co", "David2@m.co"},
63+
},
64+
expected: [][]string{
65+
{"David", "David0@m.co", "David1@m.co", "David2@m.co", "David3@m.co", "David4@m.co", "David5@m.co"},
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)

AltStyle によって変換されたページ (->オリジナル) /