Skip to content

Cleanup imports and isEqual #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 22, 2018
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
4 changes: 2 additions & 2 deletions Firestore/Example/Tests/API/FIRCollectionReferenceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#import <XCTest/XCTest.h>
#import <FirebaseFirestore/FIRCollectionReference.h>

#import "FirebaseFirestore/FIRCollectionReference.h"
#import <XCTest/XCTest.h>

#import "Firestore/Example/Tests/API/FSTAPIHelpers.h"

Expand Down
4 changes: 2 additions & 2 deletions Firestore/Example/Tests/API/FIRDocumentReferenceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#import <XCTest/XCTest.h>
#import <FirebaseFirestore/FIRDocumentReference.h>

#import "FirebaseFirestore/FIRDocumentReference.h"
#import <XCTest/XCTest.h>

#import "Firestore/Example/Tests/API/FSTAPIHelpers.h"

Expand Down
7 changes: 2 additions & 5 deletions Firestore/Example/Tests/API/FIRDocumentSnapshotTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#import <XCTest/XCTest.h>
#import <FirebaseFirestore/FIRDocumentSnapshot.h>

#import "FirebaseFirestore/FIRDocumentSnapshot.h"
#import <XCTest/XCTest.h>

#import "Firestore/Example/Tests/API/FSTAPIHelpers.h"

