Skip to content

Commit a06af14

Browse files
committed
Add some helpful operators
1 parent 6837658 commit a06af14

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v15.3.0
2+
3+
- Add `==` operators for `SocketAckStatus` and `String`
4+
15
# v15.2.0
26

37
- Small fixes.

Source/SocketIO/Ack/SocketAckManager.swift

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ public enum SocketAckStatus : String {
3131

3232
/// The ack timed out.
3333
case noAck = "NO ACK"
34+
35+
/// Tests whether a string is equal to a given SocketAckStatus
36+
public static func == (lhs: String, rhs: SocketAckStatus) -> Bool {
37+
return lhs == rhs.rawValue
38+
}
39+
40+
/// Tests whether a string is equal to a given SocketAckStatus
41+
public static func == (lhs: SocketAckStatus, rhs: String) -> Bool {
42+
return rhs == lhs
43+
}
3444
}
3545

3646
private struct SocketAck : Hashable {

Tests/TestSocketIO/SocketAckManagerTest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SocketAckManagerTest : XCTestCase {
3838
return
3939
}
4040

41-
XCTAssertEqual(timeoutReason, SocketAckStatus.noAck.rawValue)
41+
XCTAssert(timeoutReason == SocketAckStatus.noAck)
4242

4343
callbackExpection.fulfill()
4444
}

0 commit comments

Comments
 (0)