github.com/matrixorigin/matrixone@v0.7.0/pkg/sql/colexec/agg/aggUt/bit_xor_test.go (about)

     1  // Copyright 2021 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package aggut
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/matrixorigin/matrixone/pkg/sql/colexec/agg"
    21  
    22  	"github.com/matrixorigin/matrixone/pkg/container/types"
    23  )
    24  
    25  func TestBitXor(t *testing.T) {
    26  	int32Typ := types.New(types.T_int32, 0, 0, 0)
    27  	float64Typ := types.New(types.T_float64, 0, 0, 0)
    28  
    29  	testCases := []testCase{
    30  		// int8 bit-xor test
    31  		{
    32  			op:         agg.AggregateBitXor,
    33  			isDistinct: false,
    34  			inputTyp:   int32Typ,
    35  
    36  			input:    []int32{2, 2},
    37  			inputNsp: nil,
    38  			expected: []uint64{0},
    39  
    40  			mergeInput:  []int32{1},
    41  			mergeNsp:    nil,
    42  			mergeExpect: []uint64{1},
    43  
    44  			testMarshal: true,
    45  		},
    46  		// int8 bit-xor test
    47  		{
    48  			op:         agg.AggregateBitXor,
    49  			isDistinct: true,
    50  			inputTyp:   int32Typ,
    51  
    52  			input:    []int32{2, 2},
    53  			inputNsp: nil,
    54  			expected: []uint64{2},
    55  
    56  			mergeInput:  []int32{1},
    57  			mergeNsp:    nil,
    58  			mergeExpect: []uint64{3},
    59  
    60  			testMarshal: false,
    61  		},
    62  		// float64 bit-xor test
    63  		{
    64  			op:         agg.AggregateBitXor,
    65  			isDistinct: false,
    66  			inputTyp:   float64Typ,
    67  
    68  			input:    []float64{2, 2},
    69  			inputNsp: nil,
    70  			expected: []uint64{0},
    71  
    72  			mergeInput:  []float64{1},
    73  			mergeNsp:    nil,
    74  			mergeExpect: []uint64{1},
    75  
    76  			testMarshal: true,
    77  		},
    78  	}
    79  
    80  	RunTest(t, testCases)
    81  }