-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patheach_test.go
More file actions
33 lines (24 loc) · 689 Bytes
/
each_test.go
File metadata and controls
33 lines (24 loc) · 689 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
package underscore_test
import (
"fmt"
"testing"
"github.com/rjNemo/underscore"
"github.com/stretchr/testify/assert"
)
func TestEach(t *testing.T) {
names := []string{"Alice", "Bob", "Charles"}
want := []string{"Hi Alice", "Hi Bob", "Hi Charles"}
res := make([]string, 0)
underscore.Each(names, func(n string) {
res = append(res, fmt.Sprintf("Hi %s", n))
})
assert.Equal(t, want, res)
}
func TestEachReturnsInitialSlice(t *testing.T) {
names := []string{"Alice", "Bob", "Charles"}
want := []string{"Alice", "Bob", "Charles"}
res := make([]string, 0)
assert.Equal(t, want, underscore.Each(names, func(n string) {
res = append(res, fmt.Sprintf("Hi %s", n))
}))
}