Additional test coverage for DataType

pull/5196/head
Jonathan A. Sternberg 2016-01-22 23:22:50 -05:00 committed by Ben Johnson
parent 8e925065a0
commit 43ae104e31
1 changed files with 27 additions and 0 deletions

View File

@ -17,6 +17,14 @@ func TestInspectDataType(t *testing.T) {
typ influxql.DataType
}{
{float64(100), influxql.Float},
{int64(100), influxql.Integer},
{int32(100), influxql.Integer},
{100, influxql.Integer},
{true, influxql.Boolean},
{"string", influxql.String},
{time.Now(), influxql.Time},
{time.Second, influxql.Duration},
{nil, influxql.Unknown},
} {
if typ := influxql.InspectDataType(tt.v); tt.typ != typ {
t.Errorf("%d. %v (%s): unexpected type: %s", i, tt.v, tt.typ, typ)
@ -25,6 +33,25 @@ func TestInspectDataType(t *testing.T) {
}
}
func TestDataType_String(t *testing.T) {
for i, tt := range []struct {
typ influxql.DataType
v string
}{
{influxql.Float, "float"},
{influxql.Integer, "integer"},
{influxql.Boolean, "boolean"},
{influxql.String, "string"},
{influxql.Time, "time"},
{influxql.Duration, "duration"},
{influxql.Unknown, "unknown"},
} {
if v := tt.typ.String(); tt.v != v {
t.Errorf("%d. %v (%s): unexpected string: %s", i, tt.typ, tt.v, v)
}
}
}
// Ensure the SELECT statement can extract substatements.
func TestSelectStatement_Substatement(t *testing.T) {
var tests = []struct {