+void RectTestCase::Operators()
+{
+ // test + operator which works like Union but does not ignore empty rectangles
+ static const struct RectData
+ {
+ int x1, y1, w1, h1;
+ int x2, y2, w2, h2;
+ int x, y, w, h;
+
+ wxRect GetFirst() const { return wxRect(x1, y1, w1, h1); }
+ wxRect GetSecond() const { return wxRect(x2, y2, w2, h2); }
+ wxRect GetResult() const { return wxRect(x, y, w, h); }
+ } s_rects[] =
+ {
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 2, 2 },
+ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+ { 1, 1, 1, 1, 4, 4, 1, 1, 1, 1, 4, 4 },
+ { 1, 1, 2, 2, 4, 4, 1, 1, 1, 1, 4, 4 },
+ { 2, 2, 2, 2, 4, 4, 4, 4, 2, 2, 6, 6 },
+ { 1, 1, 4, 4, 4, 4, 1, 1, 1, 1, 4, 4 }
+ };
+
+ for ( size_t n = 0; n < WXSIZEOF(s_rects); n++ )
+ {
+ const RectData& data = s_rects[n];
+
+ CPPUNIT_ASSERT(
+ ( data.GetFirst() + data.GetSecond() ) == data.GetResult()
+ );
+
+ CPPUNIT_ASSERT(
+ ( data.GetSecond() + data.GetFirst() ) == data.GetResult()
+ );
+ }
+}
+