]> code.delx.au - offlineimap/blob - testsrc/TestConnection.hs
e513557c9ac19dcf89594ec82e047ee542142342
[offlineimap] / testsrc / TestConnection.hs
1 {-
2 Copyright (C) 2002-2008 John Goerzen <jgoerzen@complete.org>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -}
18 module TestConnection where
19 import qualified Data.Map as Map
20 import Data.List
21 import qualified Test.HUnit as HU
22 import Test.HUnit.Utils
23 import Data.Word
24 import Test.QuickCheck
25 import TestInfrastructure
26
27 import Network.IMAP.Connection
28
29 prop_identity :: String -> Bool
30 prop_identity f = runStringConnection f (\_ -> return ()) == ((), (f, []))
31
32 prop_linesidentity :: String -> Bool
33 prop_linesidentity f =
34 runLinesConnection [f] (\_ -> return ()) == ((), (f ++ "\r\n", []))
35
36 prop_lineslistidentity :: String -> Bool
37 prop_lineslistidentity f =
38 runLinesConnection f (\_ -> return ()) == ((),
39
40 q :: Testable a => String -> a -> HU.Test
41 q = qccheck (defaultConfig {configMaxTest = 250})
42
43 allt = [q "Identity" prop_identity,
44 q "Lines identity" prop_linesidentity,
45 ]