diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-01-04 14:23:07 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-01-04 14:23:07 +0200 |
commit | 9b0b87c951bd88a3e579d8f0a9ee5880920e9a65 (patch) | |
tree | abbb2b04a6d845b6be1ee5660ed531daa23ca735 /uri_test.go | |
parent | Added short term TODO items (diff) | |
download | fasthttp-9b0b87c951bd88a3e579d8f0a9ee5880920e9a65.tar.gz fasthttp-9b0b87c951bd88a3e579d8f0a9ee5880920e9a65.tar.bz2 fasthttp-9b0b87c951bd88a3e579d8f0a9ee5880920e9a65.zip |
Added URI.LastPathSegment helper function
Diffstat (limited to 'uri_test.go')
-rw-r--r-- | uri_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/uri_test.go b/uri_test.go index 687c2cf..71191cd 100644 --- a/uri_test.go +++ b/uri_test.go @@ -5,6 +5,23 @@ import ( "testing" ) +func TestLastPathSegment(t *testing.T) { + testLastPathSegment(t, "", "") + testLastPathSegment(t, "/", "") + testLastPathSegment(t, "/foo/bar/", "") + testLastPathSegment(t, "/foobar.js", "foobar.js") + testLastPathSegment(t, "/foo/bar/baz.html", "baz.html") +} + +func testLastPathSegment(t *testing.T, path, expectedSegment string) { + var u URI + u.SetPath(path) + segment := u.LastPathSegment() + if string(segment) != expectedSegment { + t.Fatalf("unexpected last path segment for path %q: %q. Expecting %q", path, segment, expectedSegment) + } +} + func TestURIPathEscape(t *testing.T) { testURIPathEscape(t, "/foo/bar", "/foo/bar") testURIPathEscape(t, "/f_o-o=b:ar,b.c&q", "/f_o-o=b:ar,b.c&q") |