unicodeEncoding :: Invocation -> Test
unicodeEncoding i = "Unicode encoding (valid)" ~:
    [ utf8Test i [utf8 "xαβγy"]
        [prompt 0, utf8 "xαβγy"]
    , utf8Test i [utf8 "a\n", "quit\n"]
        [ prompt 0
        , utf8 "a" <> end
            <> output 0 (utf8 "a") <> prompt 1
        , utf8 "quit" <> end
        ]
    , utf8Test i [utf8 "xαβyψ안기q영\n", "quit\n"]
        [ prompt 0
        , utf8 "xαβyψ안기q영" <> end
            <> output 0 (utf8 "xαβyψ안기q영") <> prompt 1
        , utf8 "quit" <> end
        ]
    -- test buffering: 32 bytes is in middle of a char encoding,
    -- also test long paste
    , "multipleLines" ~: utf8Test i [l1 <> "\n" <> l1]
        [ prompt 0
        , l1 <> end <> output 0 l1 <> prompt 1 <> l1]
    ]
  where
    l1 = utf8 $ T.replicate 30 "안" -- three bytes, width 60

unicodeMovement :: Invocation -> 
unicodeEncoding :: Invocation -> Test
unicodeEncoding i = "Unicode encoding (valid)" ~:
    [ utf8Test i [utf8 "xαβγy"]
        [prompt 0, utf8 "xαβγy"]
    , utf8Test i [utf8 "a\n", "quit\n"]
        [ prompt 0
        , utf8 "a" <> end
            <> output 0 (utf8 "a") <> prompt 1
        , utf8 "quit" <> end
        ]
    , utf8Test i [utf8 "xαβyψ안기q영\n", "quit\n"]
        [ prompt 0
        , utf8 "xαβyψ안기q영" <> end
            <> output 0 (utf8 "xαβyψ안기q영") <> prompt 1
        , utf8 "quit" <> end
        ]
    -- test buffering: 32 bytes is in middle of a char encoding,
    -- also test long paste
    , "multipleLines" ~: utf8Test i [l1 <> "\n" <> l1]
        [ prompt 0
        , l1 <> end <> output 0 l1 <> prompt 1 <> l1]
    ]
  where
    l1 = utf8 $ T.replicate 30 "안" -- three bytes, width 60
unicodeEncoding i = "Unicode encoding (valid)" ~:
    [ utf8Test i [utf8 "xαβγy"]
        [prompt 0, utf8 "xαβγy"]
    , utf8Test i [utf8 "a\n", "quit\n"]
        [ prompt 0
        , utf8 "a" <> end
            <> output 0 (utf8 "a") <> prompt 1
        , utf8 "quit" <> end
        ]
    , utf8Test i [utf8 "xαβyψ안기q영\n", "quit\n"]
        [ prompt 0
        , utf8 "xαβyψ안기q영" <> end
            <> output 0 (utf8 "xαβyψ안기q영") <> prompt 1
        , utf8 "quit" <> end
        ]
    -- test buffering: 32 bytes is in middle of a char encoding,
    -- also test long paste
    , "multipleLines" ~: utf8Test i [l1 <> "\n" <> l1]
        [ prompt 0
        , l1 <> end <> output 0 l1 <> prompt 1 <> l1]
    ]
  where
    l1 = utf8 $ T.replicate 30 "안" -- three bytes, width 60