From d002be5074476eb7928248f78fea69a1b4db5b74 Mon Sep 17 00:00:00 2001 From: Christoph Polcin Date: Thu, 23 Oct 2014 11:15:28 +0200 Subject: [PATCH] add utils_test --- Makefile | 5 ++++- utils_test.go | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 utils_test.go 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+"'") + } +}