Improved test coverage

This commit is contained in:
2023-09-06 16:52:22 +02:00
parent bd91077f83
commit 3008940025
5 changed files with 80 additions and 71 deletions

12
Tree.go
View File

@ -130,6 +130,8 @@ begin:
return node.data
}
// node: /|*any
// path: /|image.png
if lastWildcard != nil {
addParameter(lastWildcard.prefix, path[lastWildcardOffset:])
return lastWildcard.data
@ -193,9 +195,9 @@ begin:
// node: /|*any
// path: /|image.png
if node.wildcard != nil {
addParameter(node.wildcard.prefix, path[i:])
return node.wildcard.data
if lastWildcard != nil {
addParameter(lastWildcard.prefix, path[lastWildcardOffset:])
return lastWildcard.data
}
return empty
@ -217,8 +219,8 @@ begin:
}
}
// Bind binds all handlers to a new one provided by the callback.
func (tree *Tree[T]) Bind(transform func(T) T) {
// Map binds all handlers to a new one provided by the callback.
func (tree *Tree[T]) Map(transform func(T) T) {
tree.root.each(func(node *treeNode[T]) {
node.data = transform(node.data)
})