forked from Naville/class-dump-utf8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestBlockSignature.m
79 lines (67 loc) · 2.81 KB
/
TestBlockSignature.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// -*- mode: ObjC -*-
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-2019 Steve Nygard.
#import <XCTest/XCTest.h>
#import "CDType.h"
#import "CDTypeName.h"
@interface CDType (UnitTests)
- (NSString *)blockSignatureString;
@end
@interface TestBlockSignature : XCTestCase
@end
@implementation TestBlockSignature
- (void)testZeroArguments;
{
NSMutableArray *types = [NSMutableArray new];
[types addObject:[[CDType alloc] initSimpleType:'v']];
[types addObject:[[CDType alloc] initBlockTypeWithTypes:nil]];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
XCTAssertEqualObjects(blockSignatureString, @"void (^)(void)", @"");
}
- (void)testOneArgument;
{
NSMutableArray *types = [NSMutableArray new];
[types addObject:[[CDType alloc] initSimpleType:'v']];
[types addObject:[[CDType alloc] initBlockTypeWithTypes:nil]];
CDTypeName *typeName = [CDTypeName new];
typeName.name = @"NSData";
[types addObject:[[CDType alloc] initIDType:typeName]];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
XCTAssertEqualObjects(blockSignatureString, @"void (^)(NSData *)", @"");
}
- (void)testTwoArguments;
{
NSMutableArray *types = [NSMutableArray new];
[types addObject:[[CDType alloc] initSimpleType:'v']];
[types addObject:[[CDType alloc] initBlockTypeWithTypes:nil]];
[types addObject:[[CDType alloc] initIDType:nil]];
CDTypeName *typeName = [CDTypeName new];
typeName.name = @"NSError";
[types addObject:[[CDType alloc] initIDType:typeName]];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
XCTAssertEqualObjects(blockSignatureString, @"void (^)(id, NSError *)", @"");
}
- (void)testBlockArgument;
{
NSMutableArray *types = [NSMutableArray new];
[types addObject:[[CDType alloc] initSimpleType:'v']];
[types addObject:[[CDType alloc] initBlockTypeWithTypes:nil]];
[types addObject:[[CDType alloc] initBlockTypeWithTypes:[types copy]]];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
XCTAssertEqualObjects(blockSignatureString, @"void (^)(void (^)(void))", @"");
}
- (void)testBOOLArgument;
{
NSMutableArray *types = [NSMutableArray new];
[types addObject:[[CDType alloc] initSimpleType:'v']];
[types addObject:[[CDType alloc] initBlockTypeWithTypes:nil]];
[types addObject:[[CDType alloc] initSimpleType:'c']];
CDType *blockType = [[CDType alloc] initBlockTypeWithTypes:types];
NSString *blockSignatureString = [blockType blockSignatureString];
XCTAssertEqualObjects(blockSignatureString, @"void (^)(BOOL)", @"");
}
@end