SVGKit_iOS-RetainTests.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // SVGKit_iOS_Tests.m
  3. // SVGKit-iOS Tests
  4. //
  5. // Created by C.W. Betts on 10/13/14.
  6. // Copyright (c) 2014 na. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import <XCTest/XCTest.h>
  10. #import "SVGKit.h"
  11. #if __has_feature(objc_arc)
  12. #error This test file must not be compiled with ARC.
  13. #endif
  14. @interface SVGKit_iOS_RetainTests : XCTestCase
  15. @property (retain) NSBundle *pathsToSVGs;
  16. @end
  17. @implementation SVGKit_iOS_RetainTests
  18. - (void)setUp {
  19. [super setUp];
  20. self.pathsToSVGs = [NSBundle bundleForClass:[self class]];
  21. }
  22. - (void)tearDown {
  23. self.pathsToSVGs = nil;
  24. // Put teardown code here. This method is called after the invocation of each test method in the class.
  25. [super tearDown];
  26. }
  27. - (void)testReleasing {
  28. @try {
  29. @autoreleasepool {
  30. SVGKImage *image = [[SVGKImage alloc] initWithContentsOfFile:[self.pathsToSVGs pathForResource:@"Note" ofType:@"svg"]];
  31. // Release the image
  32. XCTAssertNoThrow([image release]);
  33. }
  34. XCTAssertTrue(YES);
  35. }
  36. @catch (NSException *exception) {
  37. XCTFail(@"Exception Thrown: %@", exception);
  38. }
  39. }
  40. - (void)testReplacing {
  41. @try {
  42. @autoreleasepool {
  43. SVGKImage *image = [[SVGKImage alloc] initWithContentsOfFile:[self.pathsToSVGs pathForResource:@"CurvedDiamond" ofType:@"svg"]];
  44. // Release the image
  45. XCTAssertNoThrow([image release]);
  46. XCTAssertNoThrow(image = [SVGKImage imageWithContentsOfFile:[self.pathsToSVGs pathForResource:@"Lion" ofType:@"svg"]]);
  47. NSLog(@"image description: %@", image.description);
  48. }
  49. XCTAssertTrue(YES);
  50. }
  51. @catch (NSException *exception) {
  52. XCTFail(@"Exception Thrown: %@", exception);
  53. }
  54. }
  55. - (void)testSameFileTwice {
  56. @try {
  57. @autoreleasepool {
  58. SVGKImage *image = [[SVGKImage alloc] initWithContentsOfFile:[self.pathsToSVGs pathForResource:@"Monkey" ofType:@"svg"]];
  59. SVGKImage *image2 = [[SVGKImage alloc] initWithContentsOfFile:[self.pathsToSVGs pathForResource:@"Monkey" ofType:@"svg"]];
  60. // Release the images
  61. [image release];
  62. [image2 release];
  63. }
  64. XCTAssertTrue(YES);
  65. }
  66. @catch (NSException *exception) {
  67. XCTFail(@"Exception Thrown: %@", exception);
  68. }
  69. }
  70. @end