github.com/matrixorigin/matrixone@v0.7.0/pkg/sql/colexec/agg/aggUt/bit_and_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 TestBitAnd(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-and test 31 { 32 op: agg.AggregateBitAnd, 33 isDistinct: false, 34 inputTyp: int32Typ, 35 36 input: []int32{1, 3}, 37 inputNsp: nil, 38 expected: []uint64{1}, 39 40 mergeInput: []int32{2}, 41 mergeNsp: nil, 42 mergeExpect: []uint64{0}, 43 44 testMarshal: true, 45 }, 46 // int8 bit-and test 47 { 48 op: agg.AggregateBitAnd, 49 isDistinct: true, 50 inputTyp: int32Typ, 51 52 input: []int32{1, 3, 3}, 53 inputNsp: nil, 54 expected: []uint64{1}, 55 56 mergeInput: []int32{2, 2}, 57 mergeNsp: nil, 58 mergeExpect: []uint64{0}, 59 60 testMarshal: false, 61 }, 62 // float64 bit-and test 63 { 64 op: agg.AggregateBitAnd, 65 isDistinct: false, 66 inputTyp: float64Typ, 67 68 input: []float64{1, 3}, 69 inputNsp: nil, 70 expected: []uint64{1}, 71 72 mergeInput: []float64{2}, 73 mergeNsp: nil, 74 mergeExpect: []uint64{0}, 75 76 testMarshal: true, 77 }, 78 } 79 80 RunTest(t, testCases) 81 }