|
@@ -4,12 +4,14 @@ module Targets (tests) where
|
|
|
|
|
|
import Distribution.TestSuite
|
|
import Distribution.TestSuite
|
|
import Base (simpleTest)
|
|
import Base (simpleTest)
|
|
-import Control.Concurrent(forkIO)
|
|
|
|
|
|
+import Control.Concurrent(forkIO)
|
|
|
|
+import qualified System.IO as I
|
|
import System.IO.Uniform
|
|
import System.IO.Uniform
|
|
import System.IO.Uniform.Network
|
|
import System.IO.Uniform.Network
|
|
import System.IO.Uniform.File
|
|
import System.IO.Uniform.File
|
|
--import System.IO.Uniform.Std
|
|
--import System.IO.Uniform.Std
|
|
import System.IO.Uniform.ByteString
|
|
import System.IO.Uniform.ByteString
|
|
|
|
+import System.IO.Uniform.HandlePair
|
|
import System.Timeout (timeout)
|
|
import System.Timeout (timeout)
|
|
import qualified Data.ByteString.Char8 as C8
|
|
import qualified Data.ByteString.Char8 as C8
|
|
import Data.ByteString (ByteString)
|
|
import Data.ByteString (ByteString)
|
|
@@ -20,7 +22,8 @@ tests = return [
|
|
simpleTest "network" testNetwork,
|
|
simpleTest "network" testNetwork,
|
|
simpleTest "file" testFile,
|
|
simpleTest "file" testFile,
|
|
simpleTest "network TLS" testTls,
|
|
simpleTest "network TLS" testTls,
|
|
- simpleTest "byte string" testBS
|
|
|
|
|
|
+ simpleTest "byte string" testBS,
|
|
|
|
+ simpleTest "handle pair" testHandlePair
|
|
]
|
|
]
|
|
|
|
|
|
testNetwork :: IO Progress
|
|
testNetwork :: IO Progress
|
|
@@ -102,3 +105,18 @@ testBS = do
|
|
countAndEcho io initial dt = do
|
|
countAndEcho io initial dt = do
|
|
uPut io dt
|
|
uPut io dt
|
|
return $ initial + BS.length dt
|
|
return $ initial + BS.length dt
|
|
|
|
+
|
|
|
|
+testHandlePair :: IO Progress
|
|
|
|
+testHandlePair = do
|
|
|
|
+ let l = "abcde\n"
|
|
|
|
+ h <- I.openFile "test/testHandles" I.WriteMode
|
|
|
|
+ let s = fromHandles h h
|
|
|
|
+ uPut s l
|
|
|
|
+ uClose s
|
|
|
|
+ h' <- I.openFile "test/testHandles" I.ReadMode
|
|
|
|
+ let s' = fromHandles h' h'
|
|
|
|
+ l' <- uRead s' 100
|
|
|
|
+ uClose s'
|
|
|
|
+ if l == l'
|
|
|
|
+ then return . Finished $ Pass
|
|
|
|
+ else return . Finished . Fail . C8.unpack $ l'
|