示例#1
0
func checkNode(t *testing.T, node trie.Node, size int, data nodeData) {
	if node == nil {
		t.Error("Nil node:", data)
	}
	if node.Size() != size {
		t.Errorf("Unexpected childrens: %d != %d", node.Size(), size)
	}
	d := node.Value().(*nodeData)
	if d == nil {
		t.Error("Nil data:", data, node)
	}
	if data.pattern != nil && *d.pattern != *data.pattern {
		t.Error("Pattern unmatched:", data, node, *d.pattern)
	}
	if data.value != nil && d.value != data.value {
		t.Error("Value unmatched:", data, node, d.value)
	}
	if d.failure == nil {
		t.Error("Nil failure:", data, node)
	} else if d.failure != data.failure {
		t.Errorf("Failure unmatched: data=%+v node=%+v d.failure=%+v",
			data, node, d.failure)
	}
}