This commit is contained in:
Jens Kadenbach
2022-12-16 15:59:43 +01:00
parent 714980da64
commit 26e6851eec
6 changed files with 211 additions and 1 deletions

30
test/Day12Spec.hs Normal file
View File

@@ -0,0 +1,30 @@
{-# LANGUAGE QuasiQuotes #-}
module Day12Spec (spec) where
import Day12
import Test.Hspec
import Text.Heredoc
import Data.Maybe (fromJust, isJust)
testInput :: String
testInput = [str|Sabqponm
|abcryxxl
|accszExk
|acctuvwj
|abdefghi
|]
spec :: Spec
spec =
describe "Day12" $ do
describe "Part1" $ do
it "finds a path" $ do
let (points, grid) = parseGrid testInput
let result = findPath grid points
isJust result `shouldBe` True
fst (fromJust result) `shouldBe` 31
it "finds shortest paths from all lowest points" $ do
let (points, grid) = parseGrid testInput
let fastest = findBestPath grid points
fst fastest `shouldBe` 29