MCPcopy Create free account
hub / github.com/go-task/task / TestConvertStringToInt

Function TestConvertStringToInt

internal/slicesext/slicesext_test.go:26–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24}
25
26func TestConvertStringToInt(t *testing.T) {
27 t.Parallel()
28 input := []string{"1", "2", "3", "4", "5"}
29 expected := []int{1, 2, 3, 4, 5}
30 result := Convert(input, func(s string) int {
31 n, _ := strconv.Atoi(s)
32 return n
33 })
34
35 if len(result) != len(expected) {
36 t.Errorf("Expected length %d, got %d", len(expected), len(result))
37 }
38
39 for i := range expected {
40 if result[i] != expected[i] {
41 t.Errorf("At index %d: expected %v, got %v", i, expected[i], result[i])
42 }
43 }
44}
45
46func TestConvertFloatToInt(t *testing.T) {
47 t.Parallel()

Callers

nothing calls this directly

Calls 1

ConvertFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…