github.com/matrixorigin/matrixone@v0.7.0/pkg/vectorize/reverse/reverse_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  package reverse
    15  
    16  import (
    17  	"testing"
    18  
    19  	"github.com/stretchr/testify/require"
    20  )
    21  
    22  func TestReverse(t *testing.T) {
    23  	cases := []struct {
    24  		name string
    25  		args []string
    26  		want []string
    27  	}{
    28  		{
    29  			name: "English",
    30  			args: []string{"HelloWorld"},
    31  			want: []string{"dlroWolleH"},
    32  		},
    33  		{
    34  			name: "Chinese",
    35  			args: []string{"你好世界"},
    36  			want: []string{"界世好你"},
    37  		},
    38  		{
    39  			name: "Englist + Chinese",
    40  			args: []string{"Hello 世界"},
    41  			want: []string{"界世 olleH"},
    42  		},
    43  		{
    44  			name: "three strings",
    45  			args: []string{"Hello", " ", "世界"},
    46  			want: []string{"olleH", " ", "界世"},
    47  		},
    48  	}
    49  
    50  	for _, c := range cases {
    51  		t.Run(c.name, func(t *testing.T) {
    52  			out := make([]string, len(c.args))
    53  			got := Reverse(c.args, out)
    54  			require.Equal(t, c.want, got)
    55  		})
    56  	}
    57  
    58  }