Show
Ignore:
Timestamp:
08/13/07 20:58:20 (6 years ago)
Author:
bjourne
Message:

Fix unit tests so that they compile and pass.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gtkimageview/tests/test-gdk-utils.c

    r202 r280  
    1010 
    1111static void 
    12 rects_around_rect_checker (int width, int height, GdkRectangle i) 
     12rects_around_rect_checker (GdkRectangle outer, 
     13                                                   GdkRectangle inner) 
    1314{ 
    1415    GdkRectangle borders[4]; 
    15     gdk_get_rects_around_rect (width, height, &i, borders); 
     16       gdk_rectangle_get_rects_around (&outer, &inner, borders); 
    1617 
    17     GdkRectangle top = borders[0]; 
    18         assert (gdk_rectangle_eq (top, (GdkRectangle){0, 0, width, i.y})); 
     18        GdkRectangle top = borders[0]; 
     19        assert (top.x == outer.x); 
     20        assert (top.y == outer.y); 
     21        assert (top.width == outer.width); 
     22        assert (top.height == inner.y - outer.y); 
    1923 
    20     GdkRectangle bottom = borders[1]; 
    21     assert (bottom.x == 0); 
    22     assert (bottom.y == i.y + i.height); 
    23     assert (bottom.width == width); 
    24     assert (bottom.height == height - i.y - i.height); 
     24       GdkRectangle left = borders[1]; 
     25    assert (left.x == 0); 
     26    assert (left.y == inner.y); 
     27    assert (left.width == inner.x - outer.x); 
     28    assert (left.height == inner.height); 
    2529 
    26     GdkRectangle left = borders[2]; 
    27     assert (left.x == 0); 
    28     assert (left.y == i.y -1); 
    29     assert (left.width == i.x); 
    30     assert (left.height == i.height + 2); 
     30        GdkRectangle right = borders[2]; 
     31    assert (right.x == inner.x + inner.width); 
     32    assert (right.y == inner.y); 
     33    assert (right.width == 
     34                        (outer.x + outer.width) - (inner.x + inner.width)); 
     35    assert (right.height == inner.height); 
    3136 
    32     GdkRectangle right = borders[3]; 
    33     assert (right.x == i.x + i.width); 
    34     assert (right.y == i.y - 1); 
    35     assert (right.width == width - i.x - i.width); 
    36     assert (right.height == i.height + 2); 
     37    GdkRectangle bottom = borders[3]; 
     38    assert (bottom.x == outer.x); 
     39    assert (bottom.y == inner.y + inner.height); 
     40    assert (bottom.width == outer.width); 
     41    assert (bottom.height == 
     42                        (outer.y + outer.height) - (inner.y + inner.height)); 
    3743} 
    3844 
     
    4753{ 
    4854    printf ("test_get_rects_around_rect\n"); 
    49     int outsides[] = { 
    50         600, 400
    51         10, 10, 
    52     }; 
    53     int insides[] = { 
    54         40, 40, 100, 100 
    55     }; 
     55       GdkRectangle outsides[] = { 
     56               {0, 0, 600, 400}
     57                {0, 0, 10, 10} 
     58       }; 
     59       GdkRectangle insides[] = { 
     60                {40, 40, 100, 100} 
     61       }; 
    5662 
    57     for (int i = 0; i < G_N_ELEMENTS(outsides); i += 2) 
    58     { 
    59         for (int j = 0; j < G_N_ELEMENTS(insides); j += 4) 
    60         { 
    61             int width = outsides[i + 0]; 
    62             int height = outsides[i + 1]; 
    63             GdkRectangle inside = { 
    64                 insides[j + 0], 
    65                 insides[j + 1], 
    66                 insides[j + 2], 
    67                 insides[j + 3] 
    68             }; 
    69             rects_around_rect_checker (width, height, inside); 
    70         } 
    71     } 
     63    for (int i = 0; i < G_N_ELEMENTS(outsides); i++) 
     64        for (int j = 0; j < G_N_ELEMENTS(insides); j++) 
     65                        rects_around_rect_checker (outsides[i], insides[j]); 
     66                         
    7267    // Do manual simple sanity checks 
     68        GdkRectangle out = {0, 0, 100, 100}; 
    7369    GdkRectangle in = {25, 25, 50, 50}; 
    7470    GdkRectangle arounds[4]; 
    75     gdk_get_rects_around_rect (100, 100, &in, arounds); 
    76         assert (gdk_rectangle_eq (arounds[0], 
    77                                                           (GdkRectangle){0, 0, 100, 25})); 
    78         assert (gdk_rectangle_eq (arounds[1], 
    79                                                           (GdkRectangle){0, 75, 100, 25})); 
    80         assert (gdk_rectangle_eq (arounds[2], 
    81                                                           (GdkRectangle){0, 25 - 1, 25, 50 + 2})); 
    82         assert (gdk_rectangle_eq (arounds[3], 
    83                                                           (GdkRectangle){75, 25 - 1, 25, 50 + 2})); 
     71    gdk_rectangle_get_rects_around (&out, &in, arounds); 
     72        assert (gdk_rectangle_eq2 (arounds[0], 0, 0, 100, 25)); 
     73        assert (gdk_rectangle_eq2 (arounds[1], 0, 25, 25, 50)); 
     74        assert (gdk_rectangle_eq2 (arounds[2], 75, 25, 25, 50)); 
     75        assert (gdk_rectangle_eq2 (arounds[3], 0, 75, 100, 25)); 
    8476} 
    8577