-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroute_trie_test.go
52 lines (44 loc) · 1.05 KB
/
route_trie_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
45
46
47
48
49
50
51
52
package hasty
import (
"testing"
)
func TestSplitInTwo(t *testing.T) {
a, b := SplitInTwo("my/dummy/path", "/")
if a != "my" {
t.Error("First Part doesn't matches")
}
if b != "dummy/path" {
t.Error("Second Part doesn't matches")
}
a, b = SplitInTwo("mypath", "/")
if b != "" {
t.Error("Second part should be empty")
}
}
func TestRootRouteTrie(t *testing.T) {
rt := rootRouteTrie()
if rt.token != "" {
t.Error("Root Route is not an empty string")
}
if rt.pattern == true {
t.Error("Root Route is pattern based")
}
}
func TestNewRouteTrieWithoutPattern(t *testing.T) {
rt := newRouteTrie("article")
if rt.token != "article" {
t.Error("Root trie path and token doesn't match")
}
if rt.pattern == true {
t.Error("Pattern based route trie from non-pattern based path")
}
}
func TestNewRouteTrieWithPattern(t *testing.T) {
rt := newRouteTrie(":articleName")
if rt.token != "articleName" {
t.Error("Root trie path and token doesn't match")
}
if rt.pattern != true {
t.Error("Not a pattern based route trie from pattern based path")
}
}