[Scummvm-cvs-logs] SF.net SVN: scummvm:[39907] scummvm/trunk/test/common/rect.h
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Apr 9 19:07:00 CEST 2009
Revision: 39907
http://scummvm.svn.sourceforge.net/scummvm/?rev=39907&view=rev
Author: fingolfin
Date: 2009-04-09 17:07:00 +0000 (Thu, 09 Apr 2009)
Log Message:
-----------
Patch #2735283: GSOC09: A few unit tests for Common::Rect
Added Paths:
-----------
scummvm/trunk/test/common/rect.h
Added: scummvm/trunk/test/common/rect.h
===================================================================
--- scummvm/trunk/test/common/rect.h (rev 0)
+++ scummvm/trunk/test/common/rect.h 2009-04-09 17:07:00 UTC (rev 39907)
@@ -0,0 +1,48 @@
+#include <cxxtest/TestSuite.h>
+
+#include "common/rect.h"
+
+class RectTestSuite : public CxxTest::TestSuite
+{
+ public:
+ void test_point_sqrDist( void )
+ {
+ Common::Point p0;
+ Common::Point p11(1, 1);
+ Common::Point p21(2, 1);
+ Common::Point p23(2, 3);
+ Common::Point p32(3, 2);
+ TS_ASSERT_EQUALS( p0.sqrDist(p11), (uint) 2 );
+ TS_ASSERT_EQUALS( p0.sqrDist(p21), (uint) 5 );
+ TS_ASSERT_EQUALS( p0.sqrDist(p23), p0.sqrDist(p32) );
+ TS_ASSERT_EQUALS( p11.sqrDist(p11), (uint) 0 );
+ TS_ASSERT_EQUALS( p11.sqrDist(p23), (uint) 5 );
+ }
+
+ void test_intersects( void )
+ {
+ TS_ASSERT( Common::Rect(0, 0, 2, 2).intersects(Common::Rect(0, 0, 1, 1)) );
+ TS_ASSERT( Common::Rect(0, 0, 2, 2).intersects(Common::Rect(1, 1, 2, 2)) );
+ TS_ASSERT( !Common::Rect(0, 0, 1, 1).intersects(Common::Rect(1, 1, 2, 2)) );
+ }
+
+ void test_extend( void )
+ {
+ Common::Rect r0;
+ Common::Rect r1(0, 0, 1, 1);
+ Common::Rect r2(0, 0, 2, 2);
+ TS_ASSERT( !r0.contains(r1) );
+ r0.extend(r1);
+// TS_ASSERT( r0.contains(r1) );
+ TS_ASSERT_EQUALS(r0.top, 0);
+ TS_ASSERT_EQUALS(r0.left, 0);
+ TS_ASSERT_EQUALS(r0.bottom, 1);
+ TS_ASSERT_EQUALS(r0.right, 1);
+ r2.extend(r1);
+ TS_ASSERT_EQUALS(r2.top, 0);
+ TS_ASSERT_EQUALS(r2.left, 0);
+ TS_ASSERT_EQUALS(r2.bottom, 2);
+ TS_ASSERT_EQUALS(r2.right, 2);
+ }
+
+};
Property changes on: scummvm/trunk/test/common/rect.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list