Skip to content

Commit fb1bb3d

Browse files
committed
make PingResponse Equatable
1 parent 6554761 commit fb1bb3d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Sources/SwiftyPing/SwiftyPing.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ public struct IPv4Address: Equatable {
731731
}
732732

733733
/// Format of IPv4 header
734-
public struct IPHeader {
734+
public struct IPHeader: Equatable {
735735
public var versionAndHeaderLength: UInt8
736736
public var differentiatedServices: UInt8
737737
public var totalLength: UInt16
@@ -770,7 +770,7 @@ public enum ICMPType: UInt8 {
770770
// MARK: - Helpers
771771

772772
/// A struct encapsulating a ping response.
773-
public struct PingResponse {
773+
public struct PingResponse: Equatable {
774774
/// The randomly generated identifier used in the ping header.
775775
public let identifier: UInt16
776776
/// The IP address of the host.
@@ -790,6 +790,17 @@ public struct PingResponse {
790790
public let byteCount: Int?
791791
/// Response IP header.
792792
public let ipHeader: IPHeader?
793+
794+
public static func == (lhs: PingResponse, rhs: PingResponse) -> Bool {
795+
return lhs.identifier == rhs.identifier &&
796+
lhs.ipAddress == rhs.ipAddress &&
797+
lhs.sequenceNumber == rhs.sequenceNumber &&
798+
lhs.trueSequenceNumber == rhs.trueSequenceNumber &&
799+
lhs.duration == rhs.duration &&
800+
lhs.error == rhs.error &&
801+
lhs.byteCount == rhs.byteCount &&
802+
lhs.ipHeader == rhs.ipHeader
803+
}
793804
}
794805
/// A struct encapsulating the results of a ping instance.
795806
public struct PingResult {

0 commit comments

Comments
 (0)