aboutsummaryrefslogtreecommitdiff
path: root/args_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2017-01-30 19:47:15 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2017-01-30 19:47:15 +0200
commitb69eba7101fa6c66ba4db0641968a401c9f4f148 (patch)
tree1c175e2b4da5d0b776423c29000525f89fc65de2 /args_test.go
parentDocument that the cookie passed to ResponseHeader.SetCookie may be re-used af... (diff)
downloadfasthttp-b69eba7101fa6c66ba4db0641968a401c9f4f148.tar.gz
fasthttp-b69eba7101fa6c66ba4db0641968a401c9f4f148.tar.bz2
fasthttp-b69eba7101fa6c66ba4db0641968a401c9f4f148.zip
Added Args.GetBool helper
Diffstat (limited to 'args_test.go')
-rw-r--r--args_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/args_test.go b/args_test.go
index 914d5c8..c50bdf3 100644
--- a/args_test.go
+++ b/args_test.go
@@ -164,6 +164,29 @@ func TestArgsWriteTo(t *testing.T) {
}
}
+func TestArgsGetBool(t *testing.T) {
+ testArgsGetBool(t, "", false)
+ testArgsGetBool(t, "0", false)
+ testArgsGetBool(t, "n", false)
+ testArgsGetBool(t, "no", false)
+ testArgsGetBool(t, "1", true)
+ testArgsGetBool(t, "y", true)
+ testArgsGetBool(t, "yes", true)
+
+ testArgsGetBool(t, "123", false)
+ testArgsGetBool(t, "foobar", false)
+}
+
+func testArgsGetBool(t *testing.T, value string, expectedResult bool) {
+ var a Args
+ a.Parse("v=" + value)
+
+ result := a.GetBool("v")
+ if result != expectedResult {
+ t.Fatalf("unexpected result %v. Expecting %v for value %q", result, expectedResult, value)
+ }
+}
+
func TestArgsUint(t *testing.T) {
var a Args
a.SetUint("foo", 123)