aboutsummaryrefslogtreecommitdiff
path: root/lib/ints/ints_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2019-03-02 06:26:35 +0700
committerShulhan <ms@kilabit.info>2019-03-02 06:26:35 +0700
commit4d522fa86a8ff2c4468c7e1adff5665c405bb07c (patch)
tree9e929a79d1bad3c4dbe9b4a5c63a8823cea081ba /lib/ints/ints_test.go
parent8a5dfcccd447a9e2693bace81525d6264abccc63 (diff)
downloadpakakeh.go-4d522fa86a8ff2c4468c7e1adff5665c405bb07c.tar.xz
ints: add function to remove value from slice
The Remove function remove value "v" from slice if its exist and return new slice and true; otherwise, if not found, return unmodified slice and false.
Diffstat (limited to 'lib/ints/ints_test.go')
-rw-r--r--lib/ints/ints_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/ints/ints_test.go b/lib/ints/ints_test.go
index 58800bea..5e7111d4 100644
--- a/lib/ints/ints_test.go
+++ b/lib/ints/ints_test.go
@@ -397,3 +397,33 @@ func TestIndirectSort_SortByIndex(t *testing.T) {
test.Assert(t, "", exp, got, true)
}
+
+func TestRemove(t *testing.T) {
+ cases := []struct {
+ d []int
+ v int
+ exp []int
+ }{{
+ d: []int{},
+ v: 1,
+ exp: []int{},
+ }, {
+ d: []int{1},
+ v: 1,
+ exp: []int{},
+ }, {
+ d: []int{1, 2, 3, 4},
+ v: 5,
+ exp: []int{1, 2, 3, 4},
+ }, {
+ d: []int{1, 2, 3, 4},
+ v: 1,
+ exp: []int{2, 3, 4},
+ }}
+
+ for _, c := range cases {
+ got, _ := Remove(c.d, c.v)
+
+ test.Assert(t, "Remove", c.exp, got, true)
+ }
+}