Skip to content

Commit

Permalink
expression: migrate generated tests to testify
Browse files Browse the repository at this point in the history
This refers pingcap#26855 .

Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Oct 25, 2021
1 parent 836b102 commit bdba1b1
Show file tree
Hide file tree
Showing 27 changed files with 330 additions and 298 deletions.
248 changes: 77 additions & 171 deletions expression/bench_test.go

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions expression/builtin_arithmetic_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"math"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/mock"
"github.com/stretchr/testify/require"
)

var vecBuiltinArithmeticCases = map[string][]vecExprBenchCase{
Expand Down Expand Up @@ -182,11 +182,11 @@ var vecBuiltinArithmeticCases = map[string][]vecExprBenchCase{
ast.NE: {},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinArithmeticFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinArithmeticCases)
func TestVectorizedBuiltinArithmeticFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinArithmeticCases)
}

func (s *testEvaluatorSuite) TestVectorizedDecimalErrOverflow(c *C) {
func TestVectorizedDecimalErrOverflow(t *testing.T) {
ctx := mock.NewContext()
testCases := []struct {
args []float64
Expand All @@ -212,18 +212,17 @@ func (s *testEvaluatorSuite) TestVectorizedDecimalErrOverflow(c *C) {
input := chunk.New(fts, 1, 1)
dec1, dec2 := new(types.MyDecimal), new(types.MyDecimal)
err := dec1.FromFloat64(tt.args[0])
c.Assert(err, IsNil)
require.NoError(t, err)
err = dec2.FromFloat64(tt.args[1])
c.Assert(err, IsNil)
require.NoError(t, err)
input.AppendMyDecimal(0, dec1)
input.AppendMyDecimal(1, dec2)
cols := []Expression{&Column{Index: 0, RetType: fts[0]}, &Column{Index: 1, RetType: fts[1]}}
baseFunc, err := funcs[tt.funcName].getFunction(ctx, cols)
c.Assert(err, IsNil)
require.NoError(t, err)
result := chunk.NewColumn(eType2FieldType(types.ETDecimal), 1)
err = baseFunc.vecEvalDecimal(input, result)
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, tt.errStr)
require.EqualError(t, err, tt.errStr)
}
}

Expand Down
8 changes: 4 additions & 4 deletions expression/builtin_cast_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ func (g *datetimeJSONGener) gen() interface{} {
return json.CreateBinary(d.String())
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinCastEvalOneVec(c *C) {
testVectorizedEvalOneVec(c, vecBuiltinCastCases)
func TestVectorizedBuiltinCastEvalOneVec(t *testing.T) {
testVectorizedEvalOneVec(t, vecBuiltinCastCases)
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinCastFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinCastCases)
func TestVectorizedBuiltinCastFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinCastCases)
}

func (s *testEvaluatorSuite) TestVectorizedCastRealAsTime(c *C) {
Expand Down
9 changes: 4 additions & 5 deletions expression/builtin_compare_vec_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions expression/builtin_compare_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package expression
import (
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/types"
Expand Down Expand Up @@ -150,12 +149,12 @@ var vecBuiltinCompareCases = map[string][]vecExprBenchCase{
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinCompareEvalOneVec(c *C) {
testVectorizedEvalOneVec(c, vecBuiltinCompareCases)
func TestVectorizedBuiltinCompareEvalOneVec(t *testing.T) {
testVectorizedEvalOneVec(t, vecBuiltinCompareCases)
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinCompareFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinCompareCases)
func TestVectorizedBuiltinCompareFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinCompareCases)
}

func BenchmarkVectorizedBuiltinCompareEvalOneVec(b *testing.B) {
Expand Down
9 changes: 4 additions & 5 deletions expression/builtin_control_vec_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions expression/builtin_encryption_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package expression
import (
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/types"
)
Expand Down Expand Up @@ -75,8 +74,8 @@ var vecBuiltinEncryptionCases = map[string][]vecExprBenchCase{
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinEncryptionFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinEncryptionCases)
func TestVectorizedBuiltinEncryptionFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinEncryptionCases)
}

func BenchmarkVectorizedBuiltinEncryptionFunc(b *testing.B) {
Expand Down
5 changes: 2 additions & 3 deletions expression/builtin_info_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"math/rand"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/parser/mysql"
Expand Down Expand Up @@ -110,8 +109,8 @@ var vecBuiltinInfoCases = map[string][]vecExprBenchCase{
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinInfoFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinInfoCases)
func TestVectorizedBuiltinInfoFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinInfoCases)
}

func BenchmarkVectorizedBuiltinInfoFunc(b *testing.B) {
Expand Down
5 changes: 2 additions & 3 deletions expression/builtin_json_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package expression
import (
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/types"
)
Expand Down Expand Up @@ -141,8 +140,8 @@ var vecBuiltinJSONCases = map[string][]vecExprBenchCase{
},
}

func (s *testVectorizeSuite2) TestVectorizedBuiltinJSONFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinJSONCases)
func TestVectorizedBuiltinJSONFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinJSONCases)
}

