github.com/apache/arrow/go/v14@v14.0.2/parquet/internal/bmi/bmi_test.go (about) 1 // Licensed to the Apache Software Foundation (ASF) under one 2 // or more contributor license agreements. See the NOTICE file 3 // distributed with this work for additional information 4 // regarding copyright ownership. The ASF licenses this file 5 // to you under the Apache License, Version 2.0 (the 6 // "License"); you may not use this file except in compliance 7 // with the License. You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 package bmi_test 18 19 import ( 20 "fmt" 21 "testing" 22 23 "github.com/apache/arrow/go/v14/parquet/internal/bmi" 24 "github.com/stretchr/testify/assert" 25 ) 26 27 // Testing the issue in GH-37712 28 func TestBasicExtractBits(t *testing.T) { 29 tests := []struct { 30 bitmap, selection uint64 31 expected uint64 32 }{ 33 {0, 0, 0}, 34 {0xFF, 0, 0}, 35 {0xFF, ^uint64(0), 0xFF}, 36 {0xFF00FF, 0xAAAA, 0x000F}, 37 {0xFF0AFF, 0xAFAA, 0x00AF}, 38 {0xFFAAFF, 0xAFAA, 0x03AF}, 39 {0xFECBDA9876543210, 0xF00FF00FF00FF00F, 0xFBD87430}, 40 } 41 42 for _, tt := range tests { 43 t.Run(fmt.Sprintf("%d-%d=>%d", tt.bitmap, tt.selection, tt.expected), func(t *testing.T) { 44 assert.Equal(t, tt.expected, bmi.ExtractBits(tt.bitmap, tt.selection)) 45 }) 46 } 47 }