|  | 
|  | 1 | +package inputs | 
|  | 2 | + | 
|  | 3 | +import ( | 
|  | 4 | +	"slices" | 
|  | 5 | +	"testing" | 
|  | 6 | +) | 
|  | 7 | + | 
|  | 8 | +func TestExtractIntPairs(t *testing.T) { | 
|  | 9 | +	t.Run("empty input", func(t *testing.T) { | 
|  | 10 | +		input := `` | 
|  | 11 | +		_, _, err := ExtractIntPairs(input) | 
|  | 12 | + | 
|  | 13 | +		if err == nil { | 
|  | 14 | +			t.Errorf("expected an error, didnt get one") | 
|  | 15 | +		} | 
|  | 16 | +	}) | 
|  | 17 | + | 
|  | 18 | +	t.Run("invalid line", func(t *testing.T) { | 
|  | 19 | +		input := `123 456 789` | 
|  | 20 | +		_, _, err := ExtractIntPairs(input) | 
|  | 21 | + | 
|  | 22 | +		if err == nil { | 
|  | 23 | +			t.Errorf("expected an error, didnt get one") | 
|  | 24 | +		} | 
|  | 25 | +	}) | 
|  | 26 | + | 
|  | 27 | +	t.Run("invalid left column", func(t *testing.T) { | 
|  | 28 | +		input := `abc 123` | 
|  | 29 | +		_, _, err := ExtractIntPairs(input) | 
|  | 30 | + | 
|  | 31 | +		if err == nil { | 
|  | 32 | +			t.Errorf("expected an error, didnt get one") | 
|  | 33 | +		} | 
|  | 34 | +	}) | 
|  | 35 | + | 
|  | 36 | +	t.Run("invalid right column", func(t *testing.T) { | 
|  | 37 | +		input := `123 abc` | 
|  | 38 | +		_, _, err := ExtractIntPairs(input) | 
|  | 39 | + | 
|  | 40 | +		if err == nil { | 
|  | 41 | +			t.Errorf("expected an error, didnt get one") | 
|  | 42 | +		} | 
|  | 43 | +	}) | 
|  | 44 | + | 
|  | 45 | +	t.Run("test slice content", func(t *testing.T) { | 
|  | 46 | +		input := "111 222\n333 444" | 
|  | 47 | +		leftWant := []int{111, 333} | 
|  | 48 | +		rightWant := []int{222, 444} | 
|  | 49 | +		leftGot, rightGot, _ := ExtractIntPairs(input) | 
|  | 50 | + | 
|  | 51 | +		if !slices.Equal(leftGot, leftWant) || !slices.Equal(rightGot, rightWant) { | 
|  | 52 | +			t.Errorf("Expected %v, %v, got %v, %v", leftWant, leftGot, rightWant, rightGot) | 
|  | 53 | +		} | 
|  | 54 | +	}) | 
|  | 55 | +} | 
0 commit comments