Created
July 6, 2024 09:04
-
-
Save ahndmal/575cf43adf6d65a60e569131f54ee2cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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