github.com/dubbogo/gost@v1.14.0/sort/sort_test.go (about)

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   * contributor license agreements.  See the NOTICE file distributed with
     4   * this work for additional information regarding copyright ownership.
     5   * The ASF licenses this file to You under the Apache License, Version 2.0
     6   * (the "License"); you may not use this file except in compliance with
     7   * the License.  You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  
    18  package gxsort
    19  
    20  import (
    21  	"testing"
    22  )
    23  
    24  import (
    25  	"github.com/stretchr/testify/assert"
    26  )
    27  
    28  func TestSortInt32(t *testing.T) {
    29  	data := []int32{3, 5, 1, 9, 0, 2, 2}
    30  	Int32(data)
    31  	assert.Equal(t, int32(0), data[0])
    32  	assert.Equal(t, int32(1), data[1])
    33  	assert.Equal(t, int32(2), data[2])
    34  	assert.Equal(t, int32(2), data[3])
    35  	assert.Equal(t, int32(3), data[4])
    36  	assert.Equal(t, int32(5), data[5])
    37  	assert.Equal(t, int32(9), data[6])
    38  }
    39  
    40  func TestSortInt64(t *testing.T) {
    41  	data := []int64{3, 5, 1, 9, 0, 2, 2}
    42  	Int64(data)
    43  	assert.Equal(t, int64(0), data[0])
    44  	assert.Equal(t, int64(1), data[1])
    45  	assert.Equal(t, int64(2), data[2])
    46  	assert.Equal(t, int64(2), data[3])
    47  	assert.Equal(t, int64(3), data[4])
    48  	assert.Equal(t, int64(5), data[5])
    49  	assert.Equal(t, int64(9), data[6])
    50  }
    51  
    52  func TestSortUint32(t *testing.T) {
    53  	data := []uint32{3, 5, 1, 9, 0, 2, 2}
    54  	Uint32(data)
    55  	assert.Equal(t, uint32(0), data[0])
    56  	assert.Equal(t, uint32(1), data[1])
    57  	assert.Equal(t, uint32(2), data[2])
    58  	assert.Equal(t, uint32(2), data[3])
    59  	assert.Equal(t, uint32(3), data[4])
    60  	assert.Equal(t, uint32(5), data[5])
    61  	assert.Equal(t, uint32(9), data[6])
    62  }