aboutsummaryrefslogtreecommitdiff
path: root/args_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-19 12:27:01 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-19 12:27:01 +0200
commitb5a101843a33d0cb579346b910c3ca092ba043db (patch)
tree69db9faa877969a612c5d43675a4099d6a933d12 /args_test.go
parentOptimization: do not parse full requests headers on ConnectionClose and Heade... (diff)
downloadfasthttp-b5a101843a33d0cb579346b910c3ca092ba043db.tar.gz
fasthttp-b5a101843a33d0cb579346b910c3ca092ba043db.tar.bz2
fasthttp-b5a101843a33d0cb579346b910c3ca092ba043db.zip
Added SetUint helper to Args
Diffstat (limited to 'args_test.go')
-rw-r--r--args_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/args_test.go b/args_test.go
index 311dc36..c12c60c 100644
--- a/args_test.go
+++ b/args_test.go
@@ -6,6 +6,39 @@ import (
"testing"
)
+func TestArgsUint(t *testing.T) {
+ var a Args
+ a.SetUint("foo", 123)
+ a.SetUint("bar", 0)
+ a.SetUint("aaaa", 34566)
+
+ expectedS := "foo=123&bar=0&aaaa=34566"
+ s := string(a.AppendBytes(nil))
+ if s != expectedS {
+ t.Fatalf("unexpected args %q. Expecting %q", s, expectedS)
+ }
+
+ if a.GetUintOrZero("foo") != 123 {
+ t.Fatalf("unexpected arg value %d. Expecting %d", a.GetUintOrZero("foo"), 123)
+ }
+ if a.GetUintOrZero("bar") != 0 {
+ t.Fatalf("unexpected arg value %d. Expecting %d", a.GetUintOrZero("bar"), 0)
+ }
+ if a.GetUintOrZero("aaaa") != 34566 {
+ t.Fatalf("unexpected arg value %d. Expecting %d", a.GetUintOrZero("aaaa"), 34566)
+ }
+
+ if string(a.Peek("foo")) != "123" {
+ t.Fatalf("unexpected arg value %q. Expecting %q", a.Peek("foo"), "123")
+ }
+ if string(a.Peek("bar")) != "0" {
+ t.Fatalf("unexpected arg value %q. Expecting %q", a.Peek("bar"), "0")
+ }
+ if string(a.Peek("aaaa")) != "34566" {
+ t.Fatalf("unexpected arg value %q. Expecting %q", a.Peek("aaaa"), "34566")
+ }
+}
+
func TestArgsCopyTo(t *testing.T) {
var a Args