Skip to content

Commit

Permalink
Merge pull request pingcap#169 from pingcap/siddontang/fix-issue-165
Browse files Browse the repository at this point in the history
codec: fix ARM build fail
  • Loading branch information
ngaut committed Sep 16, 2015
2 parents ccaa36e + 8f4c552 commit 63118e1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
32 changes: 16 additions & 16 deletions util/codec/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (s *testCodecSuite) TestCodecKeyCompare(c *C) {
},

{
[]interface{}{[]byte{0x01}, 0xFFFFFFFFFFFFFFF},
[]interface{}{[]byte{0x01}, uint64(0xFFFFFFFFFFFFFFF)},
[]interface{}{[]byte{0x01, 0x10}, 0},
-1,
},
Expand All @@ -150,12 +150,12 @@ func (s *testCodecSuite) TestCodecKeyCompare(c *C) {
1,
},
{
[]interface{}{math.MinInt64},
[]interface{}{int64(math.MinInt64)},
[]interface{}{nil},
1,
},
{
[]interface{}{1, math.MinInt64, nil},
[]interface{}{1, int64(math.MinInt64), nil},
[]interface{}{1, nil, uint64(math.MaxUint64)},
1,
},
Expand Down Expand Up @@ -578,19 +578,19 @@ func (s *testCodecSuite) TestDecimal(c *C) {
{"-12340", "-123400", 1},

// Test for int type decimal.
{-1, 1, -1},
{math.MaxInt64, math.MinInt64, 1},
{math.MaxInt64, math.MaxInt32, 1},
{math.MinInt32, math.MaxInt16, -1},
{math.MinInt64, math.MaxInt8, -1},
{0, math.MaxInt8, -1},
{math.MinInt8, 0, -1},
{math.MinInt16, math.MaxInt16, -1},
{1, -1, 1},
{1, 0, 1},
{-1, 0, -1},
{0, 0, 0},
{math.MaxInt16, math.MaxInt16, 0},
{int64(-1), int64(1), -1},
{int64(math.MaxInt64), int64(math.MinInt64), 1},
{int64(math.MaxInt64), int64(math.MaxInt32), 1},
{int64(math.MinInt32), int64(math.MaxInt16), -1},
{int64(math.MinInt64), int64(math.MaxInt8), -1},
{int64(0), int64(math.MaxInt8), -1},
{int64(math.MinInt8), int64(0), -1},
{int64(math.MinInt16), int64(math.MaxInt16), -1},
{int64(1), int64(-1), 1},
{int64(1), int64(0), 1},
{int64(-1), int64(0), -1},
{int64(0), int64(0), 0},
{int64(math.MaxInt16), int64(math.MaxInt16), 0},

// Test for uint type decimal.
{uint64(0), uint64(0), 0},
Expand Down
39 changes: 20 additions & 19 deletions util/types/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"time"

"fmt"

. "github.com/pingcap/check"
mysql "github.com/pingcap/tidb/mysqldef"
"github.com/pingcap/tidb/util/charset"
Expand Down Expand Up @@ -445,14 +446,14 @@ func (s *testTypeConvertSuite) TestConvert(c *C) {
unsignedAccept(c, mysql.TypeTiny, 255, "255")
unsignedDeny(c, mysql.TypeTiny, 256, "255")

signedDeny(c, mysql.TypeShort, math.MinInt16-1, strvalue(math.MinInt16))
signedAccept(c, mysql.TypeShort, math.MinInt16, strvalue(math.MinInt16))
signedAccept(c, mysql.TypeShort, math.MaxInt16, strvalue(math.MaxInt16))
signedDeny(c, mysql.TypeShort, math.MaxInt16+1, strvalue(math.MaxInt16))
signedDeny(c, mysql.TypeShort, int64(math.MinInt16)-1, strvalue(int64(math.MinInt16)))
signedAccept(c, mysql.TypeShort, int64(math.MinInt16), strvalue(int64(math.MinInt16)))
signedAccept(c, mysql.TypeShort, int64(math.MaxInt16), strvalue(int64(math.MaxInt16)))
signedDeny(c, mysql.TypeShort, int64(math.MaxInt16)+1, strvalue(int64(math.MaxInt16)))
unsignedDeny(c, mysql.TypeShort, -1, "0")
unsignedAccept(c, mysql.TypeShort, 0, "0")
unsignedAccept(c, mysql.TypeShort, math.MaxUint16, strvalue(math.MaxUint16))
unsignedDeny(c, mysql.TypeShort, math.MaxUint16+1, strvalue(math.MaxUint16))
unsignedAccept(c, mysql.TypeShort, uint64(math.MaxUint16), strvalue(uint64(math.MaxUint16)))
unsignedDeny(c, mysql.TypeShort, uint64(math.MaxUint16)+1, strvalue(uint64(math.MaxUint16)))

signedDeny(c, mysql.TypeInt24, -1<<23-1, strvalue(-1<<23))
signedAccept(c, mysql.TypeInt24, -1<<23, strvalue(-1<<23))
Expand All @@ -463,24 +464,24 @@ func (s *testTypeConvertSuite) TestConvert(c *C) {
unsignedAccept(c, mysql.TypeInt24, 1<<24-1, strvalue(1<<24-1))
unsignedDeny(c, mysql.TypeInt24, 1<<24, strvalue(1<<24-1))

signedDeny(c, mysql.TypeLong, math.MinInt32-1, strvalue(math.MinInt32))
signedAccept(c, mysql.TypeLong, math.MinInt32, strvalue(math.MinInt32))
signedAccept(c, mysql.TypeLong, math.MaxInt32, strvalue(math.MaxInt32))
signedDeny(c, mysql.TypeLong, uint64(math.MaxUint64), strvalue(uint(math.MaxInt32)))
signedDeny(c, mysql.TypeLong, math.MaxInt32+1, strvalue(math.MaxInt32))
signedDeny(c, mysql.TypeLong, int64(math.MinInt32)-1, strvalue(int64(math.MinInt32)))
signedAccept(c, mysql.TypeLong, int64(math.MinInt32), strvalue(int64(math.MinInt32)))
signedAccept(c, mysql.TypeLong, int64(math.MaxInt32), strvalue(int64(math.MaxInt32)))
signedDeny(c, mysql.TypeLong, uint64(math.MaxUint64), strvalue(uint64(math.MaxInt32)))
signedDeny(c, mysql.TypeLong, int64(math.MaxInt32)+1, strvalue(int64(math.MaxInt32)))
unsignedDeny(c, mysql.TypeLong, -1, "0")
unsignedAccept(c, mysql.TypeLong, 0, "0")
unsignedAccept(c, mysql.TypeLong, math.MaxUint32, strvalue(math.MaxUint32))
unsignedDeny(c, mysql.TypeLong, math.MaxUint32+1, strvalue(math.MaxUint32))
unsignedAccept(c, mysql.TypeLong, uint64(math.MaxUint32), strvalue(uint64(math.MaxUint32)))
unsignedDeny(c, mysql.TypeLong, uint64(math.MaxUint32)+1, strvalue(uint64(math.MaxUint32)))

signedDeny(c, mysql.TypeLonglong, math.MinInt64*1.1, strvalue(math.MinInt64))
signedAccept(c, mysql.TypeLonglong, math.MinInt64, strvalue(math.MinInt64))
signedAccept(c, mysql.TypeLonglong, math.MaxInt64, strvalue(math.MaxInt64))
signedDeny(c, mysql.TypeLonglong, math.MaxInt64*1.1, strvalue(math.MaxInt64))
signedDeny(c, mysql.TypeLonglong, math.MinInt64*1.1, strvalue(int64(math.MinInt64)))
signedAccept(c, mysql.TypeLonglong, int64(math.MinInt64), strvalue(int64(math.MinInt64)))
signedAccept(c, mysql.TypeLonglong, int64(math.MaxInt64), strvalue(int64(math.MaxInt64)))
signedDeny(c, mysql.TypeLonglong, math.MaxInt64*1.1, strvalue(int64(math.MaxInt64)))
unsignedDeny(c, mysql.TypeLonglong, -1, "0")
unsignedAccept(c, mysql.TypeLonglong, 0, "0")
unsignedAccept(c, mysql.TypeLonglong, uint64(math.MaxUint64), strvalue(uint(math.MaxUint64)))
unsignedDeny(c, mysql.TypeLonglong, math.MaxUint64*1.1, strvalue(uint(math.MaxUint64)))
unsignedAccept(c, mysql.TypeLonglong, uint64(math.MaxUint64), strvalue(uint64(math.MaxUint64)))
unsignedDeny(c, mysql.TypeLonglong, math.MaxUint64*1.1, strvalue(uint64(math.MaxUint64)))

// integer from string
signedAccept(c, mysql.TypeLong, " 234 ", "234")
Expand Down

0 comments on commit 63118e1

Please sign in to comment.