Files
advent-of-code-2022/test/Day12Spec.hs
T
2022-12-16 15:59:43 +01:00

31 lines
782 B
Haskell

{-# 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