Skip to content

Commit 3423412

Browse files
added missing headers for iOS tests
1 parent da9f9ae commit 3423412

File tree

10 files changed

+558
-0
lines changed

10 files changed

+558
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2009-2018 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@class OCObserverMockObject;
20+
21+
22+
@interface NSNotificationCenter(OCMAdditions)
23+
24+
- (void)addMockObserver:(OCObserverMockObject *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender;
25+
26+
@end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2009-2018 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@interface OCMArg : NSObject
20+
21+
// constraining arguments
22+
23+
+ (id)any;
24+
+ (SEL)anySelector;
25+
+ (void *)anyPointer;
26+
+ (id __autoreleasing *)anyObjectRef;
27+
+ (id)isNil;
28+
+ (id)isNotNil;
29+
+ (id)isEqual:(id)value;
30+
+ (id)isNotEqual:(id)value;
31+
+ (id)isKindOfClass:(Class)cls;
32+
+ (id)checkWithSelector:(SEL)selector onObject:(id)anObject;
33+
+ (id)checkWithBlock:(BOOL (^)(id obj))block;
34+
35+
// manipulating arguments
36+
37+
+ (id *)setTo:(id)value;
38+
+ (void *)setToValue:(NSValue *)value;
39+
+ (id)invokeBlock;
40+
+ (id)invokeBlockWithArgs:(id)first,... NS_REQUIRES_NIL_TERMINATION;
41+
42+
+ (id)defaultValue;
43+
44+
// internal use only
45+
46+
+ (id)resolveSpecialValues:(NSValue *)value;
47+
48+
@end
49+
50+
#define OCMOCK_ANY [OCMArg any]
51+
52+
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
53+
#define OCMOCK_VALUE(variable) \
54+
({ __typeof__(variable) __v = (variable); [NSValue value:&__v withObjCType:@encode(__typeof__(__v))]; })
55+
#else
56+
#define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))]
57+
#endif
58+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2007-2018 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
20+
@interface OCMConstraint : NSObject
21+
22+
+ (instancetype)constraint;
23+
- (BOOL)evaluate:(id)value;
24+
25+
// if you are looking for any, isNil, etc, they have moved to OCMArg
26+
27+
// try to use [OCMArg checkWith...] instead of the constraintWith... methods below
28+
29+
+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject;
30+
+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject withValue:(id)aValue;
31+
32+
33+
@end
34+
35+
@interface OCMAnyConstraint : OCMConstraint
36+
@end
37+
38+
@interface OCMIsNilConstraint : OCMConstraint
39+
@end
40+
41+
@interface OCMIsNotNilConstraint : OCMConstraint
42+
@end
43+
44+
@interface OCMIsNotEqualConstraint : OCMConstraint
45+
{
46+
@public
47+
id testValue;
48+
}
49+
50+
@end
51+
52+
@interface OCMInvocationConstraint : OCMConstraint
53+
{
54+
@public
55+
NSInvocation *invocation;
56+
}
57+
58+
@end
59+
60+
@interface OCMBlockConstraint : OCMConstraint
61+
{
62+
BOOL (^block)(id);
63+
}
64+
65+
- (instancetype)initWithConstraintBlock:(BOOL (^)(id))block;
66+
67+
@end
68+
69+
70+
#define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self]
71+
#define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2014-2018 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
20+
#if defined(__cplusplus)
21+
#define OCMOCK_EXTERN extern "C"
22+
#else
23+
#define OCMOCK_EXTERN extern
24+
#endif
25+
26+
27+
OCMOCK_EXTERN BOOL OCMIsObjectType(const char *objCType);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2014-2018 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
#import "OCMFunctions.h"
19+
20+
21+
@interface OCMLocation : NSObject
22+
{
23+
id testCase;
24+
NSString *file;
25+
NSUInteger line;
26+
}
27+
28+
+ (instancetype)locationWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine;
29+
30+
- (instancetype)initWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine;
31+
32+
- (id)testCase;
33+
- (NSString *)file;
34+
- (NSUInteger)line;
35+
36+
@end
37+
38+
OCMOCK_EXTERN OCMLocation *OCMMakeLocation(id testCase, const char *file, int line);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2014-2018 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@class OCMLocation;
20+
@class OCMRecorder;
21+
@class OCMStubRecorder;
22+
@class OCMockObject;
23+
24+
25+
@interface OCMMacroState : NSObject
26+
{
27+
OCMRecorder *recorder;
28+
}
29+
30+
+ (void)beginStubMacro;
31+
+ (OCMStubRecorder *)endStubMacro;
32+
33+
+ (void)beginExpectMacro;
34+
+ (OCMStubRecorder *)endExpectMacro;
35+
36+
+ (void)beginRejectMacro;
37+
+ (OCMStubRecorder *)endRejectMacro;
38+
39+
+ (void)beginVerifyMacroAtLocation:(OCMLocation *)aLocation;
40+
+ (void)endVerifyMacro;
41+
42+
+ (OCMMacroState *)globalState;
43+
44+
- (OCMRecorder *)recorder;
45+
46+
- (void)switchToClassMethod;
47+
48+
@end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2014-2018 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@class OCMockObject;
20+
@class OCMInvocationMatcher;
21+
22+
23+
@interface OCMRecorder : NSProxy
24+
{
25+
OCMockObject *mockObject;
26+
OCMInvocationMatcher *invocationMatcher;
27+
}
28+
29+
- (instancetype)init;
30+
- (instancetype)initWithMockObject:(OCMockObject *)aMockObject;
31+
32+
- (void)setMockObject:(OCMockObject *)aMockObject;
33+
34+
- (OCMInvocationMatcher *)invocationMatcher;
35+
36+
- (id)classMethod;
37+
- (id)ignoringNonObjectArgs;
38+
39+
@end
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2004-2018 Erik Doernenburg and contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use these files except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
#import <OCMock/OCMRecorder.h>
18+
#import <OCMock/OCMFunctions.h>
19+
#import <objc/runtime.h>
20+
21+
@interface OCMStubRecorder : OCMRecorder
22+
23+
- (id)andReturn:(id)anObject;
24+
- (id)andReturnValue:(NSValue *)aValue;
25+
- (id)andThrow:(NSException *)anException;
26+
- (id)andPost:(NSNotification *)aNotification;
27+
- (id)andCall:(SEL)selector onObject:(id)anObject;
28+
- (id)andDo:(void (^)(NSInvocation *invocation))block;
29+
- (id)andForwardToRealObject;
30+
31+
@end
32+
33+
34+
@interface OCMStubRecorder (Properties)
35+
36+
#define andReturn(aValue) _andReturn(({ \
37+
__typeof__(aValue) _val = (aValue); \
38+
NSValue *_nsval = [NSValue value:&_val withObjCType:@encode(__typeof__(_val))]; \
39+
if (OCMIsObjectType(@encode(__typeof(_val)))) { \
40+
objc_setAssociatedObject(_nsval, "OCMAssociatedBoxedValue", *(__unsafe_unretained id *) (void *) &_val, OBJC_ASSOCIATION_RETAIN); \
41+
} \
42+
_nsval; \
43+
}))
44+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andReturn)(NSValue *);
45+
46+
#define andThrow(anException) _andThrow(anException)
47+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andThrow)(NSException *);
48+
49+
#define andPost(aNotification) _andPost(aNotification)
50+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andPost)(NSNotification *);
51+
52+
#define andCall(anObject, aSelector) _andCall(anObject, aSelector)
53+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andCall)(id, SEL);
54+
55+
#define andDo(aBlock) _andDo(aBlock)
56+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andDo)(void (^)(NSInvocation *));
57+
58+
#define andForwardToRealObject() _andForwardToRealObject()
59+
@property (nonatomic, readonly) OCMStubRecorder *(^ _andForwardToRealObject)(void);
60+
61+
@end
62+
63+
64+

0 commit comments

Comments
 (0)