@@ -128,7 +128,14 @@ class TestCodableFirestore: XCTestCase {
128128 XCTAssertEqual ( ( try ? FirestoreEncoder ( ) . encode ( val) ) as NSDictionary ? , [ " value " : val. value] )
129129 XCTAssertEqual ( try ? FirestoreDecoder ( ) . decode ( TopLevelWrapper< DocumentReference> . self , from: [ " value " : val. value] ) , val)
130130 }
131-
131+
132+ func testEncodingTimestamp( ) {
133+ let timestamp = Timestamp ( date: Date ( ) )
134+ let wrapper = TopLevelWrapper ( timestamp)
135+ XCTAssertEqual ( ( try ? FirestoreEncoder ( ) . encode ( wrapper) ) as NSDictionary ? , [ " value " : timestamp] )
136+ XCTAssertEqual ( try ? FirestoreDecoder ( ) . decode ( TopLevelWrapper< Timestamp> . self , from: [ " value " : timestamp] ) , wrapper)
137+ }
138+
132139 private func _testEncodeFailure< T : Encodable > ( of value: T ) {
133140 do {
134141 let _ = try FirestoreEncoder ( ) . encode ( value)
@@ -195,10 +202,29 @@ fileprivate class GeoPoint: NSObject, GeoPointType {
195202 self . longitude = longitude
196203 }
197204
198- static func == ( lhs: Point , rhs: Point ) -> Bool {
199- return lhs. latitude == rhs. latitude && lhs. longitude == rhs. longitude
205+ override func isEqual( _ object: Any ? ) -> Bool {
206+ guard let other = object. flatMap ( { $0 as? GeoPoint } ) else { return false }
207+ return latitude == other. latitude && longitude == other. longitude
200208 }
201209}
202210
203211// MARK: - ReferenceType
204212fileprivate class DocumentReference : NSObject , DocumentReferenceType { }
213+
214+ // MARK: - Timestamp
215+ fileprivate class Timestamp : NSObject , TimestampType {
216+ let date : Date
217+
218+ required init ( date: Date ) {
219+ self . date = date
220+ }
221+
222+ func dateValue( ) -> Date {
223+ return date
224+ }
225+
226+ override func isEqual( _ object: Any ? ) -> Bool {
227+ guard let other = object. flatMap ( { $0 as? Timestamp } ) else { return false }
228+ return date == other. date
229+ }
230+ }
0 commit comments