day1
This commit is contained in:
25
test/Spec.hs
Normal file
25
test/Spec.hs
Normal file
@@ -0,0 +1,25 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
import Test.Hspec
|
||||
import Day1
|
||||
import Day1.Internal
|
||||
import qualified Data.Text as T
|
||||
|
||||
main :: IO ()
|
||||
main = hspec $ do
|
||||
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"
|
||||
elfToCalories (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
|
||||
|
||||
Reference in New Issue
Block a user