-
Notifications
You must be signed in to change notification settings - Fork 2
/
join_test.go
37 lines (35 loc) · 781 Bytes
/
join_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package splaytree
import "testing"
func TestJoin(t *testing.T) {
fir := NewSplayTree()
oak := NewSplayTree()
it1 := []Item{Int(6), Int(4), Int(2), Int(5), Int(3), Int(7), Int(0)}
it2 := []Item{Int(-1), Int(14), Int(-2), Int(15), Int(-3), Int(17), Int(10)}
fir.InsertAll(it1)
fir.Join(nil)
fir.Join(fir)
oak.InsertAll(it1)
fir.Join(oak)
if fir.Count() != len(it1) {
t.Errorf("join count !it1")
}
if oak.NonEmpty() {
t.Errorf("join oak !0")
}
fir.Check()
oak.InsertAll(it2)
fir.Join(oak)
if fir.Count() != len(it1)+len(it2) {
t.Errorf("join count !it1+it2")
}
if oak.NonEmpty() {
t.Errorf("join oak !0")
}
fir.Check()
for _, item := range append(it1, it2...) {
if fir.Lookup(item) == nil {
t.Errorf("join lookup !%v", item)
}
}
fir.Check()
}