diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-11 11:04:54 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-11 11:04:54 +0200 |
commit | 04ec7b22d055be61b095fc084b046022cb2aa87c (patch) | |
tree | c50ffd156669d530d0a2459210faf5de8dd3ec4e /bytesconv_test.go | |
parent | Exported ParseUint, ParseUfloat and AppendHTTPDate, which may be frequently u... (diff) | |
download | fasthttp-04ec7b22d055be61b095fc084b046022cb2aa87c.tar.gz fasthttp-04ec7b22d055be61b095fc084b046022cb2aa87c.tar.bz2 fasthttp-04ec7b22d055be61b095fc084b046022cb2aa87c.zip |
Added a test for AppendHTTPDate
Diffstat (limited to 'bytesconv_test.go')
-rw-r--r-- | bytesconv_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bytesconv_test.go b/bytesconv_test.go index c7a96e5..00b6d47 100644 --- a/bytesconv_test.go +++ b/bytesconv_test.go @@ -2,8 +2,28 @@ package fasthttp import ( "testing" + "time" ) +func TestAppendHTTPDate(t *testing.T) { + d := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) + s := string(AppendHTTPDate(nil, d)) + expectedS := "Tue, 10 Nov 2009 23:00:00 GMT" + if s != expectedS { + t.Fatalf("unexpected date %q. Expecting %q", s, expectedS) + } + + b := []byte("prefix") + s = string(AppendHTTPDate(b, d)) + if s[:len(b)] != string(b) { + t.Fatalf("unexpected prefix %q. Expecting %q", s[:len(b)], b) + } + s = s[len(b):] + if s != expectedS { + t.Fatalf("unexpected date %q. Expecting %q", s, expectedS) + } +} + func TestParseUintSuccess(t *testing.T) { testParseUintSuccess(t, "0", 0) testParseUintSuccess(t, "123", 123) |