Skip to content

Commit

Permalink
fix(enc.b64): add comma
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Nov 10, 2021
1 parent 90bb8b9 commit 1ebaae5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions enc_b64.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func (e *Encoder) Base64(data []byte) {
e.Null()
return
}
e.comma()
e.byte('"')
encodedLen := base64.StdEncoding.EncodedLen(len(data))
start := len(e.buf)
Expand Down
3 changes: 2 additions & 1 deletion enc_comma_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ func TestEncoder_comma(t *testing.T) {
e.True()
e.False()
e.Null()
e.Base64(Raw{1})
e.Bool(true)
e.ArrEnd()
e.ObjEnd()

require.Equal(t, `{"a":1,"b":2,"c":[1,2,3,4.5,23,true,false,null,true]}`, e.String())
require.Equal(t, `{"a":1,"b":2,"c":[1,2,3,4.5,23,true,false,null,"AQ==",true]}`, e.String())
})
t.Run("NoPanic", func(t *testing.T) {
var e Encoder
Expand Down

0 comments on commit 1ebaae5

Please sign in to comment.