aboutsummaryrefslogtreecommitdiff
path: root/pixman/test/region-test.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-07-25 16:02:10 +0000
committermarha <marha@users.sourceforge.net>2009-07-25 16:02:10 +0000
commit6aa791a05508dd822b229cd4ff4f9b8cdd617db3 (patch)
treea07d0a8452c90e3305417e8691d6e1deca7aa9aa /pixman/test/region-test.c
parentddfb922180a6a847d52609592a2bdb37179ca439 (diff)
parent4b195776d5fb64e83a4e56627367d8e9ea10cbf7 (diff)
downloadvcxsrv-6aa791a05508dd822b229cd4ff4f9b8cdd617db3.tar.gz
vcxsrv-6aa791a05508dd822b229cd4ff4f9b8cdd617db3.tar.bz2
vcxsrv-6aa791a05508dd822b229cd4ff4f9b8cdd617db3.zip
svn merge file:///D:/svnrepos/vcxsrv/branches/released .
Diffstat (limited to 'pixman/test/region-test.c')
-rw-r--r--pixman/test/region-test.c63
1 files changed, 59 insertions, 4 deletions
diff --git a/pixman/test/region-test.c b/pixman/test/region-test.c
index e214e9b89..3568969f1 100644
--- a/pixman/test/region-test.c
+++ b/pixman/test/region-test.c
@@ -3,21 +3,76 @@
#include <stdio.h>
#include "pixman.h"
-/* This used to go into an infinite loop before pixman-region.c
- * was fixed to not use explict "short" variables
- */
int
main ()
{
pixman_region32_t r1;
pixman_region32_t r2;
pixman_region32_t r3;
+ pixman_box32_t boxes[] = {
+ { 10, 10, 20, 20 },
+ { 30, 30, 30, 40 },
+ { 50, 45, 60, 44 },
+ };
+ pixman_box32_t boxes2[] = {
+ { 2, 6, 7, 6 },
+ { 4, 1, 6, 7 },
+ };
+ pixman_box32_t boxes3[] = {
+ { 2, 6, 7, 6 },
+ { 4, 1, 6, 1 },
+ };
+ int i;
+ pixman_box32_t *b;
+ /* This used to go into an infinite loop before pixman-region.c
+ * was fixed to not use explict "short" variables
+ */
pixman_region32_init_rect (&r1, 0, 0, 20, 64000);
pixman_region32_init_rect (&r2, 0, 0, 20, 64000);
pixman_region32_init_rect (&r3, 0, 0, 20, 64000);
pixman_region32_subtract (&r1, &r2, &r3);
-}
+ /* This would produce a region containing an empty
+ * rectangle in it. Such regions are considered malformed,
+ * but using an empty rectangle for initialization should
+ * work.
+ */
+ pixman_region32_init_rects (&r1, boxes, 3);
+
+ b = pixman_region32_rectangles (&r1, &i);
+
+ assert (i == 1);
+
+ while (i--)
+ {
+ assert (b[i].x1 < b[i].x2);
+ assert (b[i].y1 < b[i].y2);
+ }
+
+ /* This would produce a rectangle containing the bounding box
+ * of the two rectangles. The correct result is to eliminate
+ * the broken rectangle.
+ */
+ pixman_region32_init_rects (&r1, boxes2, 2);
+
+ b = pixman_region32_rectangles (&r1, &i);
+
+ assert (i == 1);
+
+ assert (b[0].x1 == 4);
+ assert (b[0].y1 == 1);
+ assert (b[0].x2 == 6);
+ assert (b[0].y2 == 7);
+
+ /* This should produce an empty region */
+ pixman_region32_init_rects (&r1, boxes3, 2);
+
+ b = pixman_region32_rectangles (&r1, &i);
+
+ assert (i == 0);
+
+ return 0;
+}