forked from preemptive/PPiOS-Rename
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCDSymbolsMapperSpec.m
69 lines (52 loc) · 2.59 KB
/
CDSymbolsMapperSpec.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
/********************************************
Copyright 2016 PreEmptive Solutions, LLC
See LICENSE.txt for licensing information
********************************************/
#import <Kiwi/Kiwi.h>
#import "CDSymbolMapper.h"
SPEC_BEGIN(CDSymbolMapperSpec)
describe(@"CDSymbolMapper", ^{
__block CDSymbolMapper *mapper;
beforeEach(^{
mapper = [[CDSymbolMapper alloc] init];
});
describe(@"processing crash dump", ^{
NSString *className = @"TestClass";
NSString *obfuscatedClass = @"abc";
NSString *methodName = @"initWithSomething";
NSString *obfusctedMethodName = @"cde";
NSString *unknownMethod = @"count";
NSString *otherClassName = @"TestClass2";
NSString *otherObfuscatedClass = @"abcd";
NSString *otherMethodName = @"initWithSomethingElse";
NSString *otherObfuscatedMethodName = @"cde2";
NSString *crashDump = [NSString stringWithFormat:@"-[%@ %@:%@:]\n-[%@ %@:]", obfuscatedClass, obfusctedMethodName, unknownMethod, otherObfuscatedClass, otherObfuscatedMethodName];
NSString *realName = [NSString stringWithFormat:@"-[%@ %@:%@:]\n-[%@ %@:]", className, methodName, unknownMethod, otherClassName, otherMethodName];
NSDictionary *symbols = @{
obfuscatedClass : className,
obfusctedMethodName : methodName,
otherObfuscatedClass : otherClassName,
otherObfuscatedMethodName : otherMethodName
};
it(@"should replace known symbols", ^{
NSString *result = [mapper processCrashDump:crashDump withSymbols:symbols];
[[result shouldNot] beNil];
NSUInteger classLocation = [result rangeOfString:className].location;
[[theValue(classLocation) shouldNot] equal:theValue(NSNotFound)];
NSUInteger methodLocation = [result rangeOfString:methodName].location;
[[theValue(methodLocation) shouldNot] equal:theValue(NSNotFound)];
});
it(@"should not replace unknown symbols", ^{
NSString *result = [mapper processCrashDump:crashDump withSymbols:symbols];
[[result shouldNot] beNil];
NSUInteger classLocation = [result rangeOfString:unknownMethod].location;
[[theValue(classLocation) shouldNot] equal:theValue(NSNotFound)];
});
it(@"should replace all symbols according to the map", ^{
NSString *result = [mapper processCrashDump:crashDump withSymbols:symbols];
[[result shouldNot] beNil];
[[result should] equal:realName];
});
});
});
SPEC_END