packages feed

willow-0.1.0.0: test/Test/Willow/WebPlatformTests/Manual/Encoding/Iso2022JpEncoder.hs

{-# LANGUAGE OverloadedStrings #-}

{-|
Description:    Emulating tests from @encoding/iso-2022-jp-encoder.html@

Copyright:      (c) 2020 Samuel May
License:        MPL-2.0
Maintainer:     ag.eitilt@gmail.com

Stability:      experimental
Portability:    portable
-}
module Test.Willow.WebPlatformTests.Manual.Encoding.Iso2022JpEncoder
    ( tests
    ) where


import qualified Test.HUnit as U

import Test.HUnit ( (~:), (~?=) )

import Web.Willow.Common.Encoding

import Test.Willow.WebPlatformTests.Manual.Common


tests :: U.Test
tests = "iso-2022-jp-encoder.html" ~: U.TestList $ map test testData
  where test t = nameE t ~: encodeEnc' Iso2022Jp (inputE t) ~?= outputE t


testData :: [InlineEncode]
testData =
    [ InlineEncode
        { inputE = "s"
        , outputE = "s"
        , nameE = "very basic"
        }
    , InlineEncode
        { inputE = "\x00A5\x203Es\\\xFF90\x4F69"
        , outputE = "\ESC(J\\~s\ESC(B\\\ESC$B%_PP\ESC(B"
        , nameE = "basics"
        }
    , InlineEncode
        { inputE = "\xFF61"
        , outputE = "\ESC$B!#\ESC(B"
        , nameE = "Katakana"
        }
    , InlineEncode
        { inputE = "\x0393"
        , outputE = "\ESC$B&#\ESC(B"
        , nameE = "jis0208"
        }
    , InlineEncode
        { inputE = "\SO\SI\ESCx"
        , outputE = "���x"
        , nameE = "SO/SI ESC"
        }
    , InlineEncode
        { inputE = "\x203E\SO\SI\ESCx"
        , outputE = "\ESC(J~���x\ESC(B"
        , nameE = "Roman SO/SI ESC"
        }
    , InlineEncode
        { inputE = "\xFF61\SO\SI\ESCx"
        , outputE = "\ESC$B!#\ESC(B���x"
        , nameE = "Katakana SO/SI ESC"
        }
    , InlineEncode
        { inputE = "\x0393\SO\SI\ESCx"
        , outputE = "\ESC$B&#\ESC(B���x"
        , nameE = "jis0208 SO/SI ESC"
        }
    , InlineEncode
        { inputE = "\xFFFD"
        , outputE = "�"
        , nameE = "U+FFFD"
        }
    , InlineEncode
        { inputE = "\x203E\xFFFD"
        , outputE = "\ESC(J~�\ESC(B"
        , nameE = "Roman U+FFFD"
        }
    , InlineEncode
        { inputE = "\xFF61\xFFFD"
        , outputE = "\ESC$B!#\ESC(B�"
        , nameE = "Katakana U+FFFD"
        }
    , InlineEncode
        { inputE = "\x0393\xFFFD"
        , outputE = "\ESC$B&#\ESC(B�"
        , nameE = "jis0208 U+FFFD"
        }
    ]