-
Notifications
You must be signed in to change notification settings - Fork 44
/
AboutRetain.m
59 lines (44 loc) · 1.89 KB
/
AboutRetain.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// AboutAssertions.m
// ObjectiveCKoans
//
// Created by Curtis Schofield
// Copyright 2011 BlazingCloud, Curtis J Schofield
//
#import "Kiwi.h"
SPEC_BEGIN(AboutRetain)
describe(@"Retain Assertions", ^{
context(@"NSMutableString Retain", ^{
__block NSMutableString *aString = NULL;
beforeEach(^{
aString = [[NSMutableString alloc] init];
});
it(@"starts with a retainCount value", ^{
int actual_count = [aString retainCount];
int expected_count = -1; // change this to the correct value
[[theValue(actual_count) should] equal:theValue(expected_count)];
});
it(@"increments retainCount value according to the selector retain", ^{
[aString retain];
int actual_count = [aString retainCount];
int expected_count = -2; // change this to the correct value
[[theValue(actual_count) should] equal:theValue(expected_count)];
});
it(@"decriments retainCount on selector release", ^{
[aString retain];
[aString release];
int actual_count = [aString retainCount];
int expected_count = -1; // change this to the correct value
[[theValue(actual_count) should] equal:theValue(expected_count)];
[aString release];
actual_count = [aString retainCount];
expected_count = -1; // change this to the correct value
[[theValue(actual_count) should] equal:theValue(expected_count)];
//
// Did you not get what you expected? Check this resource out.
//
// http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html
});
});
});
SPEC_END