Skip to content

Commit

Permalink
util/codec: refactor assertion message and args for better debug mess…
Browse files Browse the repository at this point in the history
…ages (pingcap#26171)
  • Loading branch information
Fedomn committed Jul 26, 2021
1 parent c69ec56 commit a4db45a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions util/codec/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,24 @@ func TestCodecKey(t *testing.T) {
}
sc := &stmtctx.StatementContext{TimeZone: time.Local}
for i, datums := range table {
comments := []interface{}{"%d %v", i, datums}
b, err := EncodeKey(sc, nil, datums.Input...)
require.NoError(t, err, "%d %v", i, datums)
require.NoError(t, err, comments...)

args, err := Decode(b, 1)
require.NoError(t, err)
require.Equal(t, datums.Expect, args)
require.NoError(t, err, comments...)
require.Equal(t, datums.Expect, args, comments...)

b, err = EncodeValue(sc, nil, datums.Input...)
require.NoError(t, err)
require.NoError(t, err, comments...)

size, err := estimateValuesSize(sc, datums.Input)
require.NoError(t, err)
require.Len(t, b, size)
require.NoError(t, err, comments...)
require.Len(t, b, size, comments...)

args, err = Decode(b, 1)
require.NoError(t, err)
require.Equal(t, datums.Expect, args)
require.NoError(t, err, comments...)
require.Equal(t, datums.Expect, args, comments...)
}

var raw types.Datum
Expand Down

0 comments on commit a4db45a

Please sign in to comment.