Revision 61899e64
b/htest/Test/Ganeti/Attoparsec.hs | ||
---|---|---|
25 | 25 |
|
26 | 26 |
module Test.Ganeti.Attoparsec (testAttoparsec) where |
27 | 27 |
|
28 |
import Test.QuickCheck
|
|
28 |
import Test.HUnit
|
|
29 | 29 |
|
30 | 30 |
import Test.Ganeti.TestHelper |
31 |
import Test.Ganeti.TestCommon |
|
32 | 31 |
|
33 | 32 |
import qualified Data.Attoparsec.Text as A |
34 | 33 |
import Data.Attoparsec.Text (Parser) |
... | ... | |
55 | 54 |
|
56 | 55 |
-- | Tests whether a Unicode string is still Unicode after being |
57 | 56 |
-- parsed. |
58 |
prop_parserSupportsUnicode :: Property |
|
59 |
prop_parserSupportsUnicode = case A.parseOnly simpleParser text of |
|
60 |
Right (name, value) -> (name ==? part1) .&&. (value ==? part2) |
|
61 |
Left msg -> failTest $ "Failed to parse: " ++ msg |
|
57 |
case_unicodeParsing :: Assertion |
|
58 |
case_unicodeParsing = |
|
59 |
case A.parseOnly simpleParser text of |
|
60 |
Right (name, value) -> do |
|
61 |
assertEqual "name part" part1 name |
|
62 |
assertEqual "value part" part2 value |
|
63 |
Left msg -> assertFailure $ "Failed to parse: " ++ msg |
|
62 | 64 |
where text = Data.Text.pack $ part1 ++ " = \t" ++ part2 |
63 | 65 |
|
64 | 66 |
testSuite "Attoparsec" |
65 |
[ 'prop_parserSupportsUnicode
|
|
67 |
[ 'case_unicodeParsing
|
|
66 | 68 |
] |
Also available in: Unified diff