Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions Sources/MongoSwift/BSON/BSONValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ public struct BSONNull: BSONValue, Codable, Equatable {
throw bsonTooLargeError(value: self, forKey: key)
}
}

public static func == (lhs: BSONNull, rhs: BSONNull) -> Bool {
return true
}
}

/// A struct to represent the BSON Binary type.
Expand Down Expand Up @@ -285,10 +281,6 @@ public struct Binary: BSONValue, Equatable, Codable {
let dataObj = Data(bytes: data, count: Int(length))
return try self.init(data: dataObj, subtype: UInt8(subtype.rawValue))
}

public static func == (lhs: Binary, rhs: Binary) -> Bool {
return lhs.data == rhs.data && lhs.subtype == rhs.subtype
}
}

/// An extension of `Bool` to represent the BSON Boolean type.
Expand Down Expand Up @@ -391,10 +383,6 @@ public struct DBPointer: BSONValue, Codable, Equatable {

return DBPointer(ref: String(cString: collectionP), id: ObjectId(fromPointer: oidP))
}

public static func == (lhs: DBPointer, rhs: DBPointer) -> Bool {
return lhs.ref == rhs.ref && lhs.id == rhs.id
}
}

/// A struct to represent the BSON Decimal128 type.
Expand Down Expand Up @@ -620,10 +608,6 @@ public struct CodeWithScope: BSONValue, Equatable, Codable {

return self.init(code: code, scope: scopeDoc)
}

public static func == (lhs: CodeWithScope, rhs: CodeWithScope) -> Bool {
return lhs.code == rhs.code && lhs.scope == rhs.scope
}
}

/// A struct to represent the BSON MaxKey type.
Expand Down Expand Up @@ -655,8 +639,6 @@ public struct MaxKey: BSONValue, Equatable, Codable {
}
return MaxKey()
}

public static func == (lhs: MaxKey, rhs: MaxKey) -> Bool { return true }
}

/// A struct to represent the BSON MinKey type.
Expand Down Expand Up @@ -688,8 +670,6 @@ public struct MinKey: BSONValue, Equatable, Codable {
}
return MinKey()
}

public static func == (lhs: MinKey, rhs: MinKey) -> Bool { return true }
}

/// A struct to represent the BSON ObjectId type.
Expand Down Expand Up @@ -904,11 +884,6 @@ public struct RegularExpression: BSONValue, Equatable, Codable {

return self.init(pattern: patternString, options: optionsString)
}

/// Returns `true` if the two `RegularExpression`s have matching patterns and options, and `false` otherwise.
public static func == (lhs: RegularExpression, rhs: RegularExpression) -> Bool {
return lhs.pattern == rhs.pattern && lhs.options == rhs.options
}
}

/// An extension of String to represent the BSON string type.
Expand Down Expand Up @@ -991,10 +966,6 @@ public struct Symbol: BSONValue, CustomStringConvertible, Codable, Equatable {

return Symbol(strValue)
}

public static func == (lhs: Symbol, rhs: Symbol) -> Bool {
return lhs.stringValue == rhs.stringValue
}
}

/// A struct to represent the BSON Timestamp type.
Expand Down Expand Up @@ -1044,10 +1015,6 @@ public struct Timestamp: BSONValue, Equatable, Codable {

return self.init(timestamp: t, inc: i)
}

public static func == (lhs: Timestamp, rhs: Timestamp) -> Bool {
return lhs.timestamp == rhs.timestamp && lhs.increment == rhs.increment
}
}

/// A struct to represent the deprecated Undefined type.
Expand Down Expand Up @@ -1077,10 +1044,6 @@ public struct BSONUndefined: BSONValue, Equatable, Codable {
}
return BSONUndefined()
}

public static func == (lhs: BSONUndefined, rhs: BSONUndefined) -> Bool {
return true
}
}

// See https://github.com/realm/SwiftLint/issues/461
Expand Down
5 changes: 0 additions & 5 deletions Sources/MongoSwift/SDAM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public struct ConnectionId: Equatable {
// swiftlint:disable:next force_unwrapping - should be valid UInt16 unless server response malformed.
self.port = UInt16(parts[1])!
}

/// ConnectionIds are equal if their hosts and ports match.
public static func == (lhs: ConnectionId, rhs: ConnectionId) -> Bool {
return lhs.host == rhs.host && rhs.port == lhs.port
}
}

/// A struct describing a mongod or mongos process.
Expand Down
13 changes: 0 additions & 13 deletions Sources/MongoSwift/WriteConcern.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,6 @@ public class WriteConcern: Codable {
try container.encode("majority")
}
}

public static func == (lhs: W, rhs: W) -> Bool {
switch (lhs, rhs) {
case let (.number(lNum), .number(rNum)):
return lNum == rNum
case let (.tag(lTag), .tag(rTag)):
return lTag == rTag
case (.majority, .majority):
return true
default:
return false
}
}
}

