forked from go-spatial/tegola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache_test.go
56 lines (51 loc) · 957 Bytes
/
cache_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
53
54
55
56
package cache_test
import (
"reflect"
"testing"
"github.com/terranodo/tegola/cache"
)
func TestParseKey(t *testing.T) {
testcases := []struct {
input string
expected *cache.Key
}{
{
input: "/12/11/123",
expected: &cache.Key{
Z: 12,
X: 11,
Y: 123,
},
},
{
input: "/osm/12/11/123",
expected: &cache.Key{
Z: 12,
X: 11,
Y: 123,
MapName: "osm",
},
},
{
input: "/osm/buildings/12/11/123",
expected: &cache.Key{
Z: 12,
X: 11,
Y: 123,
MapName: "osm",
LayerName: "buildings",
},
},
}
for i, tc := range testcases {
output, err := cache.ParseKey(tc.input)
if err != nil {
t.Errorf("testcase (%v) failed. err: %v", i, err)
continue
}
if !reflect.DeepEqual(tc.expected, output) {
t.Errorf("testcase (%v) failed. expected (%+v) does not match output (%+v)", i, tc.expected, output)
continue
}
}
}