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