Skip to content

Commit

Permalink
add test for DecodeRowKey
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta committed Nov 19, 2021
1 parent 79396e4 commit f998c6e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tablecodec/tablecodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ func TestTableCodec(t *testing.T) {
require.Equal(t, int64(2), h.IntValue())
}

// https://github.com/pingcap/tidb/issues/27687.
func TestTableCodecInvalid(t *testing.T) {
tableID := int64(100)
buf := make([]byte, 0, 11)
buf = append(buf, 't')
buf = codec.EncodeInt(buf, tableID)
buf = append(buf, '_', 'r')
buf = codec.EncodeInt(buf, -9078412423848787968)
buf = append(buf, '0')
_, err := DecodeRowKey(buf)
require.NotNil(t, err)
require.Equal(t, "invalid encoded key", err.Error())
}

// column is a structure used for test
type column struct {
id int64
Expand Down

0 comments on commit f998c6e

Please sign in to comment.