選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Day4Spec.hs 927B

1234567891011121314151617181920212223242526272829303132333435
  1. {-# LANGUAGE QuasiQuotes #-}
  2. module Day4Spec (spec) where
  3. import Test.Hspec
  4. import Text.Heredoc
  5. import Day4.Part1
  6. import Day4.Part2
  7. import Day4.Shared
  8. inputPart1 :: String
  9. inputPart1 = [str|2-4,6-8
  10. |2-3,4-5
  11. |5-7,7-9
  12. |2-8,3-7
  13. |6-6,4-6
  14. |2-6,4-8
  15. |]
  16. spec :: Spec
  17. spec =
  18. describe "Day4" $ do
  19. describe "Part 1" $ do
  20. it "parses section" $ do
  21. section "2-4" `shouldBe` 2 +=+ 4
  22. it "parses section pair" $ do
  23. elfPair "2-4,6-8" ` shouldBe` (2 +=+ 4, 6 +=+ 8)
  24. it "finds fully overlapping sections" $ do
  25. isFullyOverlapping (3 +=+ 6, 4 +=+ 6) `shouldBe` True
  26. it "counts fully overlapping pairs" $ do
  27. countFullyOverlappingPairs inputPart1 `shouldBe` 2
  28. describe "Part 2" $ do
  29. it "counts overlapping pairs" $ do
  30. countOverlappingPairs inputPart1 `shouldBe` 4