-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestGlobber.hs
46 lines (40 loc) · 1.62 KB
/
TestGlobber.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Main (main) where
import Test.Hspec
import Globber
main :: IO ()
main = hspec $ describe "Testing Globber" $ do
describe "empty pattern" $ do
it "matches empty string" $
matchGlob "" "" `shouldBe` True
it "shouldn't match non-empty string" $
matchGlob "" "string" `shouldBe` False
describe "literal match" $ do
it "matches single character" $
matchGlob "a" "a" `shouldBe` True
it "should not match wrong character" $
matchGlob "a" "b" `shouldBe` False
it "should not match empty string" $
matchGlob "a" "" `shouldBe` False
it "should not match empty pattern" $
matchGlob "" "a" `shouldBe` False
it "should match string" $
matchGlob "abcd" "abcd" `shouldBe` True
it "should not match wrong string" $
matchGlob "abcd" "ebcd" `shouldBe` False
it "should not match wrong string" $
matchGlob "abcd" "abce" `shouldBe` False
it "should not match string of wrong length" $
matchGlob "abcd" "abcde" `shouldBe` False
it "should not match string of wrong length" $
matchGlob "abcde" "abcd" `shouldBe` False
it "should not match string of wrong length" $
matchGlob "bcd" "abcd" `shouldBe` False
it "should not match string of wrong length" $
matchGlob "abcd" "bcd" `shouldBe` False
describe "? match" $ do
it "should match single character" $
matchGlob "?" "a" `shouldBe` True
it "should match string" $
matchGlob "a?c" "abc" `shouldBe` True
it "should not match wrong length" $
matchGlob "ab?c" "abc" `shouldBe` False