-
Notifications
You must be signed in to change notification settings - Fork 159
/
tile_test.go
53 lines (43 loc) · 1.27 KB
/
tile_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
package main
import (
"testing"
// "github.com/stretchr/testify/assert"
)
func Test_makeTile(t *testing.T) {
// func makeTile(vars map[string]string) (Tile, error) {
serverBounds, _ := getServerBounds()
var tests = []struct {
input map[string]string
outtile Tile
outerr error
}{
{
map[string]string{"x": "0", "y": "0", "z": "0", "ext": "pbf"},
Tile{X: 0, Y: 0, Zoom: 0, Ext: "pbf", Bounds: *serverBounds},
nil,
},
}
for _, test := range tests {
if output, err := makeTile(test.input); test.outtile != output || test.outerr != err {
t.Error("Test Failed: {} inputted, {} expected, recieved: {}, {}", test.input, test.outtile, output, err)
}
}
}
func Test_tileIsValid(t *testing.T) {
// func makeTile(vars map[string]string) (Tile, error) {
var tests = []struct {
input Tile
output bool
}{
{Tile{X: 0, Y: 0, Zoom: 0, Ext: "pbf"}, true},
{Tile{X: 0, Y: 1, Zoom: 0, Ext: "pbf"}, false},
{Tile{X: 1, Y: 1, Zoom: 1, Ext: "pbf"}, true},
{Tile{X: -1, Y: 0, Zoom: 0, Ext: "pbf"}, false},
{Tile{X: 0, Y: 0, Zoom: -1, Ext: "pbf"}, false},
}
for _, test := range tests {
if output := test.input.IsValid(); output != test.output {
t.Error("Test Failed: {} inputted, {} expected, recieved: {}", test.input, test.output, output)
}
}
}