github.com/matrixorigin/matrixone@v1.2.0/pkg/frontend/output_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 frontend
    16  
    17  import (
    18  	"context"
    19  	"testing"
    20  
    21  	"github.com/stretchr/testify/require"
    22  
    23  	"github.com/matrixorigin/matrixone/pkg/common/mpool"
    24  	"github.com/matrixorigin/matrixone/pkg/container/types"
    25  	"github.com/matrixorigin/matrixone/pkg/testutil"
    26  )
    27  
    28  func TestExtractRowFromVector(t *testing.T) {
    29  	mp := mpool.MustNewZero()
    30  	values := []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    31  	rowCount := len(values)
    32  	vec := testutil.NewVector(rowCount, types.New(types.T_bit, 10, 0), mp, false, values)
    33  
    34  	for rowIdx := 0; rowIdx < rowCount; rowIdx++ {
    35  		columnIdx := 0
    36  		row := make([]interface{}, 1)
    37  		err := extractRowFromVector(context.TODO(), nil, vec, columnIdx, row, rowIdx, false)
    38  		require.NoError(t, err)
    39  		require.Equal(t, row[columnIdx].(uint64), values[rowIdx])
    40  	}
    41  }