-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathremove_test.go
44 lines (32 loc) · 901 Bytes
/
remove_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
38
39
40
41
42
43
44
// Copyright 2016 David Lavieri. All rights reserved.
// Use of this source code is governed by a MIT License
// License that can be found in the LICENSE file.
package goradix
import "testing"
func TestRemove(t *testing.T) {
rx := New(false)
insertData(rx, sampleData)
rx.Remove("slow")
if rx.nodes[1].key {
t.Fatal("Expected node to not be key")
}
if rx.nodes[1].value != nil {
t.Fatalf("Expected node value to be nil; Got: %v", rx.nodes[1].value)
}
}
func TestRemoveChild(t *testing.T) {
rx := New(false)
insertData(rx, sampleData)
rx.Remove("test")
if len(rx.nodes[0].nodes) != 1 {
t.Fatalf("Expected node to have only 1 child; Got: %d", len(rx.nodes[0].nodes))
}
}
func TestRemoveChildMerge(t *testing.T) {
rx := New(false)
insertData(rx, sampleData)
rx.Remove("slow")
if string(rx.nodes[1].Path) != "slowly" {
t.Fatal("Expected child node to be merged")
}
}