From 439fd333a6a2de65aec3b83ec33ced036c99f0f0 Mon Sep 17 00:00:00 2001 From: fengzw Date: Thu, 17 Jun 2021 22:38:07 +0800 Subject: [PATCH] fix: some bugs in testcases of pattern16 challenge2 --- .../Challenge2/solution_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Pattern16 - Topological Sort/Challenge2/solution_test.go b/Pattern16 - Topological Sort/Challenge2/solution_test.go index c086ed8..da82a09 100644 --- a/Pattern16 - Topological Sort/Challenge2/solution_test.go +++ b/Pattern16 - Topological Sort/Challenge2/solution_test.go @@ -1,7 +1,6 @@ package Challenge2 import ( - "reflect" "testing" ) @@ -24,7 +23,15 @@ func Test_findMinHeightTrees(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := findMinHeightTrees(tt.args.n, tt.args.edges); !reflect.DeepEqual(got, tt.want) { + m := make(map[int]int) + got := findMinHeightTrees(tt.args.n, tt.args.edges) + for _, v := range got { + m[v] = 1 + } + for _, v := range tt.want { + delete(m, v) + } + if len(m) != 0 { t.Errorf("findMinHeightTrees() = %v, want %v", got, tt.want) } })