@@ -5,6 +5,7 @@ import Verify.Graphics.Vty.DisplayRegion
55import Verify.Graphics.Vty.Picture
66import Verify.Graphics.Vty.Image
77import Verify.Graphics.Vty.Span
8+import Verify.Graphics.Vty.Terminal
89import Graphics.Vty.Terminal
910import Graphics.Vty.Terminal.Mock
1011
@@ -18,14 +19,6 @@ import qualified Data.String.UTF8 as UTF8
1819
1920import System.IO
2021
21−compare_bytes out_bytes expected_bytes =
22− if out_bytes /= expected_bytes
23− then return $ failed { reason = "bytes\n" ++ show out_bytes
24− ++ "\nare not the expected bytes\n"
25− ++ show expected_bytes
26− }
27− else return succeeded
28−
2922unit_image_unit_bounds :: UnitImage -> Property
3023unit_image_unit_bounds (UnitImage _ i) = liftIOResult $ do
3124 (_,t) <- mock_terminal (DisplayRegion 1 1)
@@ -50,14 +43,12 @@ single_T_row (MockWindow w h) = liftIOResult $ do
5043 let i = horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
5144 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
5245 output_picture dc pic
53− out_bytes <- readIORef mock_data >>= return . UTF8.toRep
54− -- The UTF8 string that represents the output bytes a single line containing the T string:
46+ -- The mock output string that represents the output bytes a single line containing the T
47+ -- string: Followed by h - 1 lines of a change to the background attribute and then the
48+ -- background character
5549 let expected = "HD" ++ "MA" ++ replicate (fromEnum w) 'T'
56− -- Followed by h - 1 lines of a change to the background attribute and then the background
57− -- character
5850 ++ concat (replicate (fromEnum h - 1) $ "MA" ++ replicate (fromEnum w) 'B')
59− expected_bytes :: BS.ByteString = UTF8.toRep $ UTF8.fromString expected
60− compare_bytes out_bytes expected_bytes
51+ compare_mock_output mock_data expected
6152
6253many_T_rows :: MockWindow -> Property
6354many_T_rows (MockWindow w h) = liftIOResult $ do
@@ -67,12 +58,10 @@ many_T_rows (MockWindow w h) = liftIOResult $ do
6758 let i = vert_cat $ replicate (fromEnum h) $ horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
6859 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
6960 output_picture dc pic
70− out_bytes <- readIORef mock_data >>= return . UTF8.toRep
7161 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
7262 -- attribute change. 'A', followed by w 'T's
7363 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
74− expected_bytes :: BS.ByteString = UTF8.toRep $ UTF8.fromString expected
75− compare_bytes out_bytes expected_bytes
64+ compare_mock_output mock_data expected
7665
7766many_T_rows_cropped_width :: MockWindow -> Property
7867many_T_rows_cropped_width (MockWindow w h) = liftIOResult $ do
@@ -82,12 +71,10 @@ many_T_rows_cropped_width (MockWindow w h) = liftIOResult $ do
8271 let i = vert_cat $ replicate (fromEnum h) $ horiz_cat $ replicate (fromEnum w * 2) (char def_attr 'T')
8372 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
8473 output_picture dc pic
85− out_bytes <- readIORef mock_data >>= return . UTF8.toRep
8674 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
8775 -- attribute change. 'A', followed by w 'T's
8876 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
89− expected_bytes :: BS.ByteString = UTF8.toRep $ UTF8.fromString expected
90− compare_bytes out_bytes expected_bytes
77+ compare_mock_output mock_data expected
9178
9279many_T_rows_cropped_height :: MockWindow -> Property
9380many_T_rows_cropped_height (MockWindow w h) = liftIOResult $ do
@@ -97,12 +84,10 @@ many_T_rows_cropped_height (MockWindow w h) = liftIOResult $ do
9784 let i = vert_cat $ replicate (fromEnum h * 2) $ horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
9885 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
9986 output_picture dc pic
100− out_bytes <- readIORef mock_data >>= return . UTF8.toRep
10187 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
10288 -- attribute change. 'A', followed by w count 'T's
10389 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
104− expected_bytes :: BS.ByteString = UTF8.toRep $ UTF8.fromString expected
105− compare_bytes out_bytes expected_bytes
90+ compare_mock_output mock_data expected
10691
10792tests :: IO [Test]
10893tests = return [ verify "unit_image_unit_bounds" unit_image_unit_bounds