Skip to content

Commit 0bd6508

Browse files
committed
Made some small refactorings.
1 parent 863d7b3 commit 0bd6508

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

Source/OCMock/NSInvocation+OCMAdditions.m

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ static BOOL OCMObjectIsClass(id object) {
3030
#define object_isClass OCMObjectIsClass
3131
#endif
3232

33+
static NSString *const OCMArgAnyPointerDescription = @"<[OCMArg anyPointer]>";
34+
3335

3436
@implementation NSInvocation(OCMAdditions)
3537

@@ -331,6 +333,7 @@ - (id)getArgumentAtIndexAsObject:(NSInteger)argIndex
331333
return nil;
332334
}
333335

336+
334337
- (NSString *)invocationDescription
335338
{
336339
NSMethodSignature *methodSignature = [self methodSignature];
@@ -351,11 +354,6 @@ - (NSString *)invocationDescription
351354
return [description autorelease];
352355
}
353356

354-
- (NSString *)anyPointerDescription
355-
{
356-
return @"<Any Pointer>";
357-
}
358-
359357
- (NSString *)argumentDescriptionAtIndex:(NSInteger)argIndex
360358
{
361359
const char *argType = OCMTypeWithoutQualifiers([[self methodSignature] getArgumentTypeAtIndex:(NSUInteger)argIndex]);
@@ -386,7 +384,6 @@ - (NSString *)argumentDescriptionAtIndex:(NSInteger)argIndex
386384

387385
}
388386

389-
390387
- (NSString *)objectDescriptionAtIndex:(NSInteger)anInt
391388
{
392389
id object;
@@ -529,24 +526,22 @@ - (NSString *)pointerDescriptionAtIndex:(NSInteger)anInt
529526
void *buffer;
530527

531528
[self getArgument:&buffer atIndex:anInt];
532-
if(buffer == [OCMArg anyPointer])
533-
{
534-
return [self anyPointerDescription];
535-
}
536-
else
537-
{
538-
return [NSString stringWithFormat:@"%p", buffer];
539-
}
529+
530+
if(buffer == [OCMArg anyPointer])
531+
return OCMArgAnyPointerDescription;
532+
else
533+
return [NSString stringWithFormat:@"%p", buffer];
540534
}
541535

542536
- (NSString *)cStringDescriptionAtIndex:(NSInteger)anInt
543537
{
544538
char *cStringPtr;
545539

546540
[self getArgument:&cStringPtr atIndex:anInt];
541+
547542
if(cStringPtr == [OCMArg anyPointer])
548543
{
549-
return [self anyPointerDescription];
544+
return OCMArgAnyPointerDescription;
550545
}
551546
else
552547
{

Source/OCMockTests/NSInvocationOCMAdditionsTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ - (void)testInvocationDescriptionWithCStringArgumentAnyPointer
277277
const char *cString = [OCMArg anyPointer];
278278
[invocation setArgument:&cString atIndex:2];
279279

280-
XCTAssertEqualObjects(@"initWithUTF8String:<Any Pointer>", [invocation invocationDescription]);
280+
XCTAssertEqualObjects(@"initWithUTF8String:<[OCMArg anyPointer]>", [invocation invocationDescription]);
281281
}
282282

283283
- (void)testInvocationDescriptionWithSelectorArgument
@@ -314,7 +314,7 @@ - (void)testInvocationDescriptionWithPointerArgumentAnyPointer
314314
[invocation setArgument:&bytes atIndex:2];
315315
[invocation setArgument:&length atIndex:3];
316316

317-
NSString *expected = [NSString stringWithFormat:@"initWithBytes:<Any Pointer> length:%lu", (unsigned long)length];
317+
NSString *expected = [NSString stringWithFormat:@"initWithBytes:<[OCMArg anyPointer]> length:%lu", (unsigned long)length];
318318
NSString *invocationDescription = [invocation invocationDescription];
319319
XCTAssertEqualObjects(expected, invocationDescription);
320320
}

0 commit comments

Comments
 (0)