aboutsummaryrefslogtreecommitdiff
path: root/securecookie_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'securecookie_test.go')
-rw-r--r--securecookie_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/securecookie_test.go b/securecookie_test.go
index 33ce4fc..2b0f8a1 100644
--- a/securecookie_test.go
+++ b/securecookie_test.go
@@ -193,6 +193,33 @@ func TestJSONSerialization(t *testing.T) {
}
}
+func TestNopSerialization(t *testing.T) {
+ cookieData := "fooobar123"
+ sz := NopEncoder{}
+
+ if _, err := sz.Serialize(cookieData); err != errValueNotByte {
+ t.Fatal("Expected error passing string")
+ }
+ dat, err := sz.Serialize([]byte(cookieData))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if (string(dat)) != cookieData {
+ t.Fatal("Expected serialized data to be same as source")
+ }
+
+ var dst []byte
+ if err = sz.Deserialize(dat, dst); err != errValueNotBytePtr {
+ t.Fatal("Expect error unless you pass a *[]byte")
+ }
+ if err = sz.Deserialize(dat, &dst); err != nil {
+ t.Fatal(err)
+ }
+ if (string(dst)) != cookieData {
+ t.Fatal("Expected deserialized data to be same as source")
+ }
+}
+
func TestEncoding(t *testing.T) {
for _, value := range testStrings {
encoded := encode([]byte(value))