diff --git a/trees/avltree/avltree_test.go b/trees/avltree/avltree_test.go index ce27d6a..114b5a5 100644 --- a/trees/avltree/avltree_test.go +++ b/trees/avltree/avltree_test.go @@ -269,15 +269,8 @@ func TestAVLTreeIterator1Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -308,15 +301,8 @@ func TestAVLTreeIterator1Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -335,15 +321,8 @@ func TestAVLTreeIterator2Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -362,15 +341,8 @@ func TestAVLTreeIterator2Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -387,15 +359,8 @@ func TestAVLTreeIterator3Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -412,15 +377,8 @@ func TestAVLTreeIterator3Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -456,15 +414,8 @@ func TestAVLTreeIterator4Next(t *testing.T) { for it.Next() { count++ value := it.Value() - switch value { - case count: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := value, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -500,15 +451,8 @@ func TestAVLTreeIterator4Prev(t *testing.T) { } for it.Prev() { value := it.Value() - switch value { - case count: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := value, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } count-- } diff --git a/trees/btree/btree_test.go b/trees/btree/btree_test.go index f8b6e61..c0a5c32 100644 --- a/trees/btree/btree_test.go +++ b/trees/btree/btree_test.go @@ -749,15 +749,8 @@ func TestBTreeIterator1Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -781,15 +774,8 @@ func TestBTreeIterator1Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -808,15 +794,8 @@ func TestBTreeIterator2Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -835,15 +814,8 @@ func TestBTreeIterator2Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -860,15 +832,8 @@ func TestBTreeIterator3Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -885,15 +850,8 @@ func TestBTreeIterator3Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -919,15 +877,8 @@ func TestBTreeIterator4Next(t *testing.T) { for it.Next() { count++ value := it.Value() - switch value { - case count: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := value, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -953,15 +904,8 @@ func TestBTreeIterator4Prev(t *testing.T) { } for it.Prev() { value := it.Value() - switch value { - case count: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := value, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } count-- } diff --git a/trees/redblacktree/redblacktree_test.go b/trees/redblacktree/redblacktree_test.go index 5de39b6..4c0f519 100644 --- a/trees/redblacktree/redblacktree_test.go +++ b/trees/redblacktree/redblacktree_test.go @@ -271,15 +271,8 @@ func TestRedBlackTreeIterator1Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -310,15 +303,8 @@ func TestRedBlackTreeIterator1Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -337,15 +323,8 @@ func TestRedBlackTreeIterator2Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -364,15 +343,8 @@ func TestRedBlackTreeIterator2Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -389,15 +361,8 @@ func TestRedBlackTreeIterator3Next(t *testing.T) { for it.Next() { count++ key := it.Key() - switch key { - case count: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -414,15 +379,8 @@ func TestRedBlackTreeIterator3Prev(t *testing.T) { countDown := tree.size for it.Prev() { key := it.Key() - switch key { - case countDown: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := key, countDown; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := key, countDown; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } countDown-- } @@ -458,15 +416,8 @@ func TestRedBlackTreeIterator4Next(t *testing.T) { for it.Next() { count++ value := it.Value() - switch value { - case count: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := value, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } } if actualValue, expectedValue := count, tree.Size(); actualValue != expectedValue { @@ -502,15 +453,8 @@ func TestRedBlackTreeIterator4Prev(t *testing.T) { } for it.Prev() { value := it.Value() - switch value { - case count: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } - default: - if actualValue, expectedValue := value, count; actualValue != expectedValue { - t.Errorf("Got %v expected %v", actualValue, expectedValue) - } + if actualValue, expectedValue := value, count; actualValue != expectedValue { + t.Errorf("Got %v expected %v", actualValue, expectedValue) } count-- }