diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-02-15 14:01:22 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-02-15 14:01:22 +0200 |
commit | db0b8124a5b5a5671ec67eef75e4288461f5d0c9 (patch) | |
tree | 9de71ad3a9d28b0ba0810383f07ad4953a67384e /args_test.go | |
parent | Do not copy body stream in Request.CopyTo to be consistent with Response.CopyTo (diff) | |
download | fasthttp-db0b8124a5b5a5671ec67eef75e4288461f5d0c9.tar.gz fasthttp-db0b8124a5b5a5671ec67eef75e4288461f5d0c9.tar.bz2 fasthttp-db0b8124a5b5a5671ec67eef75e4288461f5d0c9.zip |
Added Args.PeekMulti for obtaining multiple query arg values for the given key
Diffstat (limited to 'args_test.go')
-rw-r--r-- | args_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/args_test.go b/args_test.go index e677677..b93f30f 100644 --- a/args_test.go +++ b/args_test.go @@ -2,10 +2,37 @@ package fasthttp import ( "fmt" + "reflect" "strings" "testing" ) +func TestPeekMulti(t *testing.T) { + var a Args + a.Parse("foo=123&bar=121&foo=321&foo=&barz=sdf") + + vv := a.PeekMulti("foo") + expectedVV := [][]byte{ + []byte("123"), + []byte("321"), + []byte(nil), + } + if !reflect.DeepEqual(vv, expectedVV) { + t.Fatalf("unexpected vv\n%#v\nExpecting\n%#v\n", vv, expectedVV) + } + + vv = a.PeekMulti("aaaa") + if len(vv) > 0 { + t.Fatalf("expecting empty result for non-existing key. Got %#v", vv) + } + + vv = a.PeekMulti("bar") + expectedVV = [][]byte{[]byte("121")} + if !reflect.DeepEqual(vv, expectedVV) { + t.Fatalf("unexpected vv\n%#v\nExpecting\n%#v\n", vv, expectedVV) + } +} + func TestArgsEscape(t *testing.T) { testArgsEscape(t, "foo", "bar", "foo=bar") testArgsEscape(t, "f.o,1:2/4", "~`!@#$%^&*()_-=+\\|/[]{};:'\"<>,./?", |