-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathremove_at_test.go
More file actions
50 lines (36 loc) · 986 Bytes
/
remove_at_test.go
File metadata and controls
50 lines (36 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package underscore_test
import (
"testing"
"github.com/stretchr/testify/assert"
u "github.com/rjNemo/underscore"
)
func TestRemoveAt(t *testing.T) {
nums := []int{1, 9, 2, 8, 3, 7, 4, 6, 5}
want := []int{1, 9, 2, 3, 7, 4, 6, 5}
assert.Equal(t, want, u.RemoveAt(nums, 3))
}
func TestRemoveAtFirst(t *testing.T) {
nums := []int{1, 2, 3, 4, 5}
want := []int{2, 3, 4, 5}
assert.Equal(t, want, u.RemoveAt(nums, 0))
}
func TestRemoveAtLast(t *testing.T) {
nums := []int{1, 2, 3, 4, 5}
want := []int{1, 2, 3, 4}
assert.Equal(t, want, u.RemoveAt(nums, 4))
}
func TestRemoveAtOutOfBounds(t *testing.T) {
nums := []int{1, 2, 3}
// Negative index
assert.Equal(t, nums, u.RemoveAt(nums, -1))
// Index too large
assert.Equal(t, nums, u.RemoveAt(nums, 10))
}
func TestRemoveAtEmpty(t *testing.T) {
result := u.RemoveAt([]int{}, 0)
assert.Empty(t, result)
}
func TestRemoveAtSingleElement(t *testing.T) {
result := u.RemoveAt([]int{42}, 0)
assert.Empty(t, result)
}