this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 45 lines 1.4 kB view raw
1module AocDay02Part2Spec (main, spec) where 2 3import Test.Hspec 4import Test.QuickCheck 5 6import Data.List.Split 7 8import AocDay02Part2 9 10-- `main` is here so that this module can be run from GHCi on its own. It is 11-- not needed for automatic spec discovery. 12main :: IO () 13main = hspec spec 14 15spec :: Spec 16spec = let start = locationFromChar '5' in do 17 describe "locationFromLine" $ do 18 it "handles single lines" $ do 19 locationFromLine start "U" `shouldBe` (0, 2) 20 locationFromLine start "D" `shouldBe` (0, 2) 21 locationFromLine start "L" `shouldBe` (0, 2) 22 locationFromLine start "R" `shouldBe` (1, 2) 23 24 it "ignores unknown characters" $ do 25 locationFromLine start "X" `shouldBe` (0, 2) 26 locationFromLine start "*" `shouldBe` (0, 2) 27 28 it "handles multiple moves" $ do 29 locationFromLine start "X" `shouldBe` (0, 2) 30 locationFromLine start "RR" `shouldBe` (2, 2) 31 locationFromLine start "RRUUU" `shouldBe` (2, 0) 32 locationFromLine start "RRUUUL" `shouldBe` (2, 0) 33 34 describe "codeFromLines" $ do 35 it "handles single lines" $ do 36 codeFromLines ["UL"] `shouldBe` "5" 37 codeFromLines ["RRRU"] `shouldBe` "4" 38 39 it "handles two lines" $ do 40 codeFromLines ["UL", "RRRU"] `shouldBe` "54" 41 codeFromLines ["RD", "RRRULUU"] `shouldBe` "A1" 42 43 it "handles example input from AoC" $ 44 let lines = "ULL\nRRDDD\nLURDL\nUUUUD" 45 in codeFromLines (splitOn "\n" lines) `shouldBe` "5DB3"