expression/expressions: add error check test.

This commit is contained in:
qiuyesuifeng
2015-09-11 22:52:21 +08:00
parent 09502ecca2
commit ace4331c97

View File

@ -135,7 +135,7 @@ func (s *testCompSubQuerySuite) TestRow(c *C) {
rhs = append(rhs, []interface{}{s.convert(v)})
}
sq := newMockSubQuery(rhs, []string{"id"})
sq := newMockSubQuery(rhs, []string{"c"})
expr := NewCompareSubQuery(t.op, Value{lhs}, sq, t.all)
c.Assert(expr.IsStatic(), IsFalse)
@ -155,4 +155,16 @@ func (s *testCompSubQuerySuite) TestRow(c *C) {
c.Assert(val, Equals, int64(x))
}
}
// Test error.
sq := newMockSubQuery([][]interface{}{{1, 2}}, []string{"c1", "c2"})
expr := NewCompareSubQuery(opcode.EQ, Value{1}, sq, true)
_, err := expr.Eval(nil, nil)
c.Assert(err, NotNil)
expr = NewCompareSubQuery(opcode.EQ, Value{1}, sq, false)
_, err = expr.Eval(nil, nil)
c.Assert(err, NotNil)
}