Skip to content
Snippets Groups Projects
Commit 61899e64 authored by Iustin Pop's avatar Iustin Pop
Browse files

Switch Attoparsec/unicode test from QC to HUnit


This is not a quickcheck property, since it doesn't have any
variable/arbitrary inputs. So let's make it a test case, and shorten a
bit the name.

Also, sorry for not catching this in the review.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent bfbd12f7
No related branches found
No related tags found
No related merge requests found
...@@ -25,10 +25,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -25,10 +25,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Test.Ganeti.Attoparsec (testAttoparsec) where module Test.Ganeti.Attoparsec (testAttoparsec) where
import Test.QuickCheck import Test.HUnit
import Test.Ganeti.TestHelper import Test.Ganeti.TestHelper
import Test.Ganeti.TestCommon
import qualified Data.Attoparsec.Text as A import qualified Data.Attoparsec.Text as A
import Data.Attoparsec.Text (Parser) import Data.Attoparsec.Text (Parser)
...@@ -55,12 +54,15 @@ simpleParser = do ...@@ -55,12 +54,15 @@ simpleParser = do
-- | Tests whether a Unicode string is still Unicode after being -- | Tests whether a Unicode string is still Unicode after being
-- parsed. -- parsed.
prop_parserSupportsUnicode :: Property case_unicodeParsing :: Assertion
prop_parserSupportsUnicode = case A.parseOnly simpleParser text of case_unicodeParsing =
Right (name, value) -> (name ==? part1) .&&. (value ==? part2) case A.parseOnly simpleParser text of
Left msg -> failTest $ "Failed to parse: " ++ msg Right (name, value) -> do
assertEqual "name part" part1 name
assertEqual "value part" part2 value
Left msg -> assertFailure $ "Failed to parse: " ++ msg
where text = Data.Text.pack $ part1 ++ " = \t" ++ part2 where text = Data.Text.pack $ part1 ++ " = \t" ++ part2
testSuite "Attoparsec" testSuite "Attoparsec"
[ 'prop_parserSupportsUnicode [ 'case_unicodeParsing
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment