TestConduit.hs 719 B

1234567891011121314151617181920212223242526
  1. {-# LANGUAGE OverloadedStrings #-}
  2. module TestConduit (tests) where
  3. import Distribution.TestSuite
  4. import Base
  5. import qualified Data.Conduit.List as C
  6. import System.IO.Uniform.ByteString
  7. import System.IO.Uniform.Conduit
  8. import Data.Monoid (Sum(..))
  9. import qualified Data.ByteString as BS
  10. tests :: IO [Test]
  11. tests = do
  12. return [
  13. simpleTest "runConduit" testRunConduit
  14. ]
  15. testRunConduit :: IO Progress
  16. testRunConduit = do
  17. let dt = "Some data to test ByteString"
  18. (Sum len, _) <- withByteStringIO dt $ \io ->
  19. runConduit io (C.foldMap (Sum . BS.length))
  20. if BS.length dt /= len
  21. then return . Finished . Fail $ "Failure on ByteStringIO test. Length is: " ++ show len
  22. else return . Finished $ Pass