add utils_test

This commit is contained in:
Christoph Polcin 2014-10-23 11:15:28 +02:00
parent 95f1f68142
commit d002be5074
2 changed files with 22 additions and 1 deletions

View File

@ -3,7 +3,7 @@ BIN := bin
CLIENT := ${BIN}/client CLIENT := ${BIN}/client
GOPATH ?= ${PWD} GOPATH ?= ${PWD}
all: client all: test client
client: ${CLIENT} client: ${CLIENT}
@ -11,6 +11,9 @@ ${CLIENT}: ${SRC}
@echo build $@ @echo build $@
@GOPATH=${GOPATH} go build -o $@ -- main/client.go @GOPATH=${GOPATH} go build -o $@ -- main/client.go
test:
@GOPATH=${GOPATH} go test
clean: clean:
@echo clean ${BIN} @echo clean ${BIN}
@rm -f ${BIN}/* @rm -f ${BIN}/*

18
utils_test.go Normal file
View File

@ -0,0 +1,18 @@
package gowebdav
import "testing"
func TestJoin(t *testing.T) {
eq(t, "/", "", "")
eq(t, "/", "/", "/")
eq(t, "/foo", "", "/foo")
eq(t, "foo/foo", "foo/", "/foo")
eq(t, "foo/foo", "foo/", "foo")
}
func eq(t *testing.T, expected string, s0 string, s1 string) {
s := Join(s0, s1)
if s != expected {
t.Error("For", "'"+s0+"','" + s1+"'", "expeted", "'"+ expected + "'", "got", "'"+s+"'")
}
}