10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
*/
#include "config.h"
#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "main.h"
static OFString *module = @"Properties";
@interface PropertiesTest: OFObject
{
OFString *foo;
OFString *bar;
|
|
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
*/
#include "config.h"
#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "TestsAppDelegate.h"
static OFString *module = @"Properties";
@interface PropertiesTest: OFObject
{
OFString *foo;
OFString *bar;
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
[foo release];
[bar release];
[super dealloc];
}
@end
void
properties_tests()
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
PropertiesTest *pt = [[[PropertiesTest alloc] init] autorelease];
OFString *t = [OFMutableString stringWithString: @"foo"];
[pt setFoo: t];
TEST(@"copy, nonatomic", [[pt foo] isEqual: @"foo"] &&
[pt foo] != @"foo" && [[pt foo] retainCount] == 1)
[pt setBar: t];
TEST(@"retain, atomic", [pt bar] == t && [t retainCount] == 3)
[pool drain];
}
|
|
|
>
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
[foo release];
[bar release];
[super dealloc];
}
@end
@implementation TestsAppDelegate (PropertiesTests)
- (void)propertiesTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
PropertiesTest *pt = [[[PropertiesTest alloc] init] autorelease];
OFString *t = [OFMutableString stringWithString: @"foo"];
[pt setFoo: t];
TEST(@"copy, nonatomic", [[pt foo] isEqual: @"foo"] &&
[pt foo] != @"foo" && [[pt foo] retainCount] == 1)
[pt setBar: t];
TEST(@"retain, atomic", [pt bar] == t && [t retainCount] == 3)
[pool drain];
}
@end
|