summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-05-14 12:01:47 +0400
committerSam T <pxqr.sta@gmail.com>2013-05-14 12:01:47 +0400
commitdca81a23bcec19ab7562322c2eb988b286afe944 (patch)
treec2354fabaf9dc27b70368a68020cb9cf9bc57b47 /tests
parent50490ccb9ac98dc03a499972e693da8514779be6 (diff)
+ Add hunit tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/Client.hs53
1 files changed, 39 insertions, 14 deletions
diff --git a/tests/Client.hs b/tests/Client.hs
index ec86639e..c2ac6d01 100644
--- a/tests/Client.hs
+++ b/tests/Client.hs
@@ -3,6 +3,11 @@ module Main (main) where
3 3
4import qualified Data.ByteString as B 4import qualified Data.ByteString as B
5import System.Environment 5import System.Environment
6
7import Test.HUnit hiding (Test)
8import Test.Framework
9import Test.Framework.Providers.HUnit
10
6import Remote.KRPC 11import Remote.KRPC
7import Shared 12import Shared
8 13
@@ -11,17 +16,37 @@ addr :: RemoteAddr
11addr = (0, 6000) 16addr = (0, 6000)
12 17
13main :: IO () 18main :: IO ()
14main = do 19main = defaultMain tests
15 print =<< call addr unitM () 20
16 print =<< call addr echoM 0 21(==?) :: (Eq a, Show a) => a -> IO a -> Assertion
17 call addr reverseM [1..1000] 22expected ==? action = do
18 print =<< call addr swapM (0, 1) 23 actual <- action
19 print =<< call addr shiftR ((), 1, [2..10]) 24 expected @=? actual
20 let bs = B.replicate (32 * 1024) 0 25
21 bs' <- call addr echoBytes bs 26tests :: [Test]
22 print (bs == bs') 27tests =
23 28 [ testCase "unit" $
24{- 29 () ==? call addr unitM ()
25 forM_ [1..] $ const $ do 30
26 async addr myconcat (replicate 100 [1..10]) 31 , testCase "echo int" $
27-} 32 1234 ==? call addr echoM 1234
33
34 , testCase "reverse 1..100" $
35 reverse [1..100] ==? call addr reverseM [1..100]
36
37 , testCase "reverse empty list" $
38 reverse [] ==? call addr reverseM []
39
40 , testCase "reverse singleton list" $
41 reverse [1] ==? call addr reverseM [1]
42
43 , testCase "swap pair" $
44 (1, 0) ==? call addr swapM (0, 1)
45
46 , testCase "shift triple" $
47 ([2..10], (), 1) ==? call addr shiftR ((), 1, [2..10])
48
49 , testCase "echo bytestring" $
50 let bs = B.replicate 400 0 in
51 bs ==? call addr echoBytes bs
52 ]