github.com/seeker-insurance/kit@v0.0.13/copyslice/copyslice_test.go (about)

     1  package copyslice
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestInt(t *testing.T) {
    10  	a := []int{2, 5}
    11  	b := Int(a)
    12  	assert.Equal(t, a, b)
    13  	b[0] = 3
    14  	assert.NotEqual(t, a, b, "slices should not point to the same array")
    15  }
    16  
    17  func TestString(t *testing.T) {
    18  	a := []string{"2", "5"}
    19  	b := String(a)
    20  	assert.Equal(t, a, b)
    21  	b[0] = "3"
    22  	assert.NotEqual(t, a, b, "slices should not point to the same array")
    23  }
    24  
    25  func TestRune(t *testing.T) {
    26  	a := []rune{2, 5}
    27  	b := Rune(a)
    28  	assert.Equal(t, a, b)
    29  	b[0] = 3
    30  	assert.NotEqual(t, a, b, "slices should not point to the same array")
    31  }
    32  
    33  func TestByte(t *testing.T) {
    34  	a := []byte{'2', '5'}
    35  	b := Byte(a)
    36  	assert.Equal(t, a, b)
    37  	b[0] = '3'
    38  	assert.NotEqual(t, a, b, "slices should not point to the same array")
    39  }
    40  
    41  func TestInt64(t *testing.T) {
    42  	a := []int64{2, 5}
    43  	b := Int64(a)
    44  	assert.Equal(t, a, b)
    45  	b[0] = 3
    46  	assert.NotEqual(t, a, b, "slices should not point to the same array")
    47  }
    48  
    49  func TestFloat64(t *testing.T) {
    50  	a := []float64{2, 5}
    51  	b := Float64(a)
    52  	assert.Equal(t, a, b)
    53  	b[0] = 3
    54  	assert.NotEqual(t, a, b, "slices should not point to the same array")
    55  }