github.com/matrixorigin/matrixone@v0.7.0/pkg/vectorize/empty/empty_test.go (about)

     1  // Copyright 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 empty
    16  
    17  import (
    18  	"reflect"
    19  	"testing"
    20  )
    21  
    22  func TestEmpty(t *testing.T) {
    23  	tt := []struct {
    24  		name string
    25  		xs   []string
    26  		rs   []uint8
    27  		want []uint8
    28  	}{
    29  		{
    30  			name: "Not Empty",
    31  			xs:   []string{"Hello", "World", " ", "\t", "\n", "\r"},
    32  			rs:   make([]uint8, 6),
    33  			want: []uint8{0, 0, 0, 0, 0, 0},
    34  		},
    35  		{
    36  			name: "Empty",
    37  			xs:   []string{""},
    38  			rs:   make([]uint8, 1),
    39  			want: []uint8{1},
    40  		},
    41  	}
    42  
    43  	for _, tc := range tt {
    44  		t.Run(tc.name, func(t *testing.T) {
    45  			if got := Empty(tc.xs, tc.rs); !reflect.DeepEqual(got, tc.want) {
    46  				t.Errorf("Empty() = %v, want %v", got, tc.want)
    47  			}
    48  		})
    49  	}
    50  }