github.com/searKing/golang/go@v1.2.117/exp/slices/reverse_test.go (about) 1 // Copyright 2022 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package slices_test 6 7 import ( 8 "fmt" 9 "slices" 10 "testing" 11 12 slices_ "github.com/searKing/golang/go/exp/slices" 13 ) 14 15 func TestReverse(t *testing.T) { 16 tests := []struct { 17 data []int 18 want []int 19 }{ 20 {nil, nil}, 21 {[]int{}, []int{}}, 22 {[]int{0}, []int{0}}, 23 {[]int{1, 0}, []int{0, 1}}, 24 {[]int{2, 1, 0}, []int{0, 1, 2}}, 25 } 26 for _, tt := range tests { 27 t.Run(fmt.Sprintf("%v", tt.data), func(t *testing.T) { 28 { 29 slices_.Reverse(tt.data) 30 if !slices.Equal(tt.data, tt.want) { 31 t.Errorf("reversed %v", tt.want) 32 t.Errorf(" got %v", tt.data) 33 } 34 } 35 }) 36 } 37 }