1
0
Fork 0

Strings tests

This commit is contained in:
Gregory Eremin 2018-11-08 20:49:13 +01:00
parent 6a6b8b785a
commit dc78ce0707
1 changed files with 38 additions and 0 deletions

38
tests/strings_test.go Normal file
View File

@ -0,0 +1,38 @@
package tests
import (
"fmt"
"strings"
"testing"
"github.com/localhots/bocadillo/mysql"
)
func TestStrings(t *testing.T) {
inputs := map[string][]string{}
for _, length := range []int{1, 10, 100, 255} {
inputs[fmt.Sprint(length)] = []string{
strings.Repeat("a", length),
strings.Repeat("1", length),
strings.Repeat("!", length),
// TODO: Support multi-byte and other encodings
}
}
for _, ct := range []mysql.ColumnType{mysql.ColumnTypeString, mysql.ColumnTypeVarchar} {
t.Run(ct.String(), func(t *testing.T) {
for length, vals := range inputs {
t.Run(length, func(t *testing.T) {
tbl := suite.createTable(ct, length, attrNone)
defer tbl.drop(t)
for _, v := range vals {
t.Run(fmt.Sprintf("%s x%d", v[:1], len(v)), func(t *testing.T) {
suite.insertAndCompare(t, tbl, v)
})
}
})
}
})
}
}