func BenchmarkVectorizedBuiltinJSONFunc(b *testing.B) {
Expand Down
5 changes: 2 additions & 3 deletions expression/builtin_like_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package expression
import (
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/types"
)
Expand All @@ -33,8 +32,8 @@ var vecBuiltinLikeCases = map[string][]vecExprBenchCase{
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinLikeFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinLikeCases)
func TestVectorizedBuiltinLikeFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinLikeCases)
}

func BenchmarkVectorizedBuiltinLikeFunc(b *testing.B) {
Expand Down
13 changes: 6 additions & 7 deletions expression/builtin_math_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package expression
import (
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/types"
Expand Down Expand Up @@ -136,16 +135,16 @@ var vecBuiltinMathCases1 = map[string][]vecExprBenchCase{
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinMathEvalOneVec(c *C) {
testVectorizedEvalOneVec(c, vecBuiltinMathCases)
func TestVectorizedBuiltinMathEvalOneVec(t *testing.T) {
testVectorizedEvalOneVec(t, vecBuiltinMathCases)
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinMathFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinMathCases)
func TestVectorizedBuiltinMathFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinMathCases)
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinMathFuncForRand(c *C) {
testVectorizedBuiltinFuncForRand(c, vecBuiltinMathCases1)
func TestVectorizedBuiltinMathFuncForRand(t *testing.T) {
testVectorizedBuiltinFuncForRand(t, vecBuiltinMathCases1)
}

func BenchmarkVectorizedBuiltinMathEvalOneVec(b *testing.B) {
Expand Down
8 changes: 4 additions & 4 deletions expression/builtin_miscellaneous_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ var vecBuiltinMiscellaneousCases = map[string][]vecExprBenchCase{
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinMiscellaneousEvalOneVec(c *C) {
testVectorizedEvalOneVec(c, vecBuiltinMiscellaneousCases)
func TestVectorizedBuiltinMiscellaneousEvalOneVec(t *testing.T) {
testVectorizedEvalOneVec(t, vecBuiltinMiscellaneousCases)
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinMiscellaneousFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinMiscellaneousCases)
func TestVectorizedBuiltinMiscellaneousFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinMiscellaneousCases)
}

func BenchmarkVectorizedBuiltinMiscellaneousEvalOneVec(b *testing.B) {
Expand Down
4 changes: 2 additions & 2 deletions expression/builtin_op_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func makeBinaryLogicOpDataGeners() []dataGenerator {
makeGivenValsOrDefaultGener(arg1s, types.ETInt)}
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinOpFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinOpCases)
func TestVectorizedBuiltinOpFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinOpCases)
}

func BenchmarkVectorizedBuiltinOpFunc(b *testing.B) {
Expand Down
9 changes: 4 additions & 5 deletions expression/builtin_other_vec_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions expression/builtin_other_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ var vecBuiltinOtherCases = map[string][]vecExprBenchCase{
},
}

func (s *testEvaluatorSuite) TestVectorizedBuiltinOtherFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinOtherCases)
func TestVectorizedBuiltinOtherFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinOtherCases)
}

func BenchmarkVectorizedBuiltinOtherFunc(b *testing.B) {
Expand Down
9 changes: 4 additions & 5 deletions expression/builtin_string_vec_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions expression/builtin_string_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"math/rand"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/parser/charset"
"github.com/pingcap/tidb/parser/mysql"
Expand Down Expand Up @@ -529,12 +528,12 @@ var vecBuiltinStringCases2 = map[string][]vecExprBenchCase{
},
}

func (s *testVectorizeSuite1) TestVectorizedBuiltinStringEvalOneVec(c *C) {
testVectorizedEvalOneVec(c, vecBuiltinStringCases)
func TestVectorizedBuiltinStringEvalOneVec(t *testing.T) {
testVectorizedEvalOneVec(t, vecBuiltinStringCases)
}

func (s *testVectorizeSuite1) TestVectorizedBuiltinStringFunc(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinStringCases)
func TestVectorizedBuiltinStringFunc(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinStringCases)
}

func BenchmarkVectorizedBuiltinStringEvalOneVec(b *testing.B) {
Expand All @@ -545,12 +544,12 @@ func BenchmarkVectorizedBuiltinStringFunc(b *testing.B) {
benchmarkVectorizedBuiltinFunc(b, vecBuiltinStringCases)
}

func (s *testVectorizeSuite1) TestVectorizedBuiltinStringEvalOneVec2(c *C) {
testVectorizedEvalOneVec(c, vecBuiltinStringCases2)
func TestVectorizedBuiltinStringEvalOneVec2(t *testing.T) {
testVectorizedEvalOneVec(t, vecBuiltinStringCases2)
}

func (s *testVectorizeSuite1) TestVectorizedBuiltinStringFunc2(c *C) {
testVectorizedBuiltinFunc(c, vecBuiltinStringCases2)
func TestVectorizedBuiltinStringFunc2(t *testing.T) {
testVectorizedBuiltinFunc(t, vecBuiltinStringCases2)
}

func BenchmarkVectorizedBuiltinStringEvalOneVec2(b *testing.B) {
Expand Down
Loading

0 comments on commit bdba1b1

Please sign in to comment.