From fedb5ae1c4e2be4ecb25158bc54abcab2b965f74 Mon Sep 17 00:00:00 2001 From: Michael Roebuck Date: Thu, 22 May 2025 11:12:01 -0700 Subject: [PATCH 1/3] Build for XCode 16.2; Discovered 2 unit tests were failing due to adding weak references. Added two more unit tests. --- MulticastDelegateDemo/DemoService.swift | 1 + .../MulticastDelegateDemoTests.swift | 29 ++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/MulticastDelegateDemo/DemoService.swift b/MulticastDelegateDemo/DemoService.swift index 61a29a2..381e62a 100644 --- a/MulticastDelegateDemo/DemoService.swift +++ b/MulticastDelegateDemo/DemoService.swift @@ -7,6 +7,7 @@ // import Foundation +import MulticastDelegateDemo protocol DemoServiceDelegate { diff --git a/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift b/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift index f964214..6462b0f 100644 --- a/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift +++ b/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift @@ -291,21 +291,42 @@ class MulticastDelegateDemoTests: XCTestCase { XCTAssertTrue(multicastDelegate.isEmpty) } - func testNotEmptyAfterAdd() { + func testNotEmptyAfterAddtrongReference() { let multicastDelegate = MulticastDelegate() - multicastDelegate += DelegateTestClass() + let delegate1 = DelegateTestClass() + multicastDelegate += delegate1 + + XCTAssertFalse(multicastDelegate.isEmpty) + } + + func testNotEmptyAfterDoubleAddStrongReferences() { + + let multicastDelegate = MulticastDelegate() + let delegate1 = DelegateTestClass() + let delegate2 = DelegateTestClass() + multicastDelegate += delegate1 + multicastDelegate += delegate2 XCTAssertFalse(multicastDelegate.isEmpty) } - func testNotEmptyAfterDoubleAdd() { + // Thank you ARC + Weak References + func testEmptyAfterAddWeakReference() { + + let multicastDelegate = MulticastDelegate() + multicastDelegate += DelegateTestClass() + + XCTAssertTrue(multicastDelegate.isEmpty) + } + + func testEmptyAfterDoubleAddWeakReferences() { let multicastDelegate = MulticastDelegate() multicastDelegate += DelegateTestClass() multicastDelegate += DelegateTestClass() - XCTAssertFalse(multicastDelegate.isEmpty) + XCTAssertTrue(multicastDelegate.isEmpty) } func testEmptyAfterAddAndDelete() { From 6d5aecfa388455b3f2c55189cd1b51ddd0e54aaa Mon Sep 17 00:00:00 2001 From: Michael Roebuck Date: Thu, 22 May 2025 11:15:28 -0700 Subject: [PATCH 2/3] The bot online discovered trailing white space. Removed them. --- .../MulticastDelegateDemoTests.swift | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift b/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift index 6462b0f..7c4f712 100644 --- a/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift +++ b/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift @@ -275,7 +275,7 @@ class MulticastDelegateDemoTests: XCTestCase { XCTAssertTrue(multicastDelegate.containsDelegate(delegate)) } - + func testContainsDelegateNeverAddedDelegateReturnsFalse() { let multicastDelegate = MulticastDelegate() @@ -283,60 +283,60 @@ class MulticastDelegateDemoTests: XCTestCase { XCTAssertFalse(multicastDelegate.containsDelegate(delegate)) } - + func testEmptyAfterCreation() { let multicastDelegate = MulticastDelegate() XCTAssertTrue(multicastDelegate.isEmpty) } - + func testNotEmptyAfterAddtrongReference() { let multicastDelegate = MulticastDelegate() let delegate1 = DelegateTestClass() multicastDelegate += delegate1 - + XCTAssertFalse(multicastDelegate.isEmpty) } - + func testNotEmptyAfterDoubleAddStrongReferences() { - + let multicastDelegate = MulticastDelegate() let delegate1 = DelegateTestClass() let delegate2 = DelegateTestClass() multicastDelegate += delegate1 multicastDelegate += delegate2 - + XCTAssertFalse(multicastDelegate.isEmpty) } - + // Thank you ARC + Weak References func testEmptyAfterAddWeakReference() { - + let multicastDelegate = MulticastDelegate() multicastDelegate += DelegateTestClass() - + XCTAssertTrue(multicastDelegate.isEmpty) } - + func testEmptyAfterDoubleAddWeakReferences() { - + let multicastDelegate = MulticastDelegate() multicastDelegate += DelegateTestClass() multicastDelegate += DelegateTestClass() - + XCTAssertTrue(multicastDelegate.isEmpty) } func testEmptyAfterAddAndDelete() { - + let multicastDelegate = MulticastDelegate() let delegate = DelegateTestClass() multicastDelegate += delegate multicastDelegate -= delegate - + XCTAssertTrue(multicastDelegate.isEmpty) } - + } From eaf29e9d1d1e03754b0466142d544bb753dc18c7 Mon Sep 17 00:00:00 2001 From: Michael Roebuck Date: Wed, 4 Jun 2025 10:44:03 -0700 Subject: [PATCH 3/3] My apologies for the typo on the word 'Strong' in my unit test. --- MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift b/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift index 7c4f712..84c8d9b 100644 --- a/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift +++ b/MulticastDelegateDemoTests/MulticastDelegateDemoTests.swift @@ -291,7 +291,7 @@ class MulticastDelegateDemoTests: XCTestCase { XCTAssertTrue(multicastDelegate.isEmpty) } - func testNotEmptyAfterAddtrongReference() { + func testNotEmptyAfterAddStrongReference() { let multicastDelegate = MulticastDelegate() let delegate1 = DelegateTestClass()