diff --git a/Makefile b/Makefile index f61b862..0e8274a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ BIN := bin CLIENT := ${BIN}/client GOPATH ?= ${PWD} -all: client +all: test client client: ${CLIENT} @@ -11,6 +11,9 @@ ${CLIENT}: ${SRC} @echo build $@ @GOPATH=${GOPATH} go build -o $@ -- main/client.go +test: + @GOPATH=${GOPATH} go test + clean: @echo clean ${BIN} @rm -f ${BIN}/* diff --git a/utils_test.go b/utils_test.go new file mode 100644 index 0000000..36f468d --- /dev/null +++ b/utils_test.go @@ -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+"'") + } +}