mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-22 23:51:44 +03:00
40 lines
1.4 KiB
Go
40 lines
1.4 KiB
Go
package sqlmodel
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestTrimTrailingDelims(t *testing.T) {
|
|
delims := []string{";", "go", "Go", "gO", "GO"}
|
|
|
|
testCases := map[string]string{
|
|
"": "",
|
|
"\t": "",
|
|
" ": "",
|
|
";": "",
|
|
"GO": "",
|
|
"go;": "",
|
|
"select * from food": "select * from food",
|
|
"select * from food;": "select * from food",
|
|
"select * from food ;": "select * from food",
|
|
"select * from food ; ": "select * from food",
|
|
"select * from food;go": "select * from food",
|
|
"select * from food;GO": "select * from food",
|
|
"select * from food;Go": "select * from food",
|
|
"select * from food;gO": "select * from food",
|
|
"select * from food; go": "select * from food",
|
|
"select * from food ; go ;;;go ": "select * from food",
|
|
"select * from food2go": "select * from food2go",
|
|
"select * from food2go;go": "select * from food2go",
|
|
"select * from food2go go": "select * from food2go",
|
|
"select * from food2go go go go": "select * from food2go",
|
|
}
|
|
|
|
for input, want := range testCases {
|
|
got := trimTrailingDelims(input, delims...)
|
|
require.Equal(t, want, got)
|
|
}
|
|
}
|