From d6b9daf7ca637be965347fe2585b4f5a2a02c7b5 Mon Sep 17 00:00:00 2001 From: Vladimir Shevchenko Date: Thu, 12 Jul 2012 02:47:12 +0700 Subject: [PATCH] Fixed documentation & spaces --- Foundation/CPGeometry.j | 70 +++++++++++++++++++++++++++++++ Tests/Foundation/CPGeometryTest.j | 68 +++++++++++++++--------------- 2 files changed, 104 insertions(+), 34 deletions(-) diff --git a/Foundation/CPGeometry.j b/Foundation/CPGeometry.j index e98ba26d8..234190a59 100644 --- a/Foundation/CPGeometry.j +++ b/Foundation/CPGeometry.j @@ -29,18 +29,88 @@ CPMaxXEdge = 2; CPMaxYEdge = 3; // FIXME: the rest! +/*! + Makes a CGPoint object out of two numbers provided as arguments + @group CGPoint + @param x the x-coordinate of the CGPoint + @param y the y-coordinate of the CGPoint + @return CGPoint a CGPoint with an X and Y coordinate equal to the function arguments +*/ CPMakePoint = CGPointMake; + +/*! + Creates and returns a new CGSize object from the provided dimensions. + @group CGSize + @param width the width for the new CGSize + @param height the height for the new CGSize + @return CGSize the new CGSize +*/ CPMakeSize = CGSizeMake; + +/*! + Returns a CGRect made of the specified arguments + @group CGRect + @param x the x-coordinate of the rectangle's origin + @param y the y-coordinate of the rectangle's origin + @param width the width of the new rectangle + @param height the height of the new rectangle + @return CGRect the new rectangle +*/ CPMakeRect = CGRectMake; +/*! + Creates a copy of a specified point and returns the copy + @group CGPoint + @param the point to be copied + @return CGPoint the copy of the provided CGPoint +*/ CPPointCreateCopy = CGPointMakeCopy; +/*! + Tests whether the two CGPoints are equal to each other by comparing their + \c x and \c y members. + @group @CGPoint + @param lhsPoint the first CGPoint to check + @param rhsPoint the second CGPoint to check + @return BOOL \c YES if the two points have the same x's, and the same y's. +*/ CPPointEqualToPoint = CGPointEqualToPoint; + +/*! + Test whether the two CGRects have the same origin and size + @group CGRect + @param lhsRect the first CGRect to compare + @param rhsRect the second CGRect to compare + @return BOOL \c YES if the two rectangles have the same origin and size. \c NO, otherwise. +*/ CPRectEqualToRect = CGRectEqualToRect; +/*! + Returns \c YES if the CGRect has no area. + The test is performed by checking if the width and height are both zero. + @group CGRect + @param aRect the CGRect to test + @return BOOL \c YES if the CGRect has no area, and \c NO, otherwise. +*/ CPRectIsEmpty = CGRectIsEmpty; +/*! + Returns a \c BOOL indicating whether CGRect \c possibleOuter + contains CGRect \c possibleInner. + @group CGRect + @param possibleOuter the CGRect to test if \c possibleInner is inside of + @param possibleInner the CGRect to test if it fits inside \c possibleOuter. + @return BOOL \c YES if \c possibleInner fits inside \c possibleOuter. +*/ CPRectContainsRect = CGRectContainsRect; + +/*! + Returns the intersection of the two provided rectangles as a new rectangle + @group CGRect + @param lhsRect the first rectangle used for calculation + @param rhsRect the second rectangle used for calculation + @return CGRect the intersection of the two rectangles +*/ CPRectIntersection = CGRectIntersection; /*! diff --git a/Tests/Foundation/CPGeometryTest.j b/Tests/Foundation/CPGeometryTest.j index 7eb30c800..92ab7b1c1 100644 --- a/Tests/Foundation/CPGeometryTest.j +++ b/Tests/Foundation/CPGeometryTest.j @@ -14,54 +14,54 @@ [self assertFalse:CPRectContainsRect(CGRectMake(0, 0, 500, 500), CGRectMake(500, 500, 1, 1))]; } --(void)testCPPointEqualToPoint +- (void)testCPPointEqualToPoint { - [self assertTrue:CPPointEqualToPoint(CGPointMake(10, 10), CGPointMake(10, 10))]; - [self assertFalse:CPPointEqualToPoint(CGPointMake(0, 10), CGPointMake(10, 10))]; - [self assertFalse:CPPointEqualToPoint(CGPointMake(10, 10), CGPointMake(0, 10))]; - [self assertFalse:CPPointEqualToPoint(CGPointMake(10, 0), CGPointMake(10, 10))]; - [self assertFalse:CPPointEqualToPoint(CGPointMake(10, 10), CGPointMake(10, 0))]; + [self assertTrue:CPPointEqualToPoint(CGPointMake(10, 10), CGPointMake(10, 10))]; + [self assertFalse:CPPointEqualToPoint(CGPointMake(0, 10), CGPointMake(10, 10))]; + [self assertFalse:CPPointEqualToPoint(CGPointMake(10, 10), CGPointMake(0, 10))]; + [self assertFalse:CPPointEqualToPoint(CGPointMake(10, 0), CGPointMake(10, 10))]; + [self assertFalse:CPPointEqualToPoint(CGPointMake(10, 10), CGPointMake(10, 0))]; } --(void)testCPRectEqualToRect +- (void)testCPRectEqualToRect { - [self assertTrue:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(0, 0, 100, 100))]; - [self assertFalse:CPRectEqualToRect(CGRectMake(50, 0, 100, 100), CGRectMake(0, 0, 100, 100))]; - [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(50, 0, 100, 100))]; - [self assertFalse:CPRectEqualToRect(CGRectMake(0, 50, 100, 100), CGRectMake(0, 0, 100, 100))]; - [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(0, 50, 100, 100))]; - [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 50, 100), CGRectMake(0, 0, 100, 100))]; - [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(0, 0, 50, 100))]; - [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 50), CGRectMake(0, 0, 100, 100))]; - [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(0, 0, 100, 50))]; + [self assertTrue:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(0, 0, 100, 100))]; + [self assertFalse:CPRectEqualToRect(CGRectMake(50, 0, 100, 100), CGRectMake(0, 0, 100, 100))]; + [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(50, 0, 100, 100))]; + [self assertFalse:CPRectEqualToRect(CGRectMake(0, 50, 100, 100), CGRectMake(0, 0, 100, 100))]; + [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(0, 50, 100, 100))]; + [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 50, 100), CGRectMake(0, 0, 100, 100))]; + [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(0, 0, 50, 100))]; + [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 50), CGRectMake(0, 0, 100, 100))]; + [self assertFalse:CPRectEqualToRect(CGRectMake(0, 0, 100, 100), CGRectMake(0, 0, 100, 50))]; } --(void)textCPRectIsEmpty +- (void)textCPRectIsEmpty { - [self assertTrue:CPRectIsEmpty(CGRectMake(0, 0, 0, 10))]; - [self assertTrue:CPRectIsEmpty(CGRectMake(0, 0, 10, 0))]; - [self assertTrue:CPRectIsEmpty(CGRectMake(0, 0, -10, 10))]; - [self assertTrue:CPRectIsEmpty(CGRectMake(0, 0, 10, -10))]; - [self assertFalse:CPRectIsEmpty(CGRectMake(0, 0, 10, 10))]; + [self assertTrue:CPRectIsEmpty(CGRectMake(0, 0, 0, 10))]; + [self assertTrue:CPRectIsEmpty(CGRectMake(0, 0, 10, 0))]; + [self assertTrue:CPRectIsEmpty(CGRectMake(0, 0, -10, 10))]; + [self assertTrue:CPRectIsEmpty(CGRectMake(0, 0, 10, -10))]; + [self assertFalse:CPRectIsEmpty(CGRectMake(0, 0, 10, 10))]; } --(void)testCPRectIntersection +- (void)testCPRectIntersection { - var lhsRect = CGRectMake(0, 0, 20, 20), - rhsRect = CGRectMake(10, 10, 20, 20), - intersectionResultRect = CGRectMake(10, 10, 10, 10); + var lhsRect = CGRectMake(0, 0, 20, 20), + rhsRect = CGRectMake(10, 10, 20, 20), + intersectionResultRect = CGRectMake(10, 10, 10, 10); - [self assertTrue:CPRectEqualToRect(CPRectIntersection(lhsRect, rhsRect), intersectionResultRect)]; - intersectionResultRect.origin.x = 30; - intersectionResultRect.origin.y = 30; - [self assertFalse:CPRectEqualToRect(CPRectIntersection(lhsRect, rhsRect), intersectionResultRect)]; + [self assertTrue:CPRectEqualToRect(CPRectIntersection(lhsRect, rhsRect), intersectionResultRect)]; + intersectionResultRect.origin.x = 30; + intersectionResultRect.origin.y = 30; + [self assertFalse:CPRectEqualToRect(CPRectIntersection(lhsRect, rhsRect), intersectionResultRect)]; } --(void)testCPPointCreateCopy +- (void)testCPPointCreateCopy { - var point = CGPointMake(1, 1); - [self assertTrue:CPPointEqualToPoint(CPPointCreateCopy(point),point)]; - [self assertFalse:CPPointEqualToPoint(CPPointCreateCopy(point), CGPointMake(0,1))]; + var point = CGPointMake(1, 1); + [self assertTrue:CPPointEqualToPoint(CPPointCreateCopy(point),point)]; + [self assertFalse:CPPointEqualToPoint(CPPointCreateCopy(point), CGPointMake(0,1))]; } @end