Advertisement
Guest User

Enums memory XCTestCase Swift

a guest
Mar 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.40 KB | None | 0 0
  1. enum Ugar {
  2.     case foo(Foo)
  3.     case none
  4. }
  5.  
  6. class Foo {
  7.     let title: String
  8.     init(_ title: String) {
  9.         self.title = title
  10.         print("init \(title)")
  11.     }
  12.    
  13.     deinit {
  14.         print("deinit \(title)")
  15.     }
  16. }
  17.  
  18. class UgarTestCase : XCTestCase {
  19.     var bar : Ugar = .none
  20.     var foo : Foo!
  21.     var foo1: Foo?
  22.     var omg: Foo = Foo("property")
  23.    
  24.     override func setUp() {
  25.         super.setUp()
  26.         bar = .foo(Foo("enum"))
  27.         foo = Foo("implicitly unwrapped optional")
  28.         foo1 = Foo("optional")
  29.         omg = Foo("non optional property")
  30.     }
  31.    
  32.     func testUgar() {
  33.        
  34.     }
  35.    
  36.     func testOmg() {
  37.        
  38.     }
  39. }
  40.  
  41.  
  42.  
  43. OUTPUT:
  44.  
  45. init property
  46. init property
  47. Test Suite 'Selected tests' started at 2018-03-21 18:22:31.015
  48. Test Suite 'StickersTests.xctest' started at 2018-03-21 18:22:31.016
  49. Test Suite 'UgarTestCase' started at 2018-03-21 18:22:31.016
  50. Test Case '-[StickersTests.UgarTestCase testOmg]' started.
  51. init enum
  52. init implicitly unwrapped optional
  53. init optional
  54. init non optional property
  55. deinit property
  56. Test Case '-[StickersTests.UgarTestCase testOmg]' passed (0.001 seconds).
  57. Test Case '-[StickersTests.UgarTestCase testUgar]' started.
  58. init enum
  59. init implicitly unwrapped optional
  60. init optional
  61. init non optional property
  62. deinit property
  63. Test Case '-[StickersTests.UgarTestCase testUgar]' passed (0.000 seconds).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement