Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Spec.hs 996B

12345678910111213141516171819202122232425
  1. {-# LANGUAGE OverloadedStrings #-}
  2. import Test.Hspec
  3. import Day1
  4. import Day1.Internal
  5. import qualified Data.Text as T
  6. main :: IO ()
  7. main = hspec $ do
  8. describe "Day1" $ do
  9. it "sorts elves" $ do
  10. let input = [ elf 6000, elf 4000, elf 11000]
  11. sortElves input `shouldBe` [ elf 11000, elf 6000, elf 4000]
  12. it "converts a list of strings to a list of either int or caloriecount" $ do
  13. input <- readFile "ressources/day01-input-test"
  14. parseElfInput (T.pack input) `shouldBe`
  15. [ elf 6000, elf 4000, elf 11000, elf 24000, elf 10000 ]
  16. it "parser text to int" $ do
  17. intOrZero "1000" `shouldBe` 1000
  18. it "finds the elf with the highest calorie count" $ do
  19. input <- readFile "ressources/day01-input-test"
  20. findElfWithHighestCalorieCount (T.pack input) `shouldBe` elf 24000
  21. it "sums the calorie counts" $ do
  22. input <- readFile "ressources/day01-input-test"
  23. findCaloriesOfTop3Elves (T.pack input) `shouldBe` calories 45000