{-# OPTIONS -fno-warn-missing-signatures #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE
EmptyDataDecls
, OverloadedStrings
, ScopedTypeVariables
, TemplateHaskell
, TypeFamilies
#-}
module Main (main) where
import Test.Tasty
import GHC.Generics (Generic)
import Test.Tasty.HUnit
import Test.Tasty.TH
import Text.XML.HXT.Arrow.Pickle
import PickleUtils
import Generics.XmlPickler
data SingleCons = SingleCons deriving (Show, Eq, Generic)
instance XmlPickler SingleCons where xpickle = gxpickle
bidir :: (Show a, Eq a, XmlPickler a) => String -> a -> IO ()
bidir s d = do
eq s (toXML d)
eq (Right d) (eitherFromXML s)
eq (Right d) (encDec d)
encDec :: XmlPickler a => a -> Either String a
encDec = eitherFromXML . toXML
eq :: (Show a, Eq a) => a -> a -> Assertion
eq = (@=?)
case_constructorWithoutFields =
bidir "
123
" (P [1,2,3]) data Q = Q Int Int Int deriving (Show, Eq, Generic) instance XmlPickler Q where xpickle = gxpickle --case_ConstructorSameTypedFields = -- bidir "123" (Q 1 2 3) data T = T { r1 :: Maybe Int } deriving (Show, Eq, Generic) instance XmlPickler T where xpickle = gxpickle case_RecordMaybeField = do bidir "