|
1 | | -// Package lslice |
| 1 | +// Package gslice |
2 | 2 | // Author: hyphen |
3 | 3 | // Copyright 2023 hyphen. All rights reserved. |
4 | 4 | // Create-time: 2023/12/4 |
5 | | -package lslice_test |
| 5 | +package gslice_test |
6 | 6 |
|
7 | 7 | import ( |
8 | 8 | "strconv" |
9 | 9 | "testing" |
10 | 10 |
|
| 11 | + "github.com/hyphennn/glamda/gslice" |
11 | 12 | "github.com/hyphennn/glamda/internal/assert" |
12 | | - "github.com/hyphennn/glamda/lslice" |
13 | 13 | ) |
14 | 14 |
|
15 | 15 | func TestMap(t *testing.T) { |
16 | 16 | assert.Equal(t, |
17 | | - lslice.Map([]int{1, 1, 4, 5, 1, 4}, strconv.Itoa), |
| 17 | + gslice.Map([]int{1, 1, 4, 5, 1, 4}, strconv.Itoa), |
18 | 18 | []string{"1", "1", "4", "5", "1", "4"}, |
19 | 19 | ) |
20 | 20 | } |
21 | 21 |
|
22 | 22 | func TestToMap(t *testing.T) { |
23 | 23 | assert.Equal(t, |
24 | 24 | map[int]bool{1: true, 4: true, 5: true}, |
25 | | - lslice.ToMap([]int{1, 1, 4, 5, 1, 4}, func(f int) (int, bool) { return f, true }), |
| 25 | + gslice.ToMap([]int{1, 1, 4, 5, 1, 4}, func(f int) (int, bool) { return f, true }), |
26 | 26 | ) |
27 | 27 | } |
28 | 28 |
|
29 | 29 | func TestTryMap(t *testing.T) { |
30 | | - m, err := lslice.TryMap([]string{"1", "1", "4", "5", "1", "4"}, strconv.Atoi) |
| 30 | + m, err := gslice.TryMap([]string{"1", "1", "4", "5", "1", "4"}, strconv.Atoi) |
31 | 31 | assert.Nil(t, err) |
32 | 32 | assert.Equal(t, m, []int{1, 1, 4, 5, 1, 4}) |
33 | 33 |
|
34 | | - m2, err := lslice.TryMap([]string{"1", "1", "4", "5a", "1", "4"}, strconv.Atoi) |
| 34 | + m2, err := gslice.TryMap([]string{"1", "1", "4", "5a", "1", "4"}, strconv.Atoi) |
35 | 35 | t.Log(err) |
36 | 36 | assert.NotNil(t, err) |
37 | 37 | assert.Equal(t, m2, []int{1, 1, 4}) |
38 | 38 | } |
39 | 39 |
|
40 | 40 | func TestFilter(t *testing.T) { |
41 | 41 | assert.Equal(t, |
42 | | - lslice.Filter([]int{1, 1, 4, 5, 1, 4}, func(i int) bool { |
| 42 | + gslice.Filter([]int{1, 1, 4, 5, 1, 4}, func(i int) bool { |
43 | 43 | return i%2 == 1 |
44 | 44 | }), |
45 | 45 | []int{1, 1, 5, 1}, |
|
0 commit comments