| OLD | NEW |
| 1 //------------------------------------------------------------------------------
--------- | 1 /* |
| 2 // $Id$ | 2 * Copyright (c) 2009-2015 Erik Doernenburg and contributors |
| 3 // Copyright (c) 2009 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 <objc/runtime.h> | 17 #import <objc/runtime.h> |
| 7 #import <OCMock/OCMConstraint.h> | 18 #import <OCMock/OCMConstraint.h> |
| 8 #import "NSInvocation+OCMAdditions.h" | 19 #import "NSInvocation+OCMAdditions.h" |
| 9 #import "OCMObserverRecorder.h" | 20 #import "OCMObserverRecorder.h" |
| 10 | 21 |
| 11 @interface NSObject(HCMatcherDummy) | 22 @interface NSObject(HCMatcherDummy) |
| 12 - (BOOL)matches:(id)item; | 23 - (BOOL)matches:(id)item; |
| 13 @end | 24 @end |
| 14 | 25 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 45 { | 56 { |
| 46 return [self argument:[recordedNotification name] matchesArgument:[aNoti
fication name]] && | 57 return [self argument:[recordedNotification name] matchesArgument:[aNoti
fication name]] && |
| 47 [self argument:[recordedNotification object] matchesArgument:[aNotificat
ion object]] && | 58 [self argument:[recordedNotification object] matchesArgument:[aNotificat
ion object]] && |
| 48 [self argument:[recordedNotification userInfo] matchesArgument:[aNotific
ation userInfo]]; | 59 [self argument:[recordedNotification userInfo] matchesArgument:[aNotific
ation userInfo]]; |
| 49 } | 60 } |
| 50 | 61 |
| 51 - (BOOL)argument:(id)expectedArg matchesArgument:(id)observedArg | 62 - (BOOL)argument:(id)expectedArg matchesArgument:(id)observedArg |
| 52 { | 63 { |
| 53 if([expectedArg isKindOfClass:[OCMConstraint class]]) | 64 if([expectedArg isKindOfClass:[OCMConstraint class]]) |
| 54 { | 65 { |
| 55 » » if([expectedArg evaluate:observedArg] == NO) | 66 » » return [expectedArg evaluate:observedArg]; |
| 56 » » » return NO; | |
| 57 } | 67 } |
| 58 else if([expectedArg conformsToProtocol:objc_getProtocol("HCMatcher")]) | 68 else if([expectedArg conformsToProtocol:objc_getProtocol("HCMatcher")]) |
| 59 { | 69 { |
| 60 » » if([expectedArg matches:observedArg] == NO) | 70 » » return [expectedArg matches:observedArg]; |
| 61 » » » return NO; | 71 » } |
| 72 » else if (expectedArg == observedArg) |
| 73 » { |
| 74 » » return YES; |
| 75 » } |
| 76 » else if (expectedArg == nil || observedArg == nil) |
| 77 » { |
| 78 » » return NO; |
| 62 } | 79 } |
| 63 else | 80 else |
| 64 { | 81 { |
| 65 » » if([expectedArg class] != [observedArg class]) | 82 » » return [expectedArg isEqual:observedArg]; |
| 66 » » » return NO; | |
| 67 » » if(([expectedArg isEqual:observedArg] == NO) && | |
| 68 » » !((expectedArg == nil) && (observedArg == nil))) | |
| 69 » » » return NO; | |
| 70 } | 83 } |
| 71 return YES; | |
| 72 } | 84 } |
| 73 | 85 |
| 74 | 86 |
| 75 @end | 87 @end |
| OLD | NEW |