github.com/matrixorigin/matrixone@v1.2.0/pkg/testutil/util_new_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 testutil 16 17 import ( 18 "testing" 19 20 "github.com/matrixorigin/matrixone/pkg/common/mpool" 21 "github.com/matrixorigin/matrixone/pkg/container/types" 22 "github.com/stretchr/testify/require" 23 ) 24 25 const ( 26 Rows = 10 27 ) 28 29 func TestNewBatch(t *testing.T) { 30 m := mpool.MustNewZero() 31 bat := NewBatch([]types.Type{types.New(types.T_int8, 0, 0)}, true, Rows, m) 32 bat.Clean(m) 33 require.Equal(t, int64(0), m.CurrNB()) 34 } 35 36 func TestVector(t *testing.T) { 37 m := mpool.MustNewZero() 38 { 39 vec := NewVector(Rows, types.New(types.T_bool, 0, 0), m, true, nil) 40 vec.Free(m) 41 } 42 { 43 vec := NewVector(Rows, types.New(types.T_int8, 0, 0), m, true, nil) 44 vec.Free(m) 45 } 46 { 47 vec := NewVector(Rows, types.New(types.T_int16, 0, 0), m, true, nil) 48 vec.Free(m) 49 } 50 { 51 vec := NewVector(Rows, types.New(types.T_int32, 0, 0), m, true, nil) 52 vec.Free(m) 53 } 54 { 55 vec := NewVector(Rows, types.New(types.T_int64, 0, 0), m, true, nil) 56 vec.Free(m) 57 } 58 { 59 vec := NewVector(Rows, types.New(types.T_uint8, 0, 0), m, true, nil) 60 vec.Free(m) 61 } 62 { 63 vec := NewVector(Rows, types.New(types.T_uint16, 0, 0), m, true, nil) 64 vec.Free(m) 65 } 66 { 67 vec := NewVector(Rows, types.New(types.T_uint32, 0, 0), m, true, nil) 68 vec.Free(m) 69 } 70 { 71 vec := NewVector(Rows, types.New(types.T_uint64, 0, 0), m, true, nil) 72 vec.Free(m) 73 } 74 { 75 vec := NewVector(Rows, types.New(types.T_date, 0, 0), m, true, nil) 76 vec.Free(m) 77 } 78 { 79 vec := NewVector(Rows, types.New(types.T_time, 0, 0), m, true, nil) 80 vec.Free(m) 81 } 82 { 83 vec := NewVector(Rows, types.New(types.T_datetime, 0, 0), m, true, nil) 84 vec.Free(m) 85 } 86 { 87 vec := NewVector(Rows, types.New(types.T_timestamp, 0, 0), m, true, nil) 88 vec.Free(m) 89 } 90 { 91 vec := NewVector(Rows, types.New(types.T_float32, 0, 0), m, true, nil) 92 vec.Free(m) 93 } 94 { 95 vec := NewVector(Rows, types.New(types.T_float64, 0, 0), m, true, nil) 96 vec.Free(m) 97 } 98 { 99 vec := NewVector(Rows, types.New(types.T_decimal64, 0, 0), m, true, nil) 100 vec.Free(m) 101 } 102 { 103 vec := NewVector(Rows, types.New(types.T_decimal128, 0, 0), m, true, nil) 104 vec.Free(m) 105 } 106 { 107 vec := NewVector(Rows, types.New(types.T_char, 0, 0), m, true, nil) 108 vec.Free(m) 109 } 110 { 111 vec := NewVector(Rows, types.New(types.T_json, 0, 0), m, true, nil) 112 vec.Free(m) 113 } 114 require.Equal(t, int64(0), m.CurrNB()) 115 }