Write a basic test suite

This commit is contained in:
Asdine El Hrychy
2020-09-03 19:58:40 +04:00
parent 11081d3f97
commit 4af4993d88
2 changed files with 23 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
// Package encodingtest provides a test suite for testing codec implementations.
package encodingtest
import (
"testing"
"github.com/genjidb/genji/document"
"github.com/genjidb/genji/document/encoding"
"github.com/stretchr/testify/require"
)
// TestCodec runs a list of tests on the given codec.
func TestCodec(t *testing.T, codecBuilder func() encoding.Codec) {
t.Run("Encoding using a nil reader should fail", func(t *testing.T) {
codec := codecBuilder()
err := codec.NewEncoder(nil).EncodeDocument(document.NewFieldBuffer().Add("a", document.NewBoolValue(true)))
require.Error(t, err)
})
}