Skip to content

Instantly share code, notes, and snippets.

@ahndmal
Created July 6, 2024 09:04
Show Gist options
  • Save ahndmal/575cf43adf6d65a60e569131f54ee2cc to your computer and use it in GitHub Desktop.
Save ahndmal/575cf43adf6d65a60e569131f54ee2cc to your computer and use it in GitHub Desktop.
module SleighAuthenticationSpec where
import SleighAuthentication (authenticate)
import Test.Hspec
import Test.QuickCheck
spec :: Spec
spec = do
describe "authenticate" $ do
it "should work for some examples" $ do
expectTrue $ authenticate "Santa Claus" "Ho Ho Ho!"
expectFalse $ authenticate "Santa" "Ho Ho Ho!"
expectFalse $ authenticate "Santa Claus" "Ho Ho!"
expectFalse $ authenticate "jhoffner" "CodeWars"
it "should work for random frauds" $ do
property $ \who password ->
authenticate who password `shouldBe` solution who password
where
expectTrue = flip shouldBe True
expectFalse = flip shouldBe False
solution :: String -> String -> Bool
solution "Santa Claus" "Ho Ho Ho!" = True
solution _ _ = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment