Skip to content

Commit

Permalink
util/codec: beautify comment args in assertion (pingcap#26171)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedomn committed Jul 27, 2021
1 parent a4db45a commit 721d352
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions util/codec/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package codec

import (
"bytes"
"fmt"
"hash"
"hash/crc32"
"hash/fnv"
Expand Down Expand Up @@ -74,24 +75,24 @@ func TestCodecKey(t *testing.T) {
}
sc := &stmtctx.StatementContext{TimeZone: time.Local}
for i, datums := range table {
comments := []interface{}{"%d %v", i, datums}
comment := fmt.Sprintf("%d %v", i, datums)
b, err := EncodeKey(sc, nil, datums.Input...)
require.NoError(t, err, comments...)
require.NoError(t, err, comment)

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

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

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

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

var raw types.Datum
Expand Down

0 comments on commit 721d352

Please sign in to comment.