@@ -173,6 +173,10 @@ all_tests
173173 , inline_test_1
174174 , inline_test_2
175175 , cursor_hide_test_0
176+ , vert_crop_test_0
177+ , vert_crop_test_1
178+ , vert_crop_test_2
179+ , vert_crop_test_3
176180 ]
177181
178182reserve_output_test = Test
@@ -946,3 +950,106 @@ cursor_hide_test_0 = Test
946950 , confirm_results = generic_output_match_confirm
947951 }
948952
953+output_image_and_wait :: Image -> IO ()
954+output_image_and_wait image = do
955+ t <- current_terminal
956+ reserve_display t
957+ let pic = pic_for_image image
958+ d <- display_bounds t >>= display_context t
959+ output_picture d pic
960+ getLine
961+ release_display t
962+ release_terminal t
963+ return ()
964+
965+vert_crop_test_0 :: Test
966+vert_crop_test_0 = Test
967+ { test_name = "Verify bottom cropping works as expected with single column chars"
968+ , test_ID = "crop_test_0"
969+ , test_action = do
970+ let block_0 = crop_bottom 2 $ vert_cat $ map (string def_attr) lorum_ipsum
971+ block_1 = vert_cat $ map (string def_attr) $ take 2 lorum_ipsum
972+ image = block_0 <-> background_fill 10 2 <-> block_1
973+ output_image_and_wait image
974+ , print_summary = putStr $ [s|
975+ 1. Verify the two text blocks are identical.
976+ 2. press enter.
977+ 3. the display should return to the state before the test.
978+|]
979+ , confirm_results = generic_output_match_confirm
980+ }
981+
982+vert_crop_test_1 :: Test
983+vert_crop_test_1 = Test
984+ { test_name = "Verify bottom cropping works as expected with double column chars"
985+ , test_ID = "crop_test_0"
986+ , test_action = do
987+ let block_0 = crop_bottom 2 $ vert_cat $ map (string def_attr) lorum_ipsum_chinese
988+ block_1 = vert_cat $ map (string def_attr) $ take 2 lorum_ipsum_chinese
989+ image = block_0 <-> background_fill 10 2 <-> block_1
990+ output_image_and_wait image
991+ , print_summary = putStr $ [s|
992+ 1. Verify the two text blocks are identical.
993+ 2. press enter.
994+ 3. the display should return to the state before the test.
995+|]
996+ , confirm_results = generic_output_match_confirm
997+ }
998+
999+vert_crop_test_2 :: Test
1000+vert_crop_test_2 = Test
1001+ { test_name = "Verify top cropping works as expected with single column chars"
1002+ , test_ID = "crop_test_0"
1003+ , test_action = do
1004+ let block_0 = crop_top 2 $ vert_cat $ map (string def_attr) lorum_ipsum
1005+ block_1 = vert_cat $ map (string def_attr) $ drop (length lorum_ipsum - 2) lorum_ipsum
1006+ image = block_0 <-> background_fill 10 2 <-> block_1
1007+ output_image_and_wait image
1008+ , print_summary = putStr $ [s|
1009+ 1. Verify the two text blocks are identical.
1010+ 2. press enter.
1011+ 3. the display should return to the state before the test.
1012+|]
1013+ , confirm_results = generic_output_match_confirm
1014+ }
1015+
1016+vert_crop_test_3 :: Test
1017+vert_crop_test_3 = Test
1018+ { test_name = "Verify top cropping works as expected with double column chars"
1019+ , test_ID = "crop_test_0"
1020+ , test_action = do
1021+ let block_0 = crop_top 2 $ vert_cat $ map (string def_attr) lorum_ipsum_chinese
1022+ block_1 = vert_cat $ map (string def_attr) $ drop (length lorum_ipsum_chinese - 2 ) lorum_ipsum_chinese
1023+ image = block_0 <-> background_fill 10 2 <-> block_1
1024+ output_image_and_wait image
1025+ , print_summary = putStr $ [s|
1026+ 1. Verify the two text blocks are identical.
1027+ 2. press enter.
1028+ 3. the display should return to the state before the test.
1029+|]
1030+ , confirm_results = generic_output_match_confirm
1031+ }
1032+
1033+lorum_ipsum :: [String]
1034+lorum_ipsum = lines [s|
1035+Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium,
1036+totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae
1037+dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,
1038+sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam
1039+est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius
1040+modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima
1041+veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea
1042+commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil
1043+molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
1044+|]
1045+
1046+lorum_ipsum_chinese :: [String]
1047+lorum_ipsum_chinese = lines [s|
1048+輐銛 螷蟞覮 裌覅詵 暕 鴅噮 槶 惝掭掝 婸媥媕 耏胠臿, 汫汭沎 忕汌卣 蚡袀 僣 蒮 瀁瀎瀊 渮湸湤 緌翢,
1049+腠腶舝 糲蘥蠩 樏殣氀 蒮 蹢鎒 滍 鸄齴 櫧櫋瀩 鬄鵊鵙 莃荶衒, 毸溠 橀 簎艜薤 莃荶衒 翣聜蒢
1050+
1051+斔櫅檷 晛桼桾 拻敁柧 犿玒 膣, 墐 笓粊紒 樏殣氀 鼀齕, 蔝蓶蓨 顊顃餭 姴怤 骱 暕 蹢鎒鎛 藒襓謥 鄻鎟霣
1052+鬎鯪, 鐩闤 硻禂稢 谾踘遳 撱 赲迡 箷 蛃袚觙 萇雊蜩 壿嫷 鋡 縢羱聬 跐鉠鉣 蔝蓶蓨 匢奾灱 溮煡煟 雥齆犪
1053+蔰 虈觿, 腷腯葹 鍹餳駷 蛚袲褁 蜸 皯竻 瀁瀎 蜭蜸覟 梪涫湴 揗斝湁 毼
1054+|]
1055+