/// Indicates the `W` value for this `WriteConcern`.
Expand Down
42 changes: 0 additions & 42 deletions Tests/MongoSwiftTests/CodecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,19 @@ final class CodecTests: MongoSwiftTestCase {
struct BasicStruct: Codable, Equatable {
let int: Int
let string: String

public static func == (lhs: BasicStruct, rhs: BasicStruct) -> Bool {
return lhs.int == rhs.int && lhs.string == rhs.string
}
}

struct NestedStruct: Codable, Equatable {
let s1: BasicStruct
let s2: BasicStruct

public static func == (lhs: NestedStruct, rhs: NestedStruct) -> Bool {
return lhs.s1 == rhs.s1 && lhs.s2 == rhs.s2
}
}

struct NestedArray: Codable, Equatable {
let array: [BasicStruct]

public static func == (lhs: NestedArray, rhs: NestedArray) -> Bool {
return lhs.array == rhs.array
}
}

struct NestedNestedStruct: Codable, Equatable {
let s: NestedStruct

public static func == (lhs: NestedNestedStruct, rhs: NestedNestedStruct) -> Bool {
return lhs.s == rhs.s
}
}

/// Test encoding/decoding a variety of structs containing simple types that have
Expand Down Expand Up @@ -111,10 +95,6 @@ final class CodecTests: MongoSwiftTestCase {
let int: Int?
let bool: Bool?
let string: String

public static func == (lhs: OptionalsStruct, rhs: OptionalsStruct) -> Bool {
return lhs.int == rhs.int && lhs.bool == rhs.bool && lhs.string == rhs.string
}
}

/// Test encoding/decoding a struct containing optional values.
Expand Down Expand Up @@ -149,13 +129,6 @@ final class CodecTests: MongoSwiftTestCase {

static let keys = ["int8", "int16", "uint8", "uint16", "uint32", "uint64", "uint", "float"]

public static func == (lhs: Numbers, rhs: Numbers) -> Bool {
return lhs.int8 == rhs.int8 && lhs.int16 == rhs.int16 &&
lhs.uint8 == rhs.uint8 && lhs.uint16 == rhs.uint16 &&
lhs.uint32 == rhs.uint32 && lhs.uint64 == rhs.uint64 &&
lhs.uint == rhs.uint && lhs.float == rhs.float
}

init(int8: Int8? = nil,
int16: Int16? = nil,
uint8: UInt8? = nil,
Expand Down Expand Up @@ -265,11 +238,6 @@ final class CodecTests: MongoSwiftTestCase {
let int32: Int32
let int64: Int64
let double: Double

public static func == (lhs: BSONNumbers, rhs: BSONNumbers) -> Bool {
return lhs.int == rhs.int && lhs.int32 == rhs.int32 &&
lhs.int64 == rhs.int64 && lhs.double == rhs.double
}
}

/// Test that BSON number types are encoded properly, and can be decoded from any type they are stored as
Expand Down Expand Up @@ -321,16 +289,6 @@ final class CodecTests: MongoSwiftTestCase {
let dbpointer: DBPointer
let null: BSONNull

public static func == (lhs: AllBSONTypes, rhs: AllBSONTypes) -> Bool {
return lhs.double == rhs.double && lhs.string == rhs.string &&
lhs.doc == rhs.doc && lhs.arr == rhs.arr && lhs.binary == rhs.binary &&
lhs.oid == rhs.oid && lhs.bool == rhs.bool && lhs.code == rhs.code &&
lhs.int == rhs.int && lhs.ts == rhs.ts && lhs.int32 == rhs.int32 &&
lhs.int64 == rhs.int64 && lhs.dec == rhs.dec && lhs.minkey == rhs.minkey &&
lhs.maxkey == rhs.maxkey && lhs.regex == rhs.regex && lhs.date == rhs.date &&
lhs.symbol == rhs.symbol && lhs.dbpointer == rhs.dbpointer && lhs.null == rhs.null
}

public static func factory() throws -> AllBSONTypes {
return AllBSONTypes(
double: Double(2),
Expand Down
4 changes: 0 additions & 4 deletions Tests/MongoSwiftTests/MongoCollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,6 @@ final class MongoCollectionTests: MongoSwiftTestCase {
struct Basic: Codable, Equatable {
let x: Int
let y: String

static func == (lhs: Basic, rhs: Basic) -> Bool {
return lhs.x == rhs.x && lhs.y == rhs.y
}
}

func testCodableCollection() throws {
Expand Down
6 changes: 0 additions & 6 deletions Tests/MongoSwiftTests/TestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ extension MongoClient {
self.patch = patch ?? 0
}

static func == (lhs: ServerVersion, rhs: ServerVersion) -> Bool {
return lhs.major == rhs.major &&
lhs.minor == rhs.minor &&
lhs.patch == rhs.patch
}

func isLessThan(_ version: ServerVersion) -> Bool {
if self.major == version.major {
if self.minor == version.minor {
Expand Down