Skip to content

Commit

Permalink
fix(tree): incorrect expected value in bstree tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HotPotatoC committed Apr 15, 2022
1 parent 9a0d9cd commit 7df8ad3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tree/bstree_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tree_test

import (
"reflect"
"testing"

"github.com/HotPotatoC/sture"
Expand Down Expand Up @@ -114,8 +113,10 @@ func TestBSTree_Inorder(t *testing.T) {
list := bst.Inorder()
exp := []int{1, 3, 4, 6, 10}

if !reflect.DeepEqual(list, exp) {
t.Errorf("bst.Inorder() = %v, want %v", list, exp)
for i, v := range list {
if v.Key() != exp[i] && v.Value() != exp[i] {
t.Errorf("bst.Inorder()[%d] = %v, want %v", i, v, exp[i])
}
}
}

Expand All @@ -131,8 +132,10 @@ func TestBSTree_Preorder(t *testing.T) {
list := bst.Preorder()
exp := []int{3, 1, 10, 6, 4}

if !reflect.DeepEqual(list, exp) {
t.Errorf("bst.Preorder() = %v, want %v", list, exp)
for i, v := range list {
if v.Key() != exp[i] && v.Value() != exp[i] {
t.Errorf("bst.Inorder()[%d] = %v, want %v", i, v, exp[i])
}
}
}

Expand All @@ -148,7 +151,9 @@ func TestBSTree_Postorder(t *testing.T) {
list := bst.Postorder()
exp := []int{1, 4, 6, 10, 3}

if !reflect.DeepEqual(list, exp) {
t.Errorf("bst.Postorder() = %v, want %v", list, exp)
for i, v := range list {
if v.Key() != exp[i] && v.Value() != exp[i] {
t.Errorf("bst.Inorder()[%d] = %v, want %v", i, v, exp[i])
}
}
}

0 comments on commit 7df8ad3

Please sign in to comment.