aboutsummaryrefslogtreecommitdiff
path: root/args_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-19 12:51:34 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-19 12:51:34 +0200
commit48c0f89ee7a350b601a62a524fca875afe5138bb (patch)
tree42a839d590922647a372c9db80e383eb8cbfc683 /args_test.go
parentAdded SetUint helper to Args (diff)
downloadfasthttp-48c0f89ee7a350b601a62a524fca875afe5138bb.tar.gz
fasthttp-48c0f89ee7a350b601a62a524fca875afe5138bb.tar.bz2
fasthttp-48c0f89ee7a350b601a62a524fca875afe5138bb.zip
Added Stringer implementations to URI, Args and Cookie
Diffstat (limited to 'args_test.go')
-rw-r--r--args_test.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/args_test.go b/args_test.go
index c12c60c..fd0831b 100644
--- a/args_test.go
+++ b/args_test.go
@@ -1,11 +1,32 @@
package fasthttp
import (
+ "bytes"
"fmt"
"strings"
"testing"
)
+func TestArgsWriteTo(t *testing.T) {
+ s := "foo=bar&baz=123&aaa=bbb"
+
+ var a Args
+ a.Parse(s)
+
+ var w bytes.Buffer
+ n, err := a.WriteTo(&w)
+ if err != nil {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if n != int64(len(s)) {
+ t.Fatalf("unexpected n: %d. Expecting %d", n, len(s))
+ }
+ result := string(w.Bytes())
+ if result != s {
+ t.Fatalf("unexpected result %q. Expecting %q", result, s)
+ }
+}
+
func TestArgsUint(t *testing.T) {
var a Args
a.SetUint("foo", 123)
@@ -13,7 +34,7 @@ func TestArgsUint(t *testing.T) {
a.SetUint("aaaa", 34566)
expectedS := "foo=123&bar=0&aaaa=34566"
- s := string(a.AppendBytes(nil))
+ s := string(a.QueryString())
if s != expectedS {
t.Fatalf("unexpected args %q. Expecting %q", s, expectedS)
}