Added a test for AppendHTTPDate

This commit is contained in:
Aliaksandr Valialkin
2015-11-11 11:04:54 +02:00
parent 9735e0127b
commit 04ec7b22d0
+20
View File
@@ -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)