Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Day1Spec.hs 1013B

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