Skip to content

Commit

Permalink
Add tests for validating game set strings with different orders and m…
Browse files Browse the repository at this point in the history
…issing colors
  • Loading branch information
samjowen committed Dec 27, 2023
1 parent 5dfb413 commit c2bde07
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/day2/day2_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,31 @@ defmodule Day2Test do

assert Day2.validate_set(thirty_cube_set_str, cube_limit) == false
end

test "it tests if a game set string with cubes in different order is valid" do
cube_limit = 29

# 29 cubes, different order
different_order_set_str = "14 blue, 7 red, 8 green"

assert Day2.validate_set(different_order_set_str, cube_limit) == true
end

test "it tests if a game set string missing a color is valid" do
cube_limit = 29

# 21 cubes, missing green
missing_color_set_str = "7 red, 14 blue"

assert Day2.validate_set(missing_color_set_str, cube_limit) == true
end

test "it tests if a game set string missing a color and exceeding the limit is invalid" do
cube_limit = 29

# 30 cubes, missing green
missing_color_exceeding_limit_set_str = "15 red, 15 blue"

assert Day2.validate_set(missing_color_exceeding_limit_set_str, cube_limit) == false
end
end

0 comments on commit c2bde07

Please sign in to comment.