]> git.saurik.com Git - wxWidgets.git/commitdiff
Add a simple unit test for wxRegion::Intersect().
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 23 Oct 2012 12:03:09 +0000 (12:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 23 Oct 2012 12:03:09 +0000 (12:03 +0000)
Check that Intersect() returns true, yet the intersection is empty.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72724 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/geometry/region.cpp

index f6ae795e17dfea868f843470b59058f1d9176e21..c1f833b6005fbe56c6811fab1b5e092c6f045b04 100644 (file)
@@ -67,9 +67,11 @@ public:
 private:
     CPPUNIT_TEST_SUITE( RegionTestCase );
         CPPUNIT_TEST( Validity );
 private:
     CPPUNIT_TEST_SUITE( RegionTestCase );
         CPPUNIT_TEST( Validity );
+        CPPUNIT_TEST( Intersect );
     CPPUNIT_TEST_SUITE_END();
 
     void Validity();
     CPPUNIT_TEST_SUITE_END();
 
     void Validity();
+    void Intersect();
 
     wxDECLARE_NO_COPY_CLASS(RegionTestCase);
 };
 
     wxDECLARE_NO_COPY_CLASS(RegionTestCase);
 };
@@ -112,3 +114,27 @@ void RegionTestCase::Validity()
         r
     );
 }
         r
     );
 }
+
+void RegionTestCase::Intersect()
+{
+    const wxPoint points1[] = {
+        wxPoint(310, 392),
+        wxPoint(270, 392),
+        wxPoint(270, 421),
+        wxPoint(310, 421)
+    };
+
+    wxRegion region1(WXSIZEOF(points1), points1);
+
+    const wxPoint points2[] = {
+        wxPoint(54, 104),
+        wxPoint(85,  82),
+        wxPoint(68,  58),
+        wxPoint(37,  80)
+    };
+
+    wxRegion region2(4,points2);
+
+    CPPUNIT_ASSERT( region1.Intersect(region2) );
+    CPPUNIT_ASSERT( region1.IsEmpty() );
+}