~singpolyma/cheogram-smtp

ref: 91b56cb3edd7d5ebcbb0c11c5deca40deb4bd87d cheogram-smtp/test/TestInstances.hs -rw-r--r-- 1.7 KiB
91b56cb3Stephen Paul Weber vcard-temp for the gateway 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module TestInstances where

import Control.Error (hush)
import Test.QuickCheck.Gen (suchThatMap, elements)
import Test.QuickCheck.Instances ()
import Test.QuickCheck.Arbitrary.Generic
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
	shrink = genericShrink

instance Arbitrary XML.Node where
	arbitrary = genericArbitrary
	shrink = genericShrink

instance Arbitrary XML.Content where
	arbitrary = genericArbitrary
	shrink = genericShrink

instance Arbitrary XML.Name where
	arbitrary = genericArbitrary
	shrink = genericShrink

instance Arbitrary XML.Element where
	arbitrary = genericArbitrary
	shrink = genericShrink

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

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

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

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

instance Arbitrary XMPP.IQType where
	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