FIRStackFrameTests.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2020 Google LLC
  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 <XCTest/XCTest.h>
  15. #import "Crashlytics/Crashlytics/Private/FIRStackFrame_Private.h"
  16. @interface FIRStackFrameTests : XCTestCase
  17. @end
  18. @implementation FIRStackFrameTests
  19. - (void)testBasicSymbolicatedCheck {
  20. FIRStackFrame *stackFrame = [FIRStackFrame stackFrameWithSymbol:@"SYMBOL"
  21. file:@"FILE"
  22. line:54321];
  23. XCTAssertEqualObjects(stackFrame.symbol, @"SYMBOL");
  24. XCTAssertEqualObjects(stackFrame.fileName, @"FILE");
  25. XCTAssertEqual(stackFrame.lineNumber, 54321);
  26. }
  27. - (void)testOwnership {
  28. NSString *symbol = @"SYMBOL";
  29. NSString *file = @"FILE";
  30. FIRStackFrame *stackFrame = [FIRStackFrame stackFrameWithSymbol:symbol file:file line:54321];
  31. symbol = @"NEW_SYMBOL";
  32. file = nil;
  33. XCTAssertEqualObjects(stackFrame.symbol, @"SYMBOL");
  34. XCTAssertEqualObjects(stackFrame.fileName, @"FILE");
  35. XCTAssertEqual(stackFrame.lineNumber, 54321);
  36. }
  37. - (void)testIntUIntConversion {
  38. FIRStackFrame *stackFrame = [FIRStackFrame stackFrameWithSymbol:@"SYMBOL" file:@"FILE" line:100];
  39. XCTAssertEqual(stackFrame.lineNumber, 100);
  40. FIRStackFrame *stackFrame2 = [FIRStackFrame stackFrameWithSymbol:@"SYMBOL"
  41. file:@"FILE"
  42. line:-100];
  43. XCTAssertEqual(stackFrame2.lineNumber, 4294967196);
  44. }
  45. - (void)testDescription {
  46. FIRStackFrame *stackFrame = [FIRStackFrame stackFrameWithSymbol:@"FIRStackFrameTests"
  47. file:@"testDescription"
  48. line:35];
  49. XCTAssertEqualObjects([stackFrame description], @"{testDescription - FIRStackFrameTests:35}");
  50. }
  51. @end