Files
advent-of-code-2022/test/Day1Spec.hs
2022-12-02 11:53:44 +01:00

27 rindas
1013 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
module Day1Spec (spec) where
import Test.Hspec
import Day1
import Day1.Internal
import qualified Data.Text as T
spec :: Spec
spec =
describe "Day1" $ do
it "sorts elves" $ do
let input = [ elf 6000, elf 4000, elf 11000]
sortElves input `shouldBe` [ elf 11000, elf 6000, elf 4000]
it "converts a list of strings to a list of either int or caloriecount" $ do
input <- readFile "ressources/day01-input-test"
parseElfInput (T.pack input) `shouldBe`
[ elf 6000, elf 4000, elf 11000, elf 24000, elf 10000 ]
it "parser text to int" $ do
intOrZero "1000" `shouldBe` 1000
it "finds the elf with the highest calorie count" $ do
input <- readFile "ressources/day01-input-test"
findElfWithHighestCalorieCount (T.pack input) `shouldBe` elf 24000
it "sums the calorie counts" $ do
input <- readFile "ressources/day01-input-test"
findCaloriesOfTop3Elves (T.pack input) `shouldBe` calories 45000