-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangers_test.go
More file actions
41 lines (30 loc) · 860 Bytes
/
changers_test.go
File metadata and controls
41 lines (30 loc) · 860 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
package arrayr
import "testing"
func TestChangeTo(t *testing.T) {
intToFloat := func(i int) (r float64) {
r = float64(i)
return
}
test := ChangeTo(intToFloat, 1, 2, 3, 4, 5)
assrtEqual(t, []float64{1.0, 2.0, 3.0, 4.0, 5.0}, test)
}
func TestChangeTo2(t *testing.T) {
intToFloat := func(i int) (r float64) {
r = float64(i)
return
}
test := ChangeTo(intToFloat, []int{1, 2, 3, 4, 5}...)
assrtEqual(t, []float64{1.0, 2.0, 3.0, 4.0, 5.0}, test)
}
func TestReverse(t *testing.T) {
reverse := Reverse("apple","banana","coconut")
assrtEqual(t,3,len(reverse))
assrtEqual(t,[]string{"coconut","banana","apple"}, reverse)
}
func TestReverse2(t *testing.T) {
testArr := []int{0,1,22,2,-5,3,4}
reverse := Reverse(testArr...)
assrtEqual(t,7,len(testArr))
assrtEqual(t,7,len(reverse))
assrtEqual(t,[]int{4, 3, -5, 2, 22, 1, 0}, reverse)
}