OLD | NEW |
1 //------------------------------------------------------------------------------
--------- | 1 /* |
2 // $Id$ | 2 * Copyright (c) 2004-2015 Erik Doernenburg and contributors |
3 // Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details. | 3 * |
4 //------------------------------------------------------------------------------
--------- | 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 */ |
5 | 16 |
6 #import <OCMock/OCMockObject.h> | 17 #import <OCMock/OCMockObject.h> |
7 #import <OCMock/OCMockRecorder.h> | 18 #import <OCMock/OCMRecorder.h> |
| 19 #import <OCMock/OCMStubRecorder.h> |
8 #import <OCMock/OCMConstraint.h> | 20 #import <OCMock/OCMConstraint.h> |
9 #import <OCMock/OCMArg.h> | 21 #import <OCMock/OCMArg.h> |
| 22 #import <OCMock/OCMLocation.h> |
| 23 #import <OCMock/OCMMacroState.h> |
10 #import <OCMock/NSNotificationCenter+OCMAdditions.h> | 24 #import <OCMock/NSNotificationCenter+OCMAdditions.h> |
| 25 |
| 26 |
| 27 #define OCMClassMock(cls) [OCMockObject niceMockForClass:cls] |
| 28 |
| 29 #define OCMStrictClassMock(cls) [OCMockObject mockForClass:cls] |
| 30 |
| 31 #define OCMProtocolMock(protocol) [OCMockObject niceMockForProtocol:protocol] |
| 32 |
| 33 #define OCMStrictProtocolMock(protocol) [OCMockObject mockForProtocol:protocol] |
| 34 |
| 35 #define OCMPartialMock(obj) [OCMockObject partialMockForObject:obj] |
| 36 |
| 37 #define OCMObserverMock() [OCMockObject observerMock] |
| 38 |
| 39 |
| 40 #define OCMStub(invocation) \ |
| 41 ({ \ |
| 42 _OCMSilenceWarnings( \ |
| 43 [OCMMacroState beginStubMacro]; \ |
| 44 invocation; \ |
| 45 [OCMMacroState endStubMacro]; \ |
| 46 ); \ |
| 47 }) |
| 48 |
| 49 #define OCMExpect(invocation) \ |
| 50 ({ \ |
| 51 _OCMSilenceWarnings( \ |
| 52 [OCMMacroState beginExpectMacro]; \ |
| 53 invocation; \ |
| 54 [OCMMacroState endExpectMacro]; \ |
| 55 ); \ |
| 56 }) |
| 57 |
| 58 #define ClassMethod(invocation) \ |
| 59 _OCMSilenceWarnings( \ |
| 60 [[OCMMacroState globalState] switchToClassMethod]; \ |
| 61 invocation; \ |
| 62 ); |
| 63 |
| 64 |
| 65 #define OCMVerifyAll(mock) [mock verifyAtLocation:OCMMakeLocation(self, __FILE__
, __LINE__)] |
| 66 |
| 67 #define OCMVerifyAllWithDelay(mock, delay) [mock verifyWithDelay:delay atLocatio
n:OCMMakeLocation(self, __FILE__, __LINE__)] |
| 68 |
| 69 #define OCMVerify(invocation) \ |
| 70 ({ \ |
| 71 _OCMSilenceWarnings( \ |
| 72 [OCMMacroState beginVerifyMacroAtLocation:OCMMakeLocation(self, __FILE__
, __LINE__)]; \ |
| 73 invocation; \ |
| 74 [OCMMacroState endVerifyMacro]; \ |
| 75 ); \ |
| 76 }) |
| 77 |
| 78 #define _OCMSilenceWarnings(macro) \ |
| 79 ({ \ |
| 80 _Pragma("clang diagnostic push") \ |
| 81 _Pragma("clang diagnostic ignored \"-Wunused-value\"") \ |
| 82 _Pragma("clang diagnostic ignored \"-Wunused-getter-return-value\"") \ |
| 83 macro \ |
| 84 _Pragma("clang diagnostic pop") \ |
| 85 }) |
OLD | NEW |