-
Notifications
You must be signed in to change notification settings - Fork 2
/
remove_test.go
49 lines (35 loc) · 1.15 KB
/
remove_test.go
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
package garray
import (
"log"
"testing"
)
func TestRemove(t *testing.T) {
localUsers := *ReadUserData()
log.Printf("Count: %d", len(localUsers))
log.Printf("1st user's name: %s", localUsers[0].Name)
log.Printf("2nd user's name: %s", localUsers[1].Name)
localUsers = Remove(localUsers, 0)
log.Println("First element removed")
log.Printf("Count: %d", len(localUsers))
log.Printf("1st user's name: %s", localUsers[0].Name)
}
func TestSplice(t *testing.T) {
localUsers := *ReadUserData()
log.Printf("Count: %d", len(localUsers))
log.Printf("1st user's name: %s", localUsers[0].Name)
log.Printf("5th user's name: %s", localUsers[4].Name)
localUsers = Splice(localUsers, 1, 4)
log.Println("First element removed")
log.Printf("Count: %d", len(localUsers))
log.Printf("1st user's name: %s", localUsers[0].Name)
log.Printf("2nd user's name: %s", localUsers[0].Name)
}
func TestFilter(t *testing.T) {
localUsers := *ReadUserData()
log.Printf("Count: %d", len(localUsers))
localUsers = Filter(localUsers, func(user User, _ int) bool {
return user.Age > 50
})
log.Println("Array filtered if age > 50")
log.Printf("Count: %d", len(localUsers))
}