diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2017-01-30 19:47:15 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2017-01-30 19:47:15 +0200 |
commit | b69eba7101fa6c66ba4db0641968a401c9f4f148 (patch) | |
tree | 1c175e2b4da5d0b776423c29000525f89fc65de2 /args_test.go | |
parent | Document that the cookie passed to ResponseHeader.SetCookie may be re-used af... (diff) | |
download | fasthttp-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.go | 23 |
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) |