Skip to content

Commit

Permalink
moving tests around
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsole committed Jul 23, 2023
1 parent 8a3a6e5 commit 5f538d2
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,32 @@ package utils
import "testing"

func TestParse(t *testing.T) {
z, x, y, err := utils.ParsePath("/tile/4/3/2.png")
z, x, y, ext, err := ParsePath("/tile/4/3/2.webp")
if err != nil {
t.Error(err)
}
if z != 4 || x != 3 || y != 2 {
if z != 4 || x != 3 || y != 2 || ext != "webp" {
t.Fail()
}
}

func TestParseError(t *testing.T) {
invalid_paths := []string{
"/tile/4/3/2",
"/tile/4/3/2.jpg",
"/tile/4/3/2.png/",
"/tile/4/3/2.png/3",
"/tile/4/3/2.png/3/4",
"/tile/-1/3/2.png",
"/tile/1.5/3/2.png",
"/tile/10000/3.5/2.png",
"/tile/100000000000000000000000000000000000000000000000000000000000000000/3/2.5.png",
"/tile/abc/3/2.png",
}
for _, path := range invalid_paths {
_, _, _, _, err := ParsePath(path)
if err == nil {
t.Errorf("expected error for path %s", path)
}
}
}

0 comments on commit 5f538d2

Please sign in to comment.