7 import Test.Framework (Test, testGroup)
8 import Test.Framework.Providers.HUnit (testCase)
9 import Test.HUnit (Assertion, assertEqual)
10 import Text.HTML.TagSoup.Entity (lookupEntity)
12 replace_entities :: String -> String
13 replace_entities [] = []
14 replace_entities ('&':xs) =
15 let (b, a) = break (== ';') xs in
16 case (lookupEntity b, a) of
17 (Just c, ';':as) -> c : replace_entities as
18 _ -> '&' : replace_entities xs
19 replace_entities (x:xs) = x : replace_entities xs
24 testGroup "HTML Tests" [ tc1 ]
27 "All entities are replaced correctly."
30 test_replace_entities :: Assertion
31 test_replace_entities =
32 assertEqual description expected_text actual_text
34 description = "All entities are replaced correctly."
37 ""The moon is gay……" " ++
38 "said <insert the current president of the " ++
39 "United States of America>. “It’s " ++
40 "OK—–he’s not a real doctor.”"
42 "\"The moon is gay……\" said <insert " ++
43 "the current president of the United States of America>. " ++
44 "“It’s OK—–he’s not a real doctor.”"