on master help sign in
Some more tests. Fixed split function.
a532352Jasper Van der Jeugt
src/Text/Hakyll/Util.hs+2−1
@@ -25,4 +25,5 @@ stripHTML str = let (beforeTag, rest) = break (== '<') str
25
25
26-- | Split a list at a certain element.
26-- | Split a list at a certain element.
27split :: String -> String -> [String]
27split :: String -> String -> [String]
28+split pattern = filter (not . null)
28−split pattern = splitRegex (mkRegex pattern)
29+ . splitRegex (mkRegex pattern)
tests/Tests.hs+6
@@ -17,6 +17,8 @@ tests = [ testGroup "Util group" [ testProperty "trim length" prop_trim_length
17 , testCase "stripHTML 1" test_strip_html1
17 , testCase "stripHTML 1" test_strip_html1
18 , testCase "stripHTML 2" test_strip_html2
18 , testCase "stripHTML 2" test_strip_html2
19 , testCase "stripHTML 3" test_strip_html3
19 , testCase "stripHTML 3" test_strip_html3
20+ , testCase "split 1" test_split1
21+ , testCase "split 2" test_split2
20 ]
22 ]
21
23
22 , testGroup "CompressCSS group" [ testProperty "compressCSS length" prop_compress_css_length
24 , testGroup "CompressCSS group" [ testProperty "compressCSS length" prop_compress_css_length
@@ -44,6 +46,10 @@ test_strip_html2 = stripHTML "text" @?= "text"
44test_strip_html3 = stripHTML "<b>Hakyll</b> is an <i>awesome</i> web framework <img src=\"foo.png\" />" @?=
46test_strip_html3 = stripHTML "<b>Hakyll</b> is an <i>awesome</i> web framework <img src=\"foo.png\" />" @?=
45 "Hakyll is an awesome web framework "
47 "Hakyll is an awesome web framework "
46
48
49+-- Split test cases.
50+test_split1 = split "," "1,2,3" @?= ["1", "2", "3"]
51+test_split2 = split "," ",1,2," @?= ["1", "2"]
52+
47-- CSS compression should always decrease the text length.
53-- CSS compression should always decrease the text length.
48prop_compress_css_length str = length str >= length (compressCSS str)
54prop_compress_css_length str = length str >= length (compressCSS str)
49
55