summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLTestAssertionHandler.m
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-09-18 18:13:07 -0400
committerGitHub <noreply@github.com>2019-09-18 18:13:07 -0400
commit2b08c1d7bf9e867d6450feb6a246ce36dcdf2cd3 (patch)
tree8041d2169d2c26041c004c3336de08d031a3f9e8 /platform/darwin/test/MGLTestAssertionHandler.m
parent7bca176beaf4dcae2263eeabee82fd7b6412654b (diff)
downloadqtlocation-mapboxgl-2b08c1d7bf9e867d6450feb6a246ce36dcdf2cd3.tar.gz
[ios, macos] Fix MGLOfflinePack invalidate crash (#15582)
Diffstat (limited to 'platform/darwin/test/MGLTestAssertionHandler.m')
-rw-r--r--platform/darwin/test/MGLTestAssertionHandler.m77
1 files changed, 77 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLTestAssertionHandler.m b/platform/darwin/test/MGLTestAssertionHandler.m
new file mode 100644
index 0000000000..4b504427b5
--- /dev/null
+++ b/platform/darwin/test/MGLTestAssertionHandler.m
@@ -0,0 +1,77 @@
+#import "MGLTestAssertionHandler.h"
+
+@implementation MGLTestAssertionHandler
+
+- (instancetype)initWithTestCase:(XCTestCase *)testCase {
+ if ((self = [super init])) {
+ _testCase = testCase;
+ }
+ return self;
+}
+
+- (void)handleFailureInMethod:(SEL)selector
+ object:(id)object
+ file:(NSString *)fileName
+ lineNumber:(NSInteger)line
+ description:(NSString *)format, ...
+{
+ va_list args;
+ va_start(args, format);
+ NSString *description = [[NSString alloc] initWithFormat:format arguments:args];
+ va_end(args);
+
+ NSString *condition = [NSString stringWithFormat:
+ @"`[%@ %@]`",
+ object, NSStringFromSelector(selector)
+ ];
+
+ if (self.testCase && self.shouldFail) {
+ _XCTPreformattedFailureHandler(self.testCase,
+ YES,
+ fileName,
+ line,
+ condition,
+ description
+ );
+ }
+ else {
+ NSLog(@"Assertion Failure: %@:%lu: %@ - %@",
+ fileName,
+ line,
+ condition,
+ description);
+ }
+}
+
+- (void)handleFailureInFunction:(NSString *)functionName
+ file:(NSString *)fileName
+ lineNumber:(NSInteger)line
+ description:(NSString *)format, ...
+{
+ va_list args;
+ va_start(args, format);
+ NSString *description = [[NSString alloc] initWithFormat:format arguments:args];
+ va_end(args);
+
+ NSString *condition = [NSString stringWithFormat:
+ @"`%@`",
+ functionName];
+
+ if (self.testCase && self.shouldFail) {
+ _XCTPreformattedFailureHandler(self.testCase,
+ YES,
+ fileName,
+ line,
+ condition,
+ description);
+ }
+ else {
+ NSLog(@"Assertion Failure: %@:%lu: %@ - %@",
+ fileName,
+ line,
+ condition,
+ description);
+ }
+}
+@end
+