@@ -2,6 +2,7 @@ package accounts_merge
22
33import (
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