Skip to content

Commit de98ef4

Browse files
committed
feat: add tests for TestExtractIntRows
1 parent a594d07 commit de98ef4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

internal/inputs/inputs_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package inputs
22

33
import (
4+
"reflect"
45
"slices"
56
"testing"
67
)
@@ -53,3 +54,34 @@ func TestExtractIntPairs(t *testing.T) {
5354
}
5455
})
5556
}
57+
58+
func TestExtractIntRows(t *testing.T) {
59+
t.Run("empty input", func(t *testing.T) {
60+
input := ``
61+
_, err := ExtractIntRows(input)
62+
63+
if err == nil {
64+
t.Errorf("expected an error, didnt get one")
65+
}
66+
})
67+
68+
t.Run("invalid line", func(t *testing.T) {
69+
input := `123 abc`
70+
_, err := ExtractIntRows(input)
71+
72+
if err == nil {
73+
t.Errorf("expected an error, didnt get one")
74+
}
75+
})
76+
77+
t.Run("numbers separated by tabs", func(t *testing.T) {
78+
input := "1 2\t3\n4\t5 6"
79+
want := [][]int{{1, 2, 3}, {4, 5, 6}}
80+
81+
got, _ := ExtractIntRows(input)
82+
83+
if !reflect.DeepEqual(got, want) {
84+
t.Errorf("got %v, want %v", got, want)
85+
}
86+
})
87+
}

0 commit comments

Comments
 (0)