Skip to content

Commit

Permalink
expressions:remove unnecessary test
Browse files Browse the repository at this point in the history
  • Loading branch information
siddontang committed Sep 7, 2015
1 parent 329721d commit 213793b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 45 deletions.
42 changes: 0 additions & 42 deletions expression/expressions/binop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package expressions

import (
"errors"
"time"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/expression"
Expand Down Expand Up @@ -106,44 +105,6 @@ func (s *testBinOpSuite) TestComparisonOp(c *C) {
c.Assert(v, IsNil)
}

// test evalCompare function
cmpTbl := []struct {
lhs interface{}
rhs interface{}
ret int // 0, 1, -1
}{
{float64(1), float64(1), 0},
{float64(1), "1", 0},
{int64(1), int64(1), 0},
{int64(-1), uint64(1), -1},
{int64(-1), "-1", 0},
{uint64(1), uint64(1), 0},
{uint64(1), int64(-1), 1},
{uint64(1), "1", 0},
{mysql.NewDecimalFromInt(1, 0), mysql.NewDecimalFromInt(1, 0), 0},
{mysql.NewDecimalFromInt(1, 0), "1", 0},
{"1", "1", 0},
{"1", int64(-1), 1},
{"1", float64(2), -1},
{"1", uint64(1), 0},
{"1", mysql.NewDecimalFromInt(1, 0), 0},
{"2011-01-01 11:11:11", mysql.Time{Time: time.Now(), Type: mysql.TypeDatetime, Fsp: 0}, -1},
{"12:00:00", mysql.ZeroDuration, 1},
{mysql.ZeroDuration, mysql.ZeroDuration, 0},
{mysql.Time{Time: time.Now().Add(time.Second * 10), Type: mysql.TypeDatetime, Fsp: 0},
mysql.Time{Time: time.Now(), Type: mysql.TypeDatetime, Fsp: 0}, 1},
}

for _, t := range cmpTbl {
ret, err := evalCompare(t.lhs, t.rhs)
c.Assert(err, IsNil)
c.Assert(ret, Equals, t.ret)

ret, err = evalCompare(t.rhs, t.lhs)
c.Assert(err, IsNil)
c.Assert(ret, Equals, -t.ret)
}

// test error
mock := mockExpr{
isStatic: false,
Expand Down Expand Up @@ -194,9 +155,6 @@ func (s *testBinOpSuite) TestComparisonOp(c *C) {
expr := BinaryOperation{Op: opcode.Plus, L: Value{1}, R: Value{1}}
_, err := expr.evalComparisonOp(nil, nil)
c.Assert(err, NotNil)

_, err = evalCompare(1, 1)
c.Assert(err, NotNil)
}

func (s *testBinOpSuite) TestIdentRelOp(c *C) {
Expand Down
6 changes: 3 additions & 3 deletions util/types/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func (s *testCompareSuite) TestCompare(c *C) {
{"1", float64(2), -1},
{"1", uint64(1), 0},
{"1", mysql.NewDecimalFromInt(1, 0), 0},
{"2011-01-01 11:11:11", mysql.Time{time.Now(), mysql.TypeDatetime, 0}, -1},
{"2011-01-01 11:11:11", mysql.Time{Time: time.Now(), Type: mysql.TypeDatetime, Fsp: 0}, -1},
{"12:00:00", mysql.ZeroDuration, 1},
{mysql.ZeroDuration, mysql.ZeroDuration, 0},
{mysql.Time{time.Now().Add(time.Second * 10), mysql.TypeDatetime, 0},
mysql.Time{time.Now(), mysql.TypeDatetime, 0}, 1},
{mysql.Time{Time: time.Now().Add(time.Second * 10), Type: mysql.TypeDatetime, Fsp: 0},
mysql.Time{Time: time.Now(), Type: mysql.TypeDatetime, Fsp: 0}, 1},

{nil, 2, -1},
{nil, nil, 0},
Expand Down

0 comments on commit 213793b

Please sign in to comment.