Expand All @@ -30,11 +30,8 @@ @implementation FIRDocumentSnapshotTests
- (void)testEquals {
FIRDocumentSnapshot *base = FSTTestDocSnapshot(@"rooms/foo", 1, @{ @"a" : @1 }, NO, NO);
FIRDocumentSnapshot *baseDup = FSTTestDocSnapshot(@"rooms/foo", 1, @{ @"a" : @1 }, NO, NO);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
FIRDocumentSnapshot *nilData = FSTTestDocSnapshot(@"rooms/foo", 1, nil, NO, NO);
FIRDocumentSnapshot *nilDataDup = FSTTestDocSnapshot(@"rooms/foo", 1, nil, NO, NO);
#pragma clang diagnostic pop
FIRDocumentSnapshot *differentPath = FSTTestDocSnapshot(@"rooms/bar", 1, @{ @"a" : @1 }, NO, NO);
FIRDocumentSnapshot *differentData = FSTTestDocSnapshot(@"rooms/bar", 1, @{ @"b" : @1 }, NO, NO);
FIRDocumentSnapshot *hasMutations = FSTTestDocSnapshot(@"rooms/bar", 1, @{ @"a" : @1 }, YES, NO);
Expand Down
3 changes: 2 additions & 1 deletion Firestore/Example/Tests/API/FIRFieldPathTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

#import <FirebaseFirestore/FIRFieldPath.h>

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRFieldPath.h"
#import "Firestore/Source/API/FIRFieldPath+Internal.h"
#import "Firestore/Source/Model/FSTPath.h"

Expand Down
4 changes: 1 addition & 3 deletions Firestore/Example/Tests/API/FIRFieldValueTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
* limitations under the License.
*/

@import FirebaseFirestore;
#import <FirebaseFirestore/FIRFieldValue.h>

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRFieldValue.h"

NS_ASSUME_NONNULL_BEGIN

@interface FIRFieldValueTests : XCTestCase
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Example/Tests/API/FIRGeoPointTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#import "FirebaseFirestore/FIRGeoPoint.h"
#import <FirebaseFirestore/FIRGeoPoint.h>

#import <XCTest/XCTest.h>

Expand Down
3 changes: 2 additions & 1 deletion Firestore/Example/Tests/API/FIRQuerySnapshotTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

#import <FirebaseFirestore/FIRQuerySnapshot.h>

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRQuerySnapshot.h"
#import "Firestore/Source/Model/FSTPath.h"

#import "Firestore/Example/Tests/API/FSTAPIHelpers.h"
Expand Down
3 changes: 2 additions & 1 deletion Firestore/Example/Tests/API/FIRQueryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

#import <FirebaseFirestore/FIRQuery.h>

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRQuery.h"
#import "Firestore/Source/API/FIRQuery+Internal.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Model/FSTPath.h"
Expand Down
3 changes: 2 additions & 1 deletion Firestore/Example/Tests/API/FIRSnapshotMetadataTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

#import <FirebaseFirestore/FIRSnapshotMetadata.h>

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRSnapshotMetadata.h"
#import "Firestore/Source/API/FIRSnapshotMetadata+Internal.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down
13 changes: 7 additions & 6 deletions Firestore/Example/Tests/API/FSTAPIHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

#import <Foundation/Foundation.h>

#import "FirebaseFirestore/FIRCollectionReference.h"
#import "FirebaseFirestore/FIRDocumentSnapshot.h"
#import "FirebaseFirestore/FIRFirestore.h"
#import "FirebaseFirestore/FIRQuerySnapshot.h"

#import "Firestore/Example/Tests/Util/FSTHelpers.h"

@class FIRCollectionReference;
@class FIRDocumentReference;
@class FIRDocumentSnapshot;
@class FIRFirestore;
@class FIRQuerySnapshot;

NS_ASSUME_NONNULL_BEGIN

#if __cplusplus
Expand All @@ -35,7 +36,7 @@ FIRFirestore *FSTTestFirestore();
/** A convenience method for creating a doc snapshot for tests. */
FIRDocumentSnapshot *FSTTestDocSnapshot(NSString *path,
FSTTestSnapshotVersion version,
NSDictionary<NSString *, id> *data,
NSDictionary<NSString *, id> *_Nullable data,
BOOL hasMutations,
BOOL fromCache);

Expand Down
8 changes: 5 additions & 3 deletions Firestore/Example/Tests/API/FSTAPIHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

#import "Firestore/Example/Tests/API/FSTAPIHelpers.h"

#import "FirebaseFirestore/FIRDocumentReference.h"
#import "FirebaseFirestore/FIRSnapshotMetadata.h"
#import <FirebaseFirestore/FIRDocumentChange.h>
#import <FirebaseFirestore/FIRDocumentReference.h>
#import <FirebaseFirestore/FIRSnapshotMetadata.h>

#import "Firestore/Source/API/FIRCollectionReference+Internal.h"
#import "Firestore/Source/API/FIRDocumentReference+Internal.h"
#import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h"
Expand Down Expand Up @@ -53,7 +55,7 @@

FIRDocumentSnapshot *FSTTestDocSnapshot(NSString *path,
FSTTestSnapshotVersion version,
NSDictionary<NSString *, id> *data,
NSDictionary<NSString *, id> *_Nullable data,
BOOL hasMutations,
BOOL fromCache) {
FSTDocument *doc = data ? FSTTestDoc(path, version, data, hasMutations) : nil;
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Example/Tests/Model/FSTFieldValueTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#import "Firestore/Source/Model/FSTFieldValue.h"

#import <FirebaseFirestore/FIRGeoPoint.h>
#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRGeoPoint.h"
#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/API/FSTUserDataConverter.h"
#import "Firestore/Source/Core/FSTTimestamp.h"
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Example/Tests/Remote/FSTDatastoreTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#import "FirebaseFirestore/FIRFirestoreErrors.h"
#import "Firestore/Source/Remote/FSTDatastore.h"

#import <FirebaseFirestore/FIRFirestoreErrors.h>
#import <GRPCClient/GRPCCall.h>
#import <XCTest/XCTest.h>

Expand Down
6 changes: 3 additions & 3 deletions Firestore/Example/Tests/Remote/FSTSerializerBetaTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

#import "Firestore/Source/Remote/FSTSerializerBeta.h"

#import <FirebaseFirestore/FIRFieldPath.h>
#import <FirebaseFirestore/FIRFirestoreErrors.h>
#import <FirebaseFirestore/FIRGeoPoint.h>
#import <GRPCClient/GRPCCall.h>
#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRFieldPath.h"
#import "FirebaseFirestore/FIRFirestoreErrors.h"
#import "FirebaseFirestore/FIRGeoPoint.h"
#import "Firestore/Protos/objc/firestore/local/MaybeDocument.pbobjc.h"
#import "Firestore/Protos/objc/firestore/local/Mutation.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Common.pbobjc.h"
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Example/Tests/SpecTests/FSTSpecTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#import "Firestore/Example/Tests/SpecTests/FSTSpecTests.h"

#import <FirebaseFirestore/FIRFirestoreErrors.h>
#import <GRPCClient/GRPCCall.h>

#import "FirebaseFirestore/FIRFirestoreErrors.h"
#import "Firestore/Source/Auth/FSTUser.h"
#import "Firestore/Source/Core/FSTEventManager.h"
#import "Firestore/Source/Core/FSTQuery.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#import "Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h"

#import <FirebaseFirestore/FIRFirestoreErrors.h>
#import <GRPCClient/GRPCCall.h>

#import "FirebaseFirestore/FIRFirestoreErrors.h"
#import "Firestore/Source/Auth/FSTUser.h"
#import "Firestore/Source/Core/FSTEventManager.h"
#import "Firestore/Source/Core/FSTQuery.h"
Expand Down
5 changes: 3 additions & 2 deletions Firestore/Example/Tests/Util/FSTHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

#import "Firestore/Example/Tests/Util/FSTHelpers.h"

#import "FirebaseFirestore/FIRFieldPath.h"
#import "FirebaseFirestore/FIRGeoPoint.h"
#import <FirebaseFirestore/FIRFieldPath.h>
#import <FirebaseFirestore/FIRGeoPoint.h>

#import "Firestore/Source/API/FIRFieldPath+Internal.h"
#import "Firestore/Source/API/FSTUserDataConverter.h"
#import "Firestore/Source/Core/FSTQuery.h"
Expand Down
5 changes: 1 addition & 4 deletions Firestore/Source/API/FIRCollectionReference.mm
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ - (BOOL)isEqual:(nullable id)other {
- (BOOL)isEqualToReference:(nullable FIRCollectionReference *)reference {
if (self == reference) return YES;
if (reference == nil) return NO;
if (self.firestore != reference.firestore && ![self.firestore isEqual:reference.firestore])
return NO;
if (self.query != reference.query && ![self.query isEqual:reference.query]) return NO;
return YES;
return [self.firestore isEqual:reference.firestore] && [self.query isEqual:reference.query];
}

- (NSUInteger)hash {
Expand Down
1 change: 1 addition & 0 deletions Firestore/Source/API/FIRDocumentChange+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#import "FIRDocumentChange.h"

@class FIRFirestore;
@class FSTViewSnapshot;

NS_ASSUME_NONNULL_BEGIN
Expand Down
5 changes: 1 addition & 4 deletions Firestore/Source/API/FIRDocumentReference.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ - (BOOL)isEqual:(nullable id)other {
- (BOOL)isEqualToReference:(nullable FIRDocumentReference *)reference {
if (self == reference) return YES;
if (reference == nil) return NO;
if (self.firestore != reference.firestore && ![self.firestore isEqual:reference.firestore])
return NO;
if (self.key != reference.key && ![self.key isEqualToKey:reference.key]) return NO;
return YES;
return [self.firestore isEqual:reference.firestore] && [self.key isEqualToKey:reference.key];
}

- (NSUInteger)hash {
Expand Down
15 changes: 6 additions & 9 deletions Firestore/Source/API/FIRDocumentSnapshot.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,12 @@ - (BOOL)isEqual:(nullable id)other {
- (BOOL)isEqualToSnapshot:(nullable FIRDocumentSnapshot *)snapshot {
if (self == snapshot) return YES;
if (snapshot == nil) return NO;
if (self.firestore != snapshot.firestore && ![self.firestore isEqual:snapshot.firestore])
return NO;
if (self.internalKey != snapshot.internalKey && ![self.internalKey isEqual:snapshot.internalKey])
return NO;
if (self.internalDocument != snapshot.internalDocument &&
![self.internalDocument isEqual:snapshot.internalDocument])
return NO;
if (self.fromCache != snapshot.fromCache) return NO;
return YES;

return [self.firestore isEqual:snapshot.firestore] &&
[self.internalKey isEqual:snapshot.internalKey] &&
(self.internalDocument == snapshot.internalDocument ||
[self.internalDocument isEqual:snapshot.internalDocument]) &&
self.fromCache == snapshot.fromCache;
}

- (NSUInteger)hash {
Expand Down
5 changes: 2 additions & 3 deletions Firestore/Source/API/FIRQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ - (BOOL)isEqual:(nullable id)other {
- (BOOL)isEqualToQuery:(nullable FIRQuery *)query {
if (self == query) return YES;
if (query == nil) return NO;
if (self.firestore != query.firestore && ![self.firestore isEqual:query.firestore]) return NO;
if (self.query != query.query && ![self.query isEqual:query.query]) return NO;
return YES;

return [self.firestore isEqual:query.firestore] && [self.query isEqual:query.query];
}

- (NSUInteger)hash {
Expand Down
12 changes: 4 additions & 8 deletions Firestore/Source/API/FIRQuerySnapshot.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ - (BOOL)isEqual:(nullable id)other {
- (BOOL)isEqualToSnapshot:(nullable FIRQuerySnapshot *)snapshot {
if (self == snapshot) return YES;
if (snapshot == nil) return NO;
if (self.firestore != snapshot.firestore && ![self.firestore isEqual:snapshot.firestore])
return NO;
if (self.originalQuery != snapshot.originalQuery &&
![self.originalQuery isEqual:snapshot.originalQuery])
return NO;
if (self.snapshot != snapshot.snapshot && ![self.snapshot isEqual:snapshot.snapshot]) return NO;
if (self.metadata != snapshot.metadata && ![self.metadata isEqual:snapshot.metadata]) return NO;
return YES;

return [self.firestore isEqual:snapshot.firestore] &&
[self.originalQuery isEqual:snapshot.originalQuery] &&
[self.snapshot isEqual:snapshot.snapshot] && [self.metadata isEqual:snapshot.metadata];
}

- (NSUInteger)hash {
Expand Down
3 changes: 1 addition & 2 deletions Firestore/Source/API/FIRSetOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ - (BOOL)isEqual:(id)other {
}

FIRSetOptions *otherOptions = (FIRSetOptions *)other;

return otherOptions.merge != self.merge;
return otherOptions.merge == self.merge;
}

- (NSUInteger)hash {
Expand Down
5 changes: 2 additions & 3 deletions Firestore/Source/API/FIRSnapshotMetadata.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ - (BOOL)isEqual:(nullable id)other {
- (BOOL)isEqualToMetadata:(nullable FIRSnapshotMetadata *)metadata {
if (self == metadata) return YES;
if (metadata == nil) return NO;
if (self.pendingWrites != metadata.pendingWrites) return NO;
if (self.fromCache != metadata.fromCache) return NO;
return YES;

return self.pendingWrites == metadata.pendingWrites && self.fromCache == metadata.fromCache;
}

- (NSUInteger)hash {
Expand Down