Commit 65bb5fd1 authored by ttuegel's avatar ttuegel
Browse files

Unit test to check locale of handles created with `createPipe`

parent 93918b1b
...@@ -233,7 +233,9 @@ library ...@@ -233,7 +233,9 @@ library
test-suite unit-tests test-suite unit-tests
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
hs-source-dirs: tests hs-source-dirs: tests
other-modules: UnitTests.Distribution.Compat.ReadP other-modules:
UnitTests.Distribution.Compat.CreatePipe
UnitTests.Distribution.Compat.ReadP
main-is: UnitTests.hs main-is: UnitTests.hs
build-depends: build-depends:
base, base,
......
...@@ -5,12 +5,15 @@ module Main ...@@ -5,12 +5,15 @@ module Main
import System.IO (BufferMode(NoBuffering), hSetBuffering, stdout) import System.IO (BufferMode(NoBuffering), hSetBuffering, stdout)
import Test.Framework import Test.Framework
import qualified UnitTests.Distribution.Compat.CreatePipe
import qualified UnitTests.Distribution.Compat.ReadP import qualified UnitTests.Distribution.Compat.ReadP
tests :: [Test] tests :: [Test]
tests = [ tests =
testGroup "Distribution.Compat.ReadP" [ testGroup "Distribution.Compat.ReadP"
UnitTests.Distribution.Compat.ReadP.tests UnitTests.Distribution.Compat.ReadP.tests
, testGroup "Distribution.Compat.CreatePipe"
UnitTests.Distribution.Compat.CreatePipe.tests
] ]
main :: IO () main :: IO ()
......
module UnitTests.Distribution.Compat.CreatePipe (tests) where
import Distribution.Compat.CreatePipe
import System.IO (hClose, hGetContents, hPutStr, hSetEncoding, localeEncoding)
import Test.Framework
import Test.Framework.Providers.HUnit
import Test.HUnit hiding (Test)
tests :: [Test]
tests = [testCase "Locale Encoding" case_Locale_Encoding]
case_Locale_Encoding :: Assertion
case_Locale_Encoding = assert $ do
let str = "\0252"
(r, w) <- createPipe
hSetEncoding w localeEncoding
out <- hGetContents r
hPutStr w str
hClose w
return $! out == str
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment