aboutsummaryrefslogtreecommitdiff
path: root/bytesconv_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-11 11:04:54 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-11 11:04:54 +0200
commit04ec7b22d055be61b095fc084b046022cb2aa87c (patch)
treec50ffd156669d530d0a2459210faf5de8dd3ec4e /bytesconv_test.go
parentExported ParseUint, ParseUfloat and AppendHTTPDate, which may be frequently u... (diff)
downloadfasthttp-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.go20
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)