~singpolyma/cheogram-smtp

c31e9738d56e6a74515417c00e77245455e7539b — Stephen Paul Weber 2 years ago c7e8080
Update tests for released network-protocol-xmpp
2 files changed, 28 insertions(+), 12 deletions(-)

M cheogram-smtp.cabal
M test/TestInstances.hs
M cheogram-smtp.cabal => cheogram-smtp.cabal +3 -1
@@ 53,4 53,6 @@ test-suite test
                       tasty-quickcheck,
                       tasty-discover,
                       quickcheck-instances,
                       generic-arbitrary
                       generic-arbitrary,
                       gnuidn,
                       QuickCheck

M test/TestInstances.hs => test/TestInstances.hs +25 -11
@@ 1,9 1,14 @@
module TestInstances where

import Control.Error (hush)
import Test.QuickCheck.Gen (suchThatMap, elements)
import Test.QuickCheck.Instances ()
import Test.QuickCheck.Arbitrary.Generic
import qualified Network.Protocol.XMPP as XMPP
import qualified Data.MIME as MIME
import qualified Data.XML.Types as XML
import qualified Network.Protocol.XMPP as XMPP
import qualified Network.Protocol.XMPP.Internal as XMPP
import qualified Data.Text.IDN.StringPrep as SP

instance Arbitrary XML.Instruction where
	arbitrary = genericArbitrary


@@ 26,25 31,34 @@ instance Arbitrary XML.Element where
	shrink = genericShrink

instance Arbitrary XMPP.Resource where
	arbitrary = genericArbitrary
	shrink = genericShrink
	arbitrary = XMPP.Resource <$> suchThatMap arbitrary
		(hush . SP.stringprep SP.xmppResource SP.defaultFlags)

instance Arbitrary XMPP.Domain where
	arbitrary = genericArbitrary
	shrink = genericShrink
	arbitrary = XMPP.Domain <$> suchThatMap arbitrary
		(hush . SP.stringprep SP.nameprep SP.defaultFlags)

instance Arbitrary XMPP.Node where
	arbitrary = genericArbitrary
	shrink = genericShrink
	arbitrary = XMPP.Node <$> suchThatMap arbitrary
		(hush . SP.stringprep SP.xmppNode SP.defaultFlags)

instance Arbitrary XMPP.JID where
	arbitrary = genericArbitrary
	shrink = genericShrink
	arbitrary = XMPP.JID <$> arbitrary <*> arbitrary <*> arbitrary

instance Arbitrary XMPP.IQType where
	arbitrary = genericArbitrary
	shrink = genericShrink
	arbitrary = elements [
			XMPP.IQGet, XMPP.IQSet, XMPP.IQResult, XMPP.IQError
		]

instance Arbitrary XMPP.IQ where
	arbitrary = XMPP.IQ <$>
		arbitrary <*>
		arbitrary <*>
		arbitrary <*>
		arbitrary <*>
		arbitrary <*>
		arbitrary

instance Arbitrary MIME.Domain where
	arbitrary = genericArbitrary
	shrink = genericShrink