diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-28 13:39:42 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-29 02:14:51 -0700 |
commit | 636311bafdb18da9851a668317a8d792f38ead5b (patch) | |
tree | 0dbd3ac35fb4f54487600f3ea19964043ea011bf /base64_test.go | |
parent | 2824310168b9dbe24c2d47cfb71d4283b1733642 (diff) |
Move the base64 decode to the internal package
Diffstat (limited to 'base64_test.go')
-rw-r--r-- | base64_test.go | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/base64_test.go b/base64_test.go deleted file mode 100644 index 43367af..0000000 --- a/base64_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> -// -// SPDX-License-Identifier: GPL-2.0-or-later - -package lowmemjson - -import ( - "bytes" - "encoding/base64" - "testing" - - "github.com/stretchr/testify/require" -) - -func b64encode(t *testing.T, input []byte) []byte { - var encoded bytes.Buffer - enc := base64.NewEncoder(base64.StdEncoding, &encoded) - _, err := enc.Write(input) - require.NoError(t, err) - require.NoError(t, enc.Close()) - return encoded.Bytes() -} - -func b64decode(t *testing.T, input []byte) []byte { - var decoded bytes.Buffer - dec := newBase64Decoder(&decoded) - _, err := dec.Write(input) - require.NoError(t, err) - require.NoError(t, dec.Close()) - return decoded.Bytes() -} - -func FuzzBase64Decoder(f *testing.F) { - f.Fuzz(func(t *testing.T, input []byte) { - encoded := b64encode(t, input) - decoded := b64decode(t, encoded) - t.Logf("input b64 = %q", encoded) - t.Logf("expected decoded = %#v", input) - t.Logf("actual decoded = %#v", decoded) - if !bytes.Equal(input, decoded) { - t.Fail() - } - }) -} |