[Chlor-commits] SF.net SVN: chlor: [521] trunk/src/tests
Status: Pre-Alpha
Brought to you by:
lenny222
From: Chlor c. to s. <chl...@li...> - 2007-05-22 20:50:17
|
Revision: 521 http://svn.sourceforge.net/chlor/?rev=521&view=rev Author: lenny222 Date: 2007-05-22 13:50:15 -0700 (Tue, 22 May 2007) Log Message: ----------- unit test improvelets Modified Paths: -------------- trunk/src/tests/CAffineMapTest.m trunk/src/tests/CCollectionTest.h trunk/src/tests/CCollectionTest.m trunk/src/tests/CGroupTest.m trunk/src/tests/CRectTest.m trunk/src/tests/CSegmentTest.h trunk/src/tests/CSegmentTest.m trunk/src/tests/CSelectionTest.m Modified: trunk/src/tests/CAffineMapTest.m =================================================================== --- trunk/src/tests/CAffineMapTest.m 2007-05-22 20:22:33 UTC (rev 520) +++ trunk/src/tests/CAffineMapTest.m 2007-05-22 20:50:15 UTC (rev 521) @@ -36,6 +36,7 @@ [m_affineMap release]; } +// Tests combinations of affine transformations. - (void) testCombinations { // Reset affine map. Translate and rotate by 90 degrees. @@ -59,6 +60,7 @@ } } +// Tests the rotation transformation. - (void) testRotation { // Reset affine map and rotate by 90 degrees. @@ -113,6 +115,7 @@ } } +// Tests the scaling transformation. - (void) testScaling { // Reset affine map and scale. @@ -134,6 +137,7 @@ } } +// Tests the inversion of transformations. - (void) testInverse { // Reset affine map and scale. Modified: trunk/src/tests/CCollectionTest.h =================================================================== --- trunk/src/tests/CCollectionTest.h 2007-05-22 20:22:33 UTC (rev 520) +++ trunk/src/tests/CCollectionTest.h 2007-05-22 20:50:15 UTC (rev 521) @@ -20,7 +20,5 @@ #import <SenTestingKit/SenTestingKit.h> @interface CCollectionTest : SenTestCase -{ -} @end \ No newline at end of file Modified: trunk/src/tests/CCollectionTest.m =================================================================== --- trunk/src/tests/CCollectionTest.m 2007-05-22 20:22:33 UTC (rev 520) +++ trunk/src/tests/CCollectionTest.m 2007-05-22 20:50:15 UTC (rev 521) @@ -23,8 +23,10 @@ @implementation CCollectionTest +// Tests an empty collection. - (void) testEmptyCollection { + // Create an empty collection. CCollection* collection = [[CCollection emptyCollection] retain]; @try @@ -38,14 +40,17 @@ } } +// Tests a collection having one object. - (void) testCollectionWithOneObject { CCollection* collection = nil; + + // Create a rectangle. CPath* rectangle = [[CShape rectangleLeft: 0.0f bottom: -2.5f width: 10.0f height: 5.0f] retain]; @try { - // Create a collection with one object. + // Create a collection with the rectangle. collection = [[CCollection collectionWithObject: rectangle] retain]; // The collection should have one object. @@ -58,6 +63,7 @@ } } +// Test the collection's copy: method. - (void) testCopying { CCollection* collection1 = nil; @@ -87,10 +93,13 @@ } } +// Tests the serial addition of objects to a collection. - (void) testAddition { CCollection* collection1 = nil; CCollection* collection2 = nil; + + // Create a rectangle. CPath* rectangle = [[CShape rectangleLeft: 0.0f bottom: -2.5f width: 10.0f height: 5.0f] retain]; @try Modified: trunk/src/tests/CGroupTest.m =================================================================== --- trunk/src/tests/CGroupTest.m 2007-05-22 20:22:33 UTC (rev 520) +++ trunk/src/tests/CGroupTest.m 2007-05-22 20:50:15 UTC (rev 521) @@ -35,32 +35,29 @@ [m_group release]; } -- (void) testManipulation +// Tests the collection getter and setter. +- (void) testCollectionGetterAndSetter { - CPath* rectangle = [[CShape rectangleLeft: -52.0f bottom: 13.2f width: 22.0f height: 0.72f] retain]; + CCollection* collection = nil; @try { - // Clear the group. - [m_group setCollection: [CCollection emptyCollection]]; + // Create an empty collection. + collection = [[CCollection emptyCollection] retain]; - // Number of objects in the empty group should be zero. - STAssertEquals( [[m_group collection] count], 0, nil ); + // Set the collection. + [m_group setCollection: collection]; - // Add the rectangle to the group. - [m_group setCollection: - [[m_group collection] - collectionWithAddedObject: rectangle]]; - - // Number of objects in the group should be one. - STAssertEquals( [[m_group collection] count], 1, nil ); + // Compare the group collection with the given collection. + STAssertEquals( [m_group collection], collection, nil ); } @finally { - [rectangle release]; + [collection release]; } } +// Tests the boundaries. - (void) testBoundary { CPath* rectangle = [[CShape rectangleLeft: -52.0f bottom: 13.2f width: 22.0f height: 5.42f] retain]; @@ -84,4 +81,40 @@ } } +// Test the copy: method. +- (void) testCopying +{ + CGroup* group = nil; + CCollection* collection1 = nil; + CCollection* collection2 = nil; + + // Create a rectangle. + CPath* rectangle = [[CShape rectangleLeft: -1.3f bottom: 43.23f width: 12.0f height: 2.3f] retain]; + + @try + { + // Create a collection with one object. + collection1 = [[CCollection collectionWithObject: rectangle] retain]; + + // Create a new collection having two objects. + collection2 = [[collection1 collectionWithAddedObject: rectangle] retain]; + + // Set the collection to the group. + [m_group setCollection: collection2]; + + // Copy the group. + group = [m_group copy]; + + // The group collection should have two objects. + STAssertEquals( [[m_group collection] count], 2, nil ); + } + @finally + { + [rectangle release]; + [collection1 release]; + [collection2 release]; + [group release]; + } +} + @end Modified: trunk/src/tests/CRectTest.m =================================================================== --- trunk/src/tests/CRectTest.m 2007-05-22 20:22:33 UTC (rev 520) +++ trunk/src/tests/CRectTest.m 2007-05-22 20:50:15 UTC (rev 521) @@ -33,6 +33,7 @@ [m_rect release]; } +// Tests the addition of rectangles. - (void) testAddition { // Set m_rect to ((0,-1),(1,1)). @@ -61,6 +62,7 @@ } } +// Tests the getter and setter methods. - (void) testGetterAndSetter { // Set m_rect to ((0,0),(0,0)). @@ -100,6 +102,7 @@ STAssertEquals( [m_rect centerY], -1.0f, nil ); } +// Tests the grow: method. - (void) testGrow { // Set m_rect to ((3,5),(17,15)). @@ -115,6 +118,7 @@ STAssertEquals( [m_rect height], 20.0f, nil ); } +// Tests the overlapsWithRect: and overlapsWithCGRect: methods. - (void) testOverlap { // Set m_rect to ((10,5),(15,10)). Modified: trunk/src/tests/CSegmentTest.h =================================================================== --- trunk/src/tests/CSegmentTest.h 2007-05-22 20:22:33 UTC (rev 520) +++ trunk/src/tests/CSegmentTest.h 2007-05-22 20:50:15 UTC (rev 521) @@ -20,7 +20,5 @@ #import <SenTestingKit/SenTestingKit.h> @interface CSegmentTest : SenTestCase -{ -} @end Modified: trunk/src/tests/CSegmentTest.m =================================================================== --- trunk/src/tests/CSegmentTest.m 2007-05-22 20:22:33 UTC (rev 520) +++ trunk/src/tests/CSegmentTest.m 2007-05-22 20:50:15 UTC (rev 521) @@ -23,6 +23,7 @@ @implementation CSegmentTest +// Tests the powerFormCoefficients: method. - (void) testCubicPowerFormCoefficients { const double x0 = 0.0; Modified: trunk/src/tests/CSelectionTest.m =================================================================== --- trunk/src/tests/CSelectionTest.m 2007-05-22 20:22:33 UTC (rev 520) +++ trunk/src/tests/CSelectionTest.m 2007-05-22 20:50:15 UTC (rev 521) @@ -36,6 +36,7 @@ [m_selection release]; } +// Tests the boundaries of the selection. - (void) testBoundaries { // Create a rectangle. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |