forked from defagos/CoconutKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests for zeroing weak references
- Loading branch information
Showing
5 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// HLSZeroingWeakRefTestCase.h | ||
// CoconutKit-test | ||
// | ||
// Created by Samuel Défago on 03.04.12. | ||
// Copyright (c) 2012 Hortis. All rights reserved. | ||
// | ||
|
||
@interface HLSZeroingWeakRefTestCase : GHTestCase | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// HLSZeroingWeakRefTestCase.m | ||
// CoconutKit-test | ||
// | ||
// Created by Samuel Défago on 03.04.12. | ||
// Copyright (c) 2012 Hortis. All rights reserved. | ||
// | ||
|
||
#import "HLSZeroingWeakRefTestCase.h" | ||
|
||
@interface BasicClass : NSObject | ||
|
||
@end | ||
|
||
@implementation HLSZeroingWeakRefTestCase | ||
|
||
#pragma mark Tests | ||
|
||
- (void)testNonTollFreeBridgedObject | ||
{ | ||
BasicClass *basicClass = [[BasicClass alloc] init]; | ||
HLSZeroingWeakRef *zeroingWeakRef = [[[HLSZeroingWeakRef alloc] initWithObject:basicClass] autorelease]; | ||
GHAssertNotNil(zeroingWeakRef.object, @"Non-zeroed object reference"); | ||
[basicClass release]; | ||
GHAssertNil(zeroingWeakRef.object, @"Zeroed object reference"); | ||
} | ||
|
||
- (void)testTollFreeBridgedObject | ||
{ | ||
NSNumber *number = [[NSNumber alloc] initWithInt:1012]; | ||
GHAssertThrows([[HLSZeroingWeakRef alloc] initWithObject:number], @"Cannot create from Core Foundation objects"); | ||
[number release]; | ||
} | ||
|
||
@end | ||
|
||
@implementation BasicClass | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters