Skip to content

Commit

Permalink
[core] Flesh out more core tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Jan 27, 2012
1 parent 4bd35bc commit 81d2b36
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/core/src/NSString+NimbusCore.h
Expand Up @@ -47,5 +47,4 @@
@property (nonatomic, readonly) NSString* md5Hash;
@property (nonatomic, readonly) NSString* sha1Hash;


@end
14 changes: 8 additions & 6 deletions src/core/src/NSString+NimbusCore.m
Expand Up @@ -56,13 +56,15 @@ - (BOOL)isWhitespaceAndNewlines {
*
* A convenience wrapper for sizeWithFont:constrainedToSize:lineBreakMode:
*/
- (CGFloat)heightWithFont: (UIFont*)font
constrainedToWidth: (CGFloat)width
lineBreakMode: (UILineBreakMode)lineBreakMode {
return [self sizeWithFont: font
constrainedToSize: CGSizeMake(width, CGFLOAT_MAX)
lineBreakMode: lineBreakMode].height;
// COV_NF_START
- (CGFloat)heightWithFont:(UIFont*)font
constrainedToWidth:(CGFloat)width
lineBreakMode:(UILineBreakMode)lineBreakMode {
return [self sizeWithFont:font
constrainedToSize:CGSizeMake(width, CGFLOAT_MAX)
lineBreakMode:lineBreakMode].height;
}
// COV_NF_END


///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
31 changes: 31 additions & 0 deletions src/core/unittests/NICoreAdditionTests.m
Expand Up @@ -217,4 +217,35 @@ - (void)testNSString_versionStringCompare {
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)testNSString_md5Hash {
STAssertTrue([[@"nimbus" md5Hash] isEqualToString:@"0e78d66f33c484a3c3b36d69bd3114cf"],
@"MD5 hashes don't match.");
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)testNSString_sha1Hash {
STAssertTrue([[@"nimbus" sha1Hash] isEqualToString:@"c1b42d95fd18ad8a56d4fd7bbb4105952620d857"],
@"SHA1 hashes don't match.");
}


///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark UIView Additions


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)testCenterWithin {
UIView *containerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] autorelease];
UIView *subview = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease];

[subview centerWithin:containerView];

STAssertTrue(CGRectEqualToRect(subview.frame, CGRectMake(45, 45, 10, 10)), @"Rect should be centered.");
}


@end
6 changes: 6 additions & 0 deletions src/core/unittests/NINetworkActivityTests.m
Expand Up @@ -24,8 +24,14 @@
@interface NINetworkActivityTests : SenTestCase
@end


///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
@implementation NINetworkActivityTests


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)testNetworkActivity {
STAssertFalse([UIApplication sharedApplication].networkActivityIndicatorVisible,
@"Activity indicator should be hidden.");
Expand Down
8 changes: 8 additions & 0 deletions src/core/unittests/NIStateTests.m
Expand Up @@ -24,13 +24,21 @@
@interface NIStateTests : SenTestCase
@end


///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
@implementation NIStateTests


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)testSingletonAccess {
STAssertNotNil([Nimbus imageMemoryCache], @"Singleton object should be created automatically.");
STAssertNotNil([Nimbus networkOperationQueue], @"Singleton object should be created automatically.");
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)testSingletonSetting {
NIImageMemoryCache *cache = [[[NIImageMemoryCache alloc] init] autorelease];
[Nimbus setImageMemoryCache:cache];
Expand Down

0 comments on commit 81d2b36

Please sign in to comment.