Skip to content

Commit

Permalink
Convert unit tests to GHUnit and get rid of SenTestingKit
Browse files Browse the repository at this point in the history
  • Loading branch information
brow committed Apr 7, 2010
1 parent 7affac6 commit ef7282e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 51 deletions.
64 changes: 32 additions & 32 deletions Tests/CLMatrix3x3Tests.m
Expand Up @@ -36,26 +36,26 @@ - (void) setUp {
- (void) testZero {
CLMatrix3x3 zero = CLMatrix3x3Zero();
CLMatrix3x3 test = CLMatrix3x3Multiply(a, zero);
STAssertEquals(zero, test, nil);
GHAssertEquals(zero, test, nil);
}

- (void) testIdentity {
CLMatrix3x3 identity = CLMatrix3x3Identity();
CLMatrix3x3 test = CLMatrix3x3Multiply(a, identity);
STAssertEquals(a, test, nil);
GHAssertEquals(a, test, nil);
}

- (void) testDeterminant {
STAssertEquals(CLMatrix3x3Determinant(a), (double)0, nil);
STAssertEquals(CLMatrix3x3Determinant(b), (double)-418, nil);
GHAssertEquals(CLMatrix3x3Determinant(a), (double)0, nil);
GHAssertEquals(CLMatrix3x3Determinant(b), (double)-418, nil);
}

- (void) testTranspose {
CLMatrix3x3 check = { 1, 4, 7,
2, 5, 8,
3, 6, 9 };
STAssertEquals(CLMatrix3x3Transpose(a), check, nil);
STAssertEquals(CLMatrix3x3Transpose(check), a, nil);
GHAssertEquals(CLMatrix3x3Transpose(a), check, nil);
GHAssertEquals(CLMatrix3x3Transpose(check), a, nil);
}

- (void) testMultiply {
Expand All @@ -65,8 +65,8 @@ - (void) testMultiply {
CLMatrix3x3 checkBA = { -23, -28, -33,
79, 89, 99,
37, 35, 33 };
STAssertEquals(CLMatrix3x3Multiply(a, b), checkAB, nil);
STAssertEquals(CLMatrix3x3Multiply(b, a), checkBA, nil);
GHAssertEquals(CLMatrix3x3Multiply(a, b), checkAB, nil);
GHAssertEquals(CLMatrix3x3Multiply(b, a), checkBA, nil);
}

- (void) testMultiply2 {
Expand All @@ -90,9 +90,9 @@ - (void) testMultiply3 {
}

- (void) testTrace {
STAssertEquals(CLMatrix3x3Trace(a), (double)15, nil);
STAssertEquals(CLMatrix3x3Trace(b), (double)10, nil);
STAssertEquals(CLMatrix3x3Trace(c), (double)9, nil);
GHAssertEquals(CLMatrix3x3Trace(a), (double)15, nil);
GHAssertEquals(CLMatrix3x3Trace(b), (double)10, nil);
GHAssertEquals(CLMatrix3x3Trace(c), (double)9, nil);
}

- (void) testSubtract {
Expand All @@ -102,22 +102,22 @@ - (void) testSubtract {
- (void) testEigenvalues {
double test[3], checkA[3] = {-1.116844, 0, 16.116844}, checkC[3] = {1, 2, 6};
CLMatrix3x3Eigenvalues(a, test);
STAssertEqualsWithAccuracy(test[0], checkA[0], ACCURACY, nil);
STAssertEqualsWithAccuracy(test[1], checkA[1], ACCURACY, nil);
STAssertEqualsWithAccuracy(test[2], checkA[2], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[0], checkA[0], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[1], checkA[1], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[2], checkA[2], ACCURACY, nil);

CLMatrix3x3Eigenvalues(c, test);
STAssertEqualsWithAccuracy(test[0], checkC[0], ACCURACY, nil);
STAssertEqualsWithAccuracy(test[1], checkC[1], ACCURACY, nil);
STAssertEqualsWithAccuracy(test[2], checkC[2], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[0], checkC[0], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[1], checkC[1], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[2], checkC[2], ACCURACY, nil);
}

- (void) testEigenvaluesOneReal {
double test[3], check[3] = {0, 0, 1};
CLMatrix3x3Eigenvalues(e, test);
STAssertEqualsWithAccuracy(test[0], check[0], ACCURACY, nil);
STAssertEqualsWithAccuracy(test[1], check[1], ACCURACY, nil);
STAssertEqualsWithAccuracy(test[2], check[2], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[0], check[0], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[1], check[1], ACCURACY, nil);
GHAssertEqualsWithAccuracy(test[2], check[2], ACCURACY, nil);
}

- (void) testEigenvectorsSymmetric{
Expand All @@ -127,18 +127,18 @@ - (void) testEigenvectorsSymmetric{
0.128914, -0.594840, 0.793440 };

CLMatrix3x3SymmetricEigenvectors(d, testValues, testVectors);
STAssertEqualsWithAccuracy(testValues[0], checkValues[0], ACCURACY, nil);
STAssertEqualsWithAccuracy(testValues[1], checkValues[1], ACCURACY, nil);
STAssertEqualsWithAccuracy(testValues[2], checkValues[2], ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[0].x), abs(checkVectors[0].x), ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[0].y), abs(checkVectors[0].y), ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[0].z), abs(checkVectors[0].z), ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[1].x), abs(checkVectors[1].x), ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[1].y), abs(checkVectors[1].y), ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[1].z), abs(checkVectors[1].z), ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[2].x), abs(checkVectors[2].x), ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[2].y), abs(checkVectors[2].y), ACCURACY, nil);
STAssertEqualsWithAccuracy(abs(testVectors[2].z), abs(checkVectors[2].z), ACCURACY, nil);
GHAssertEqualsWithAccuracy(testValues[0], checkValues[0], ACCURACY, nil);
GHAssertEqualsWithAccuracy(testValues[1], checkValues[1], ACCURACY, nil);
GHAssertEqualsWithAccuracy(testValues[2], checkValues[2], ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[0].x), abs(checkVectors[0].x), ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[0].y), abs(checkVectors[0].y), ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[0].z), abs(checkVectors[0].z), ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[1].x), abs(checkVectors[1].x), ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[1].y), abs(checkVectors[1].y), ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[1].z), abs(checkVectors[1].z), ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[2].x), abs(checkVectors[2].x), ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[2].y), abs(checkVectors[2].y), ACCURACY, nil);
GHAssertEqualsWithAccuracy(abs(testVectors[2].z), abs(checkVectors[2].z), ACCURACY, nil);
}

@end
6 changes: 2 additions & 4 deletions Tests/CLTests.h
@@ -1,11 +1,9 @@
#define USE_APPLICATION_UNIT_TEST 1

#import <QuartzCore/QuartzCore.h>
#import <SenTestingKit/SenTestingKit.h>
#import <UIKit/UIKit.h>
#import "GHTestCase.h"
#import "CLVector.h"

@interface CLTests : SenTestCase {
@interface CLTests : GHTestCase {

}

Expand Down
8 changes: 4 additions & 4 deletions Tests/CLTests.m
Expand Up @@ -7,10 +7,10 @@ - (void) setUp {
}

- (void) assertDouble:(double)a equalsDouble:(double)b withAccuracy:(double)accuracy {
/* STAssertEqualsWithAccuracy is inaccurate when either argument is not finite. */
STAssertTrue(isfinite(a), nil);
STAssertTrue(isfinite(b), nil);
STAssertEqualsWithAccuracy(a, b, accuracy, nil);
/* GHAssertEqualsWithAccuracy is inaccurate when either argument is not finite. */
GHAssertTrue(isfinite(a), nil);
GHAssertTrue(isfinite(b), nil);
GHAssertEqualsWithAccuracy(a, b, accuracy, nil);
}

- (void) assertTransform:(CATransform3D)a equalsTransform:(CATransform3D)b withAccuracy:(double)accuracy {
Expand Down
5 changes: 2 additions & 3 deletions Tests/CLVectorTests.h
@@ -1,9 +1,8 @@
#import <SenTestingKit/SenTestingKit.h>
#import <UIKit/UIKit.h>

#import "GHUnit.h"
#import "CLVector.h"

@interface VectorTests : SenTestCase {
@interface VectorTests : GHTestCase {
CLVector a, b, c;
}

Expand Down
9 changes: 5 additions & 4 deletions Tests/CLVectorTests.m
@@ -1,13 +1,14 @@
#import "CLVectorTests.h"
#import "GHUnit.h"

#define ACCURACY 0.000000001

@implementation VectorTests

- (void) assertVector:(CLVector)test equalsVector:(CLVector)check withAccuracy:(double)accuracy {
STAssertEqualsWithAccuracy(test.x, check.x, ACCURACY, nil);
STAssertEqualsWithAccuracy(test.y, check.y, ACCURACY, nil);
STAssertEqualsWithAccuracy(test.z, check.z, ACCURACY, nil);
GHAssertEqualsWithAccuracy(test.x, check.x, ACCURACY, nil);
GHAssertEqualsWithAccuracy(test.y, check.y, ACCURACY, nil);
GHAssertEqualsWithAccuracy(test.z, check.z, ACCURACY, nil);
}

- (void) setUp {
Expand All @@ -33,7 +34,7 @@ - (void) testCross {
- (void) testDot {
double test = CLVectorDotProduct(a,b);
double check = -1.2;
STAssertEqualsWithAccuracy(test, check, ACCURACY, nil);
GHAssertEqualsWithAccuracy(test, check, ACCURACY, nil);
}

- (void) testNormalize {
Expand Down
4 changes: 0 additions & 4 deletions iPhone.xcodeproj/project.pbxproj
Expand Up @@ -13,7 +13,6 @@
D30E5643116D40D50068F320 /* CLQuaternion.m in Sources */ = {isa = PBXBuildFile; fileRef = D30E563D116D40D50068F320 /* CLQuaternion.m */; };
D30E5644116D40D50068F320 /* CLVector.m in Sources */ = {isa = PBXBuildFile; fileRef = D30E563F116D40D50068F320 /* CLVector.m */; };
D333CEC2116D142A00E017CE /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
D333CF4D116D15F300E017CE /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D333CF4C116D15F300E017CE /* SenTestingKit.framework */; };
D333CFA1116D166D00E017CE /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D333CFA0116D166D00E017CE /* QuartzCore.framework */; };
D36F83CA116D202600F596DE /* GHUnitIPhoneTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = D36F83BC116D202600F596DE /* GHUnitIPhoneTestMain.m */; };
D36F83CB116D202600F596DE /* libGHUnitIPhone3_0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D36F83BE116D202600F596DE /* libGHUnitIPhone3_0.a */; };
Expand All @@ -38,7 +37,6 @@
D30E563E116D40D50068F320 /* CLVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLVector.h; path = CocoaLinear/CLVector.h; sourceTree = "<group>"; };
D30E563F116D40D50068F320 /* CLVector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLVector.m; path = CocoaLinear/CLVector.m; sourceTree = "<group>"; };
D333CE76116D134C00E017CE /* Test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Test.app; sourceTree = BUILT_PRODUCTS_DIR; };
D333CF4C116D15F300E017CE /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
D333CFA0116D166D00E017CE /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
D36F83AE116D1FF700F596DE /* Test-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Test-Info.plist"; sourceTree = "<group>"; };
D36F83B2116D202600F596DE /* GHAsyncTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHAsyncTestCase.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -72,7 +70,6 @@
buildActionMask = 2147483647;
files = (
D333CEC2116D142A00E017CE /* CoreGraphics.framework in Frameworks */,
D333CF4D116D15F300E017CE /* SenTestingKit.framework in Frameworks */,
D333CFA1116D166D00E017CE /* QuartzCore.framework in Frameworks */,
D36F83CB116D202600F596DE /* libGHUnitIPhone3_0.a in Frameworks */,
);
Expand Down Expand Up @@ -114,7 +111,6 @@
isa = PBXGroup;
children = (
D333CFA0116D166D00E017CE /* QuartzCore.framework */,
D333CF4C116D15F300E017CE /* SenTestingKit.framework */,
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
1D30AB110D05D00D00671497 /* Foundation.framework */,
288765FC0DF74451002DB57D /* CoreGraphics.framework */,
Expand Down

0 comments on commit ef7282e

Please sign in to comment.