add utils_test
This commit is contained in:
parent
95f1f68142
commit
d002be5074
5
Makefile
5
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}/*
|
||||
|
18
utils_test.go
Normal file
18
utils_test.go
Normal 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+"'")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user