FIRCLSSymbolResolverTests.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2019 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "Crashlytics/Crashlytics/Models/FIRCLSSymbolResolver.h"
  15. #import <XCTest/XCTest.h>
  16. @interface FIRCLSSymbolResolverTests : XCTestCase
  17. @end
  18. @implementation FIRCLSSymbolResolverTests
  19. - (void)setUp {
  20. [super setUp];
  21. }
  22. - (void)tearDown {
  23. [super tearDown];
  24. }
  25. - (NSString*)resourcePath {
  26. #if SWIFT_PACKAGE
  27. NSBundle* bundle = SWIFTPM_MODULE_BUNDLE;
  28. return [bundle.resourcePath stringByAppendingPathComponent:@"Data"];
  29. #else
  30. NSBundle* bundle = [NSBundle bundleForClass:[self class]];
  31. return bundle.resourcePath;
  32. #endif
  33. }
  34. - (NSString*)pathForResource:(NSString*)name {
  35. return [[self resourcePath] stringByAppendingPathComponent:name];
  36. }
  37. - (void)testLoadingBinaryImagesWithInvalidFile {
  38. FIRCLSSymbolResolver* resolver = [[FIRCLSSymbolResolver alloc] init];
  39. XCTAssertFalse([resolver loadBinaryImagesFromFile:nil]);
  40. XCTAssertFalse([resolver loadBinaryImagesFromFile:@""]);
  41. }
  42. - (void)testLoadingBinaryImagesWithNullBaseValue {
  43. FIRCLSSymbolResolver* resolver = [[FIRCLSSymbolResolver alloc] init];
  44. NSString* binaryImagePath =
  45. [self pathForResource:@"binary_images_with_null_base_entry.clsrecord"];
  46. XCTAssert([resolver loadBinaryImagesFromFile:binaryImagePath]);
  47. }
  48. - (void)testLoadingBinaryImagesWithMissingBaseValue {
  49. FIRCLSSymbolResolver* resolver = [[FIRCLSSymbolResolver alloc] init];
  50. NSString* binaryImagePath = [self pathForResource:@"binary_images_missing_base_entry.clsrecord"];
  51. XCTAssert([resolver loadBinaryImagesFromFile:binaryImagePath]);
  52. }
  53. @end