From 456f2ca3124b4666c1eff8d4f9f6e9d71662ee37 Mon Sep 17 00:00:00 2001 From: Gregory Collins Date: Thu, 28 Feb 2013 23:48:36 +0100 Subject: [PATCH] Commit failing test for #175. --- test/suite/Snap/Core/Tests.hs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/suite/Snap/Core/Tests.hs b/test/suite/Snap/Core/Tests.hs index b6feb5aa..b442f258 100644 --- a/test/suite/Snap/Core/Tests.hs +++ b/test/suite/Snap/Core/Tests.hs @@ -22,7 +22,8 @@ import qualified Data.IntMap as IM import Data.IORef import Data.Maybe (isJust) import Data.Monoid -import Data.Text () +import Data.Text (Text) +import qualified Data.Text.Encoding as T import Data.Text.Lazy () import qualified Data.Map as Map import Prelude hiding (catch) @@ -69,7 +70,9 @@ tests = [ testFail , testEvalSnap , testLocalRequest , testRedirect - , testBracketSnap ] + , testBracketSnap + , testPathArgs + ] expectSpecificException :: Exception e => e -> IO a -> IO () @@ -671,3 +674,17 @@ testRedirect = testCase "types/redirect" $ do assertEqual "redirect path" (Just "/bar/foo") $ getHeader "Location" rsp2 assertEqual "redirect status" 307 $ rspStatus rsp2 assertEqual "status description" "Temporary Redirect" $ rspStatusReason rsp2 + + +testPathArgs :: Test +testPathArgs = testCase "types/pathArgs" $ do + (_, rsp) <- goPath "%e4%b8%ad" m + b <- getBody rsp + assertEqual "pathargs url- and utf8-decodes" "ok" b + + where + m = pathArg f + + f x = if x == ("\x4e2d" :: Text) + then writeBS "ok" + else writeBS $ "not ok: " `mappend` T.encodeUtf8 x