github.com/matrixorigin/matrixone@v0.7.0/pkg/sql/plan/function/builtin/multi/uuid_test.go (about)

     1  // Copyright 2021 - 2022 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 multi
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/matrixorigin/matrixone/pkg/container/types"
    21  	"github.com/matrixorigin/matrixone/pkg/container/vector"
    22  	"github.com/matrixorigin/matrixone/pkg/testutil"
    23  	"github.com/stretchr/testify/require"
    24  )
    25  
    26  // test return multi line
    27  func TestUUID(t *testing.T) {
    28  	//scalar
    29  	vec := testutil.MakeScalarNull(types.T_int8, 5)
    30  	proc := testutil.NewProc()
    31  	res, err := UUID([]*vector.Vector{vec}, proc)
    32  	if err != nil {
    33  		t.Fatal(err)
    34  	}
    35  
    36  	uuids := vector.GetStrVectorValues(res)
    37  
    38  	for i := 0; i < 5; i++ {
    39  		for j := 0; j < 5; j++ {
    40  			if i == j {
    41  				continue
    42  			}
    43  			require.NotEqual(t, uuids[i], uuids[j])
    44  		}
    45  	}
    46  }
    47  
    48  // test return one line
    49  func TestUUID2(t *testing.T) {
    50  	//scalar
    51  	vec := testutil.MakeScalarInt64(1, 1)
    52  	proc := testutil.NewProc()
    53  	res, err := UUID([]*vector.Vector{vec}, proc)
    54  	if err != nil {
    55  		t.Fatal(err)
    56  	}
    57  
    58  	uuids := vector.GetStrVectorValues(res)
    59  
    60  	require.Equal(t, len(uuids), 1)
    61  	t.Log(uuids[0])
    62  }