Fix various mysql data type conversions (#3554)
This commit is contained in:
committed by
Daniel Nelson
parent
825d338386
commit
60c39ced69
@@ -127,26 +127,29 @@ func TestMysqlDNSAddTimeout(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseValue(t *testing.T) {
|
||||
testCases := []struct {
|
||||
rawByte sql.RawBytes
|
||||
value float64
|
||||
output interface{}
|
||||
boolValue bool
|
||||
}{
|
||||
{sql.RawBytes("Yes"), 1, true},
|
||||
{sql.RawBytes("No"), 0, false},
|
||||
{sql.RawBytes("123"), int64(123), true},
|
||||
{sql.RawBytes("abc"), "abc", true},
|
||||
{sql.RawBytes("10.1"), 10.1, true},
|
||||
{sql.RawBytes("ON"), 1, true},
|
||||
{sql.RawBytes("OFF"), 0, false},
|
||||
{sql.RawBytes("ABC"), 0, false},
|
||||
{sql.RawBytes("OFF"), 0, true},
|
||||
{sql.RawBytes("NO"), 0, true},
|
||||
{sql.RawBytes("YES"), 1, true},
|
||||
{sql.RawBytes("No"), 0, true},
|
||||
{sql.RawBytes("Yes"), 1, true},
|
||||
{sql.RawBytes(""), nil, false},
|
||||
}
|
||||
for _, cases := range testCases {
|
||||
if value, ok := parseValue(cases.rawByte); value != cases.value && ok != cases.boolValue {
|
||||
t.Errorf("want %d with %t, got %d with %t", int(cases.value), cases.boolValue, int(value), ok)
|
||||
if got, ok := parseValue(cases.rawByte); got != cases.output && ok != cases.boolValue {
|
||||
t.Errorf("for %s wanted %t, got %t", string(cases.rawByte), cases.output, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewNamespace(t *testing.T) {
|
||||
testCases := []struct {
|
||||
words []string
|
||||
|
||||
Reference in New Issue
Block a user