on master help sign in
yet more tests of cropping
b21f019Corey O'Connor
test/VerifySpanOps.hs+24
@@ -185,6 +185,26 @@ crop_top_output_rows = height_crop_output_columns crop_top
185crop_bottom_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
185crop_bottom_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
186crop_bottom_output_rows = height_crop_output_columns crop_bottom
186crop_bottom_output_rows = height_crop_output_columns crop_bottom
187
187
188+crop_right_and_left_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
189+crop_right_and_left_rejoined_equivalence stack = image_width (stack_image stack) `mod` 2 == 0 ==>
190+ let i = stack_image stack
191+ -- the right part is made by cropping the image from the left.
192+ i_r = crop_left (image_width i `div` 2) i
193+ -- the left part is made by cropping the image from the right
194+ i_l = crop_right (image_width i `div` 2) i
195+ i_alt = i_l <|> i_r
196+ in display_ops_for_image i == display_ops_for_image i_alt
197+
198+crop_top_and_bottom_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
199+crop_top_and_bottom_rejoined_equivalence stack = image_height (stack_image stack) `mod` 2 == 0 ==>
200+ let i = stack_image stack
201+ -- the top part is made by cropping the image from the bottom.
202+ i_t = crop_bottom (image_height i `div` 2) i
203+ -- the bottom part is made by cropping the image from the top.
204+ i_b = crop_top (image_height i `div` 2) i
205+ i_alt = i_t <-> i_b
206+ in display_ops_for_image i == display_ops_for_image i_alt
207+
188image_coverage_matches_bounds :: Image -> Result
208image_coverage_matches_bounds :: Image -> Result
189image_coverage_matches_bounds i =
209image_coverage_matches_bounds i =
190 let p = pic_for_image i
210 let p = pic_for_image i
@@ -228,6 +248,10 @@ tests = return
228 crop_left_output_columns
248 crop_left_output_columns
229 , verify "cropping from the right produces display operations covering the expected columns"
249 , verify "cropping from the right produces display operations covering the expected columns"
230 crop_right_output_columns
250 crop_right_output_columns
251+ , verify "the output of a stack is the same as that stack cropped left & right and joined together"
252+ crop_right_and_left_rejoined_equivalence
253+ , verify "the output of a stack is the same as that stack cropped top & bottom and joined together"
254+ crop_top_and_bottom_rejoined_equivalence
231 , verify "an arbitrary image when rendered to a window of the same size will cover the entire window"
255 , verify "an arbitrary image when rendered to a window of the same size will cover the entire window"
232 image_coverage_matches_bounds
256 image_coverage_matches_bounds
233 ]
257 ]