gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog libgeometry/Range2d.h testsuite...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libgeometry/Range2d.h testsuite...
Date: Tue, 27 Feb 2007 11:24:12 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/02/27 11:24:11

Modified files:
        .              : ChangeLog 
        libgeometry    : Range2d.h 
        testsuite/libgeometry: Range2dTest.cpp 

Log message:
                * libgeometry/Range2d.h: add contains(Range2d) method.
                * testsuite/libgeometry/Range2dTest.cpp: Add tests for 
'contains'.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2481&r2=1.2482
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/Range2d.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libgeometry/Range2dTest.cpp?cvsroot=gnash&r1=1.5&r2=1.6

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2481
retrieving revision 1.2482
diff -u -b -r1.2481 -r1.2482
--- ChangeLog   27 Feb 2007 09:10:19 -0000      1.2481
+++ ChangeLog   27 Feb 2007 11:24:11 -0000      1.2482
@@ -1,5 +1,10 @@
 2007-02-27 Sandro Santilli <address@hidden>
 
+       * libgeometry/Range2d.h: add contains(Range2d) method.
+       * testsuite/libgeometry/Range2dTest.cpp: Add tests for 'contains'.
+
+2007-02-27 Sandro Santilli <address@hidden>
+
        * backend/Makefile.am, backend/sound_handler.h,
          backend/sound_handler.cpp, backend/sound_handler_gst.h,
          backend/sound_handler_sdl.h, extensions/Makefile.am,

Index: libgeometry/Range2d.h
===================================================================
RCS file: /sources/gnash/gnash/libgeometry/Range2d.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- libgeometry/Range2d.h       17 Dec 2006 19:21:20 -0000      1.9
+++ libgeometry/Range2d.h       27 Feb 2007 11:24:11 -0000      1.10
@@ -19,7 +19,7 @@
 //
 
 
-/* $Id: Range2d.h,v 1.9 2006/12/17 19:21:20 nihilus Exp $ */
+/* $Id: Range2d.h,v 1.10 2007/02/27 11:24:11 strk Exp $ */
 
 #ifndef GNASH_RANGE2D_H
 #define GNASH_RANGE2D_H
@@ -269,6 +269,28 @@
        }
 
        /// \brief
+       /// Return true if this rectangle contains the given rectangle.
+       //
+       /// Note that:
+       ///
+       ///     - WORLD ranges contain every range
+       ///       and are only contained in WORLD ranges
+       ///
+       ///     - NULL ranges contain no range and are contained in no range.
+       ///
+       bool contains(const Range2d<T>& other) const
+       {
+               if ( isNull() || other.isNull() ) return false;
+               if ( isWorld() ) return true;
+               if ( other.isWorld() ) return false;
+
+               return _xmin <= other._xmin &&
+                       _xmax >= other._xmax &&
+                       _ymin <= other._ymin &&
+                       _ymax >= other._ymax;
+       }
+
+       /// \brief
        /// Return true if this rectangle intersects the point with
        /// given coordinates (boundaries are inclusive).
        //

Index: testsuite/libgeometry/Range2dTest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libgeometry/Range2dTest.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- testsuite/libgeometry/Range2dTest.cpp       8 Dec 2006 13:06:06 -0000       
1.5
+++ testsuite/libgeometry/Range2dTest.cpp       27 Feb 2007 11:24:11 -0000      
1.6
@@ -275,5 +275,49 @@
        check_equals( (Range2d<int>)Range2d<float>(-0.1, 0.1, 10.1, 10.2),
                        Range2d<int>(-1, 0, 11, 11) );
 
+
+       //
+       // Test Contains
+       //
+
+       // Null ranges don't contain anything, not even themselves
+       check( ! nullIntRange1.contains(10, 10) );
+       check( ! nullIntRange1.contains(nullIntRange1) );
+       check( ! nullIntRange1.contains(worldIntRange1) );
+
+       // World ranges contain everything except null ranges
+       check( worldIntRange1.contains(10, -190) );
+       check( worldIntRange1.contains(worldIntRange1) );
+       check( ! worldIntRange1.contains(nullIntRange1) );
+
+       // Self-containment
+       check( fIntRange1.contains(fIntRange1) );
+
+       cout << "fIntRange1 == " << fIntRange1 << endl;
+
+       // Boundary overlaps
+       check( fIntRange1.contains(0, 0) );
+       check( fIntRange1.contains(10, 5) );
+       check( fIntRange1.contains(5, 10) );
+       check( fIntRange1.contains(5, 0) );
+       check( fIntRange1.contains(Range2d<int>(0, 0, 2, 2)) );
+       check( fIntRange1.contains(Range2d<int>(0, 4, 2, 6)) );
+       check( fIntRange1.contains(Range2d<int>(0, 8, 2, 10)) );
+       check( fIntRange1.contains(Range2d<int>(4, 8, 6, 10)) );
+       check( fIntRange1.contains(Range2d<int>(8, 8, 10, 10)) );
+       check( fIntRange1.contains(Range2d<int>(8, 4, 10, 6)) );
+       check( fIntRange1.contains(Range2d<int>(8, 0, 10, 2)) );
+       check( fIntRange1.contains(Range2d<int>(4, 0, 6, 2)) );
+
+       // Strict containment
+       check( fIntRange1.contains(Range2d<int>(2, 2, 4, 4)) );
+       check( fIntRange1.contains(5, 5) );
+
+       // Intersection (partial overlap)
+       check( ! fIntRange1.contains(Range2d<int>(-2, 0, 2, 2)) );
+       check( ! fIntRange1.contains(Range2d<int>(8, 8, 10, 11)) );
+       check( ! fIntRange1.contains(Range2d<int>(8, 8, 11, 11)) );
+       
+
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]