sq/libsq/core/bytez/bytez_test.go
Neil O'Toole a3cd01f36a
#353 Diff performance (#399)
* Diff refactor
2024-02-20 16:26:45 -07:00

31 lines
626 B
Go

package bytez_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/neilotoole/sq/libsq/core/bytez"
)
func TestTerminateNewline(t *testing.T) {
tests := []struct {
name string
in []byte
want []byte
}{
{"nil", nil, nil},
{"empty", []byte{}, []byte{}},
{"single-newline", []byte("\n"), []byte("\n")},
{"already-terminated", []byte("hello\n"), []byte("hello\n")},
{"not-terminated", []byte("hello"), []byte("hello\n")},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := bytez.TerminateNewline(test.in)
require.Equal(t, test.want, got)
})
}
}