1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
package sdkuri
import "testing"
func TestPathJoin(t *testing.T) {
cases := []struct {
Elems []string
Expect string
}{
{Elems: []string{"/"}, Expect: "/"},
{Elems: []string{}, Expect: ""},
{Elems: []string{"blah", "el", "blah/"}, Expect: "blah/el/blah/"},
{Elems: []string{"/asd", "asdfa", "asdfasd/"}, Expect: "/asd/asdfa/asdfasd/"},
{Elems: []string{"asdfa", "asdfa", "asdfads"}, Expect: "asdfa/asdfa/asdfads"},
}
for _, c := range cases {
if e, a := c.Expect, PathJoin(c.Elems...); e != a {
t.Errorf("expect %v, got %v", e, a)
}
}
}
|