diff options
author | Craig Peterson <cpeterson@stackoverflow.com> | 2016-10-03 08:16:01 +0300 |
---|---|---|
committer | Matt Silverlock <matt@eatsleeprepeat.net> | 2016-10-03 08:16:01 +0300 |
commit | fa5329f913702981df43dcb2a380bac429c810b5 (patch) | |
tree | d2d7093530f1a21b54c477dbd500959acde50c1a /securecookie_test.go | |
parent | c13558c2b1c44da35e0eb043053609a5ba3a1f19 (diff) |
[bugfix] Fix NopDecoder
* Fixes #41
Diffstat (limited to 'securecookie_test.go')
-rw-r--r-- | securecookie_test.go | 27 |
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)) |