Browse Source

Split test cases in separate files

main
Annwan 3 weeks ago
parent
commit
209d872052
  1. 6
      test/1.testcase
  2. 6
      test/2.testcase
  3. 13
      test/Main.hs

6
test/1.testcase

@ -0,0 +1,6 @@
3 4
4 3
2 5
1 3
3 9
3 3

6
test/2.testcase

@ -0,0 +1,6 @@
7 6 4 2 1
1 2 7 8 9
9 7 6 2 1
1 3 2 4 5
8 6 4 4 1
1 3 6 7 9

13
test/Main.hs

@ -4,14 +4,17 @@ import Day1
import Day2 import Day2
main :: IO () main :: IO ()
main = hspec $ do
main = do
day1in <- readFile "test/1.testcase"
day2in <- readFile "test/2.testcase"
hspec $ do
describe "Day1" $ do describe "Day1" $ do
it "solves part 1" $ do it "solves part 1" $ do
Day1.part1 "3 4\n4 3\n2 5\n1 3\n3 9\n3 3\n" `shouldBe` "11"
Day1.part1 day1in `shouldBe` "11"
it "solves part 2" $ do it "solves part 2" $ do
Day1.part2 "3 4\n4 3\n2 5\n1 3\n3 9\n3 3\n" `shouldBe` "31"
Day1.part2 day1in `shouldBe` "31"
describe "Day 2" $ do describe "Day 2" $ do
it "solves part 1" $ do it "solves part 1" $ do
Day2.part1 "7 6 4 2 1\n1 2 7 8 9\n9 7 6 2 1\n1 3 2 4 5\n8 6 4 4 1\n1 3 6 7 9" `shouldBe` "2"
Day2.part1 day2in `shouldBe` "2"
it "solves part 2" $ do it "solves part 2" $ do
Day2.part2 "7 6 4 2 1\n1 2 7 8 9\n9 7 6 2 1\n1 3 2 4 5\n8 6 4 4 1\n1 3 6 7 9" `shouldBe` "4"
Day2.part2 day2in `shouldBe` "4"
Loading…
Cancel
Save