diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-05-14 12:01:47 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-05-14 12:01:47 +0400 |
commit | dca81a23bcec19ab7562322c2eb988b286afe944 (patch) | |
tree | c2354fabaf9dc27b70368a68020cb9cf9bc57b47 /tests | |
parent | 50490ccb9ac98dc03a499972e693da8514779be6 (diff) |
+ Add hunit tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Client.hs | 53 |
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 | ||
4 | import qualified Data.ByteString as B | 4 | import qualified Data.ByteString as B |
5 | import System.Environment | 5 | import System.Environment |
6 | |||
7 | import Test.HUnit hiding (Test) | ||
8 | import Test.Framework | ||
9 | import Test.Framework.Providers.HUnit | ||
10 | |||
6 | import Remote.KRPC | 11 | import Remote.KRPC |
7 | import Shared | 12 | import Shared |
8 | 13 | ||
@@ -11,17 +16,37 @@ addr :: RemoteAddr | |||
11 | addr = (0, 6000) | 16 | addr = (0, 6000) |
12 | 17 | ||
13 | main :: IO () | 18 | main :: IO () |
14 | main = do | 19 | main = 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] | 22 | expected ==? 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 | 26 | tests :: [Test] |
22 | print (bs == bs') | 27 | tests = |
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 | ] | ||