您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Day6Spec.hs 1.5KB

1234567891011121314151617181920212223242526272829303132333435
  1. module Day6Spec (spec) where
  2. import Test.Hspec
  3. import Day6
  4. spec :: Spec
  5. spec =
  6. describe "Day6" $ do
  7. describe "Part1" $ do
  8. it "finds unique lists" $ do
  9. isUnique "abc" `shouldBe` True
  10. isUnique "abca" `shouldBe` False
  11. isUnique "cabc" `shouldBe` False
  12. it "finds the marker in the next iteration" $ do
  13. findMarker' 4 3 "abc" "d" `shouldBe` Just 4
  14. findMarker' 4 4 "bcd" "e" `shouldBe` Just 5
  15. it "finds nothing if nothing is there" $ do
  16. findMarker "abcb" `shouldBe` Nothing
  17. findMarker "abcabcb" `shouldBe` Nothing
  18. it "finds the marker in the beginning" $ do
  19. findMarker "abcd" `shouldBe` Just 4
  20. findMarker "aabcd" `shouldBe` Just 5
  21. it "finds a marker" $ do
  22. findMarker "mjqjpqmgbljsphdztnvjfqwrcgsmlb"`shouldBe` Just 7
  23. findMarker "bvwbjplbgvbhsrlpgdmjqwftvncz" `shouldBe` Just 5
  24. findMarker "nppdvjthqldpwncqszvftbrmjlhg" `shouldBe` Just 6
  25. findMarker "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" `shouldBe` Just 10
  26. findMarker "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" `shouldBe` Just 11
  27. describe "Part 2" $ do
  28. it "finds start of message marker" $ do
  29. findStart "mjqjpqmgbljsphdztnvjfqwrcgsmlb"`shouldBe` Just 19
  30. findStart "bvwbjplbgvbhsrlpgdmjqwftvncz" `shouldBe` Just 23
  31. findStart "nppdvjthqldpwncqszvftbrmjlhg" `shouldBe` Just 23
  32. findStart "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" `shouldBe` Just 29
  33. findStart "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" `shouldBe` Just 26