Skip to content

Commit

Permalink
Add failing test: parses list of strings into first and last number t…
Browse files Browse the repository at this point in the history
…uples
  • Loading branch information
samjowen committed Dec 22, 2023
1 parent b124430 commit c572354
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/day1/day1.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ defmodule Day1 do
|> String.split("\n", trim: true)
end
end

def parse_list_to_first_last_numbers(input_list) do
input_list |> Enum.map(&find_first_and_last_number/1)
end
end
9 changes: 9 additions & 0 deletions test/day1_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ defmodule Day1Test do
"third line of the file"
]
end

test "parses list of strings into first and last number tuples" do

Check failure on line 21 in test/day1_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test parses list of strings into first and last number tuples (Day1Test)
list = Day1.parse_file("./test/mocks/lines_of_text_w_numbers.txt", :string)
assert Day1.parse_list_to_first_last_numbers(list, :string) == [
{1, 3},
{4, 6},
{7, 9}
]
end
end
3 changes: 3 additions & 0 deletions test/mocks/lines_of_text_w_numbers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
abc123
efg456
hij789

0 comments on commit c572354

Please sign in to comment.