github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/dbs/memristed/memex/aggregation/util_test.go (about)

     1  package aggregation
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/whtcorpsinc/check"
     7  	"github.com/whtcorpsinc/milevadb/stochastikctx/stmtctx"
     8  	"github.com/whtcorpsinc/milevadb/types"
     9  )
    10  
    11  var _ = check.Suite(&testUtilSuite{})
    12  
    13  type testUtilSuite struct {
    14  }
    15  
    16  func (s *testUtilSuite) TestDistinct(c *check.C) {
    17  	sc := &stmtctx.StatementContext{TimeZone: time.Local}
    18  	dc := createDistinctChecker(sc)
    19  	tests := []struct {
    20  		vals   []interface{}
    21  		expect bool
    22  	}{
    23  		{[]interface{}{1, 1}, true},
    24  		{[]interface{}{1, 1}, false},
    25  		{[]interface{}{1, 2}, true},
    26  		{[]interface{}{1, 2}, false},
    27  		{[]interface{}{1, nil}, true},
    28  		{[]interface{}{1, nil}, false},
    29  	}
    30  	for _, tt := range tests {
    31  		d, err := dc.Check(types.MakeCausets(tt.vals...))
    32  		c.Assert(err, check.IsNil)
    33  		c.Assert(d, check.Equals, tt.expect)
    34  	}
    35  }