MCPcopy Index your code
hub / github.com/duke-git/lancet / TestBefore

Function TestBefore

function/function_test.go:38–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestBefore(t *testing.T) {
39 t.Parallel()
40
41 assert := internal.NewAssert(t, "TestBefore")
42
43 arr := []string{"a", "b", "c", "d", "e"}
44 f := Before(3, func(i int) int {
45 return i
46 })
47
48 var res []int64
49 type cb func(args ...any) []reflect.Value
50 appendStr := func(i int, _ string, fn cb) {
51 v := fn(i)
52 res = append(res, v[0].Int())
53 }
54
55 for i := 0; i < len(arr); i++ {
56 appendStr(i, arr[i], f)
57 }
58
59 expected := []int64{0, 1, 2, 2, 2}
60 assert.Equal(expected, res)
61}
62
63func TestCurry(t *testing.T) {
64 t.Parallel()

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.95
NewAssertFunction · 0.92
BeforeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…