Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
26095ec
add bone code for new isEqual and unit test for old isEqual
zxu123 Dec 12, 2017
0686f88
Implement isEqual for FIRCollectionReference
zxu123 Dec 14, 2017
a3f3771
implement isEqual for FIRSnapshotMetadata
zxu123 Dec 14, 2017
9b02f22
Implement isEqual for FIRDocumentSnapshot
zxu123 Dec 14, 2017
d40c4c1
Implement isEqual for FIRQuerySnapshot
zxu123 Dec 14, 2017
ea5fdd7
(un)implement `isEqual` for `FIRFieldValue`
zxu123 Dec 14, 2017
0c73729
fix style with `scripts/style.sh`
zxu123 Dec 14, 2017
4e77490
Implement hash for those with overridden isEqual without hash yet.
zxu123 Dec 15, 2017
9a0117a
refactor to use test helper functions -- FSTTestFirestore, FSTTestPat…
zxu123 Dec 15, 2017
09b3804
refactor using test helper `FSTTestDocSnapshot`, `FSTTestFieldPath`, …
zxu123 Dec 15, 2017
ed88900
refactoring to use test helper method `FSTTestQuerySnapshot`,
zxu123 Dec 15, 2017
e4e3903
remove unneccessary nil-check, check isKindOfClass instead of isEqual
zxu123 Dec 15, 2017
f734f10
refactoring: adding `FSTAPIHelpers.{h,m}`, `FSTTest{Collection,Docume…
zxu123 Dec 18, 2017
73f4c55
a file forgot in last commit
zxu123 Dec 18, 2017
0df38d8
mainly clean up import and some minor refactoring
zxu123 Dec 19, 2017
a2fc4a0
fix style via style.sh
zxu123 Dec 19, 2017
5714e7d
minor style fix
zxu123 Dec 19, 2017
5f20358
Merge branch 'firestore-api-changes' into zxu/isEqual
zxu123 Dec 19, 2017
3fbd94d
add pragma ignored -Wnonnull
zxu123 Dec 19, 2017
a6d6bbc
Merge branch 'zxu/isEqual' of https://github.com/firebase/firebase-io…
zxu123 Dec 19, 2017
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
34 changes: 34 additions & 0 deletions Firestore/Example/Firestore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@
6ED54761B845349D43DB6B78 /* Pods_Firestore_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75A6FE51C1A02DF38F62FAAD /* Pods_Firestore_Example.framework */; };
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; };
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
AB382F7C1FE02A1F007CA955 /* FIRDocumentReferenceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB382F7B1FE02A1F007CA955 /* FIRDocumentReferenceTests.m */; };
AB382F7E1FE03059007CA955 /* FIRFieldPathTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB382F7D1FE03059007CA955 /* FIRFieldPathTests.m */; };
AB9945261FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB9945251FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m */; };
AB9945281FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB9945271FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m */; };
AB99452A1FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB9945291FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m */; };
AB99452C1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB99452B1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m */; };
AB99452E1FE30AC800DFC1E6 /* FIRFieldValueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AB99452D1FE30AC800DFC1E6 /* FIRFieldValueTests.m */; };
ABAEEF4F1FD5F8B100C966CB /* FIRQueryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = ABAEEF4E1FD5F8B100C966CB /* FIRQueryTests.m */; };
ABF341051FE860CA00C48322 /* FSTAPIHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = ABF341021FE8593500C48322 /* FSTAPIHelpers.m */; };
AFE6114F0D4DAECBA7B7C089 /* Pods_Firestore_IntegrationTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2FA635DF5D116A67A7441CD /* Pods_Firestore_IntegrationTests.framework */; };
C4E749275AD0FBDF9F4716A8 /* Pods_SwiftBuildTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32AD40BF6B0E849B07FFD05E /* Pods_SwiftBuildTest.framework */; };
D5B2532E4676014F57A7EAB9 /* FSTStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5B25C0D4AADFCA3ADB883E4 /* FSTStreamTests.m */; };
Expand Down Expand Up @@ -231,7 +239,16 @@
8E002F4AD5D9B6197C940847 /* Firestore.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Firestore.podspec; path = ../Firestore.podspec; sourceTree = "<group>"; };
9D52E67EE96AA7E5D6F69748 /* Pods-Firestore_IntegrationTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_IntegrationTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_IntegrationTests/Pods-Firestore_IntegrationTests.debug.xcconfig"; sourceTree = "<group>"; };
9EF477AD4B2B643FD320867A /* Pods-Firestore_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example/Pods-Firestore_Example.debug.xcconfig"; sourceTree = "<group>"; };
AB382F7B1FE02A1F007CA955 /* FIRDocumentReferenceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRDocumentReferenceTests.m; sourceTree = "<group>"; };
AB382F7D1FE03059007CA955 /* FIRFieldPathTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRFieldPathTests.m; sourceTree = "<group>"; };
AB9945251FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRCollectionReferenceTests.m; sourceTree = "<group>"; };
AB9945271FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRSnapshotMetadataTests.m; sourceTree = "<group>"; };
AB9945291FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRDocumentSnapshotTests.m; sourceTree = "<group>"; };
AB99452B1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRQuerySnapshotTests.m; sourceTree = "<group>"; };
AB99452D1FE30AC800DFC1E6 /* FIRFieldValueTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRFieldValueTests.m; sourceTree = "<group>"; };
ABAEEF4E1FD5F8B100C966CB /* FIRQueryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRQueryTests.m; sourceTree = "<group>"; };
ABF341011FE858B500C48322 /* FSTAPIHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FSTAPIHelpers.h; sourceTree = "<group>"; };
ABF341021FE8593500C48322 /* FSTAPIHelpers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTAPIHelpers.m; sourceTree = "<group>"; };
B2FA635DF5D116A67A7441CD /* Pods_Firestore_IntegrationTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_IntegrationTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CE00BABB5A3AAB44A4C209E2 /* Pods-Firestore_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Tests/Pods-Firestore_Tests.debug.xcconfig"; sourceTree = "<group>"; };
D3CC3DC5338DCAF43A211155 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
Expand Down Expand Up @@ -585,8 +602,17 @@
DE51B1831F0D48AC0013853F /* API */ = {
isa = PBXGroup;
children = (
AB99452D1FE30AC800DFC1E6 /* FIRFieldValueTests.m */,
AB99452B1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m */,
AB9945291FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m */,
AB9945271FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m */,
AB9945251FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m */,
AB382F7D1FE03059007CA955 /* FIRFieldPathTests.m */,
AB382F7B1FE02A1F007CA955 /* FIRDocumentReferenceTests.m */,
DE51B1841F0D48AC0013853F /* FIRGeoPointTests.m */,
ABAEEF4E1FD5F8B100C966CB /* FIRQueryTests.m */,
ABF341011FE858B500C48322 /* FSTAPIHelpers.h */,
ABF341021FE8593500C48322 /* FSTAPIHelpers.m */,
);
path = API;
sourceTree = "<group>";
Expand Down Expand Up @@ -1164,6 +1190,7 @@
DE51B1FD1F0D492C0013853F /* FSTSpecTests.m in Sources */,
ABAEEF4F1FD5F8B100C966CB /* FIRQueryTests.m in Sources */,
DE51B2001F0D493A0013853F /* FSTComparisonTests.m in Sources */,
ABF341051FE860CA00C48322 /* FSTAPIHelpers.m in Sources */,
DE51B1CC1F0D48C00013853F /* FIRGeoPointTests.m in Sources */,
DE51B1E11F0D490D0013853F /* FSTMemoryRemoteDocumentCacheTests.m in Sources */,
DE51B1FF1F0D493A0013853F /* FSTAssertTests.m in Sources */,
Expand All @@ -1174,6 +1201,7 @@
DE51B2011F0D493E0013853F /* FSTHelpers.m in Sources */,
DE51B1F61F0D491B0013853F /* FSTSerializerBetaTests.m in Sources */,
DE51B1F01F0D49140013853F /* FSTFieldValueTests.m in Sources */,
AB9945281FE2DE0C00DFC1E6 /* FIRSnapshotMetadataTests.m in Sources */,
5491BC721FB44593008B3588 /* FSTIntegrationTestCase.mm in Sources */,
DE2EF0861F3D0B6E003D0CDC /* FSTImmutableSortedDictionary+Testing.m in Sources */,
DE51B1DE1F0D490D0013853F /* FSTMemoryLocalStoreTests.m in Sources */,
Expand All @@ -1186,6 +1214,7 @@
DE51B1D11F0D48CD0013853F /* FSTTargetIDGeneratorTests.m in Sources */,
DE51B1EF1F0D49140013853F /* FSTDocumentTests.m in Sources */,
DE51B1DC1F0D490D0013853F /* FSTLocalSerializerTests.m in Sources */,
AB99452A1FE2F9EB00DFC1E6 /* FIRDocumentSnapshotTests.m in Sources */,
DE51B1E71F0D490D0013853F /* FSTRemoteDocumentChangeBufferTests.m in Sources */,
DE51B1E51F0D490D0013853F /* FSTReferenceSetTests.m in Sources */,
DE51B1EA1F0D490D0013853F /* FSTLevelDBRemoteDocumentCacheTests.mm in Sources */,
Expand All @@ -1197,6 +1226,7 @@
DE51B1DB1F0D490D0013853F /* FSTLevelDBQueryCacheTests.m in Sources */,
54764FAB1FAA0C320085E60A /* string_util_test.cc in Sources */,
54E9282C1F339CAD00C1953E /* XCTestCase+Await.m in Sources */,
AB99452E1FE30AC800DFC1E6 /* FIRFieldValueTests.m in Sources */,
DE51B1DF1F0D490D0013853F /* FSTMemoryMutationQueueTests.m in Sources */,
DE51B1F31F0D491B0013853F /* FSTDatastoreTests.m in Sources */,
DE51B1D01F0D48CD0013853F /* FSTQueryTests.m in Sources */,
Expand All @@ -1209,7 +1239,9 @@
DE51B1D91F0D490D0013853F /* FSTEagerGarbageCollectorTests.m in Sources */,
DE51B1E21F0D490D0013853F /* FSTMutationQueueTests.m in Sources */,
DE51B1E81F0D490D0013853F /* FSTLevelDBKeyTests.mm in Sources */,
AB9945261FE2D71100DFC1E6 /* FIRCollectionReferenceTests.m in Sources */,
DE51B1E31F0D490D0013853F /* FSTPersistenceTestHelpers.m in Sources */,
AB382F7C1FE02A1F007CA955 /* FIRDocumentReferenceTests.m in Sources */,
DE51B1CF1F0D48CD0013853F /* FSTQueryListenerTests.m in Sources */,
DE51B1DA1F0D490D0013853F /* FSTLevelDBLocalStoreTests.m in Sources */,
DE51B1FA1F0D492C0013853F /* FSTLevelDBSpecTests.m in Sources */,
Expand All @@ -1218,7 +1250,9 @@
DE51B1CE1F0D48CD0013853F /* FSTEventManagerTests.m in Sources */,
DE51B1E41F0D490D0013853F /* FSTQueryCacheTests.m in Sources */,
DE51B1CD1F0D48CD0013853F /* FSTDatabaseInfoTests.m in Sources */,
AB382F7E1FE03059007CA955 /* FIRFieldPathTests.m in Sources */,
DE51B1F21F0D49140013853F /* FSTPathTests.m in Sources */,
AB99452C1FE3018D00DFC1E6 /* FIRQuerySnapshotTests.m in Sources */,
54740A571FC914BA00713A1A /* secure_random_test.cc in Sources */,
DE51B1DD1F0D490D0013853F /* FSTLocalStoreTests.m in Sources */,
D5B25474286C9800CE42B8C2 /* FSTTestDispatchQueue.m in Sources */,
Expand Down
43 changes: 43 additions & 0 deletions Firestore/Example/Tests/API/FIRCollectionReferenceTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRCollectionReference.h"

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

NS_ASSUME_NONNULL_BEGIN

@interface FIRCollectionReferenceTests : XCTestCase
@end

@implementation FIRCollectionReferenceTests

- (void)testEquals {
FIRCollectionReference *referenceFoo = FSTTestCollectionRef(@"foo");
FIRCollectionReference *referenceFooDup = FSTTestCollectionRef(@"foo");
FIRCollectionReference *referenceBar = FSTTestCollectionRef(@"bar");
XCTAssertEqualObjects(referenceFoo, referenceFooDup);
XCTAssertNotEqualObjects(referenceFoo, referenceBar);

XCTAssertEqual([referenceFoo hash], [referenceFooDup hash]);
XCTAssertNotEqual([referenceFoo hash], [referenceBar hash]);
}

@end

NS_ASSUME_NONNULL_END
43 changes: 43 additions & 0 deletions Firestore/Example/Tests/API/FIRDocumentReferenceTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRDocumentReference.h"

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

NS_ASSUME_NONNULL_BEGIN

@interface FIRDocumentReferenceTests : XCTestCase
@end

@implementation FIRDocumentReferenceTests

- (void)testEquals {
FIRDocumentReference *referenceFoo = FSTTestDocRef(@"rooms/foo");
FIRDocumentReference *referenceFooDup = FSTTestDocRef(@"rooms/foo");
FIRDocumentReference *referenceBar = FSTTestDocRef(@"rooms/bar");
XCTAssertEqualObjects(referenceFoo, referenceFooDup);
XCTAssertNotEqualObjects(referenceFoo, referenceBar);

XCTAssertEqual([referenceFoo hash], [referenceFooDup hash]);
XCTAssertNotEqual([referenceFoo hash], [referenceBar hash]);
}

@end

NS_ASSUME_NONNULL_END
62 changes: 62 additions & 0 deletions Firestore/Example/Tests/API/FIRDocumentSnapshotTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRDocumentSnapshot.h"

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

NS_ASSUME_NONNULL_BEGIN

@interface FIRDocumentSnapshotTests : XCTestCase
@end

@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);
FIRDocumentSnapshot *fromCache = FSTTestDocSnapshot(@"rooms/bar", 1, @{ @"a" : @1 }, NO, YES);
XCTAssertEqualObjects(base, baseDup);
XCTAssertEqualObjects(nilData, nilDataDup);
XCTAssertNotEqualObjects(base, nilData);
XCTAssertNotEqualObjects(nilData, base);
XCTAssertNotEqualObjects(base, differentPath);
XCTAssertNotEqualObjects(base, differentData);
XCTAssertNotEqualObjects(base, hasMutations);
XCTAssertNotEqualObjects(base, fromCache);

XCTAssertEqual([base hash], [baseDup hash]);
XCTAssertEqual([nilData hash], [nilDataDup hash]);
XCTAssertNotEqual([base hash], [nilData hash]);
XCTAssertNotEqual([base hash], [differentPath hash]);
XCTAssertNotEqual([base hash], [differentData hash]);
XCTAssertNotEqual([base hash], [hasMutations hash]);
XCTAssertNotEqual([base hash], [fromCache hash]);
}

@end

NS_ASSUME_NONNULL_END
45 changes: 45 additions & 0 deletions Firestore/Example/Tests/API/FIRFieldPathTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <XCTest/XCTest.h>

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

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

NS_ASSUME_NONNULL_BEGIN

@interface FIRFieldPathTests : XCTestCase
@end

@implementation FIRFieldPathTests

- (void)testEquals {
FIRFieldPath *foo = [[FIRFieldPath alloc] initPrivate:FSTTestFieldPath(@"foo.ooo.oooo")];
FIRFieldPath *fooDup = [[FIRFieldPath alloc] initPrivate:FSTTestFieldPath(@"foo.ooo.oooo")];
FIRFieldPath *bar = [[FIRFieldPath alloc] initPrivate:FSTTestFieldPath(@"baa.aaa.aaar")];
XCTAssertEqualObjects(foo, fooDup);
XCTAssertNotEqualObjects(foo, bar);

XCTAssertEqual([foo hash], [fooDup hash]);
XCTAssertNotEqual([foo hash], [bar hash]);
}

@end

NS_ASSUME_NONNULL_END
48 changes: 48 additions & 0 deletions Firestore/Example/Tests/API/FIRFieldValueTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@import FirebaseFirestore;

#import <XCTest/XCTest.h>

#import "FirebaseFirestore/FIRFieldValue.h"

NS_ASSUME_NONNULL_BEGIN

@interface FIRFieldValueTests : XCTestCase
@end

@implementation FIRFieldValueTests

- (void)testEquals {
FIRFieldValue *delete = [FIRFieldValue fieldValueForDelete];
FIRFieldValue *deleteDup = [FIRFieldValue fieldValueForDelete];
FIRFieldValue *serverTimestamp = [FIRFieldValue fieldValueForServerTimestamp];
FIRFieldValue *serverTimestampDup = [FIRFieldValue fieldValueForServerTimestamp];
XCTAssertEqualObjects(delete, deleteDup);
XCTAssertNotEqualObjects(delete, nil);
XCTAssertEqualObjects(serverTimestamp, serverTimestampDup);
XCTAssertNotEqualObjects(serverTimestamp, nil);
XCTAssertNotEqualObjects(delete, serverTimestamp);

XCTAssertEqual([delete hash], [deleteDup hash]);
XCTAssertEqual([serverTimestamp hash], [serverTimestamp hash]);
XCTAssertNotEqual([delete hash], [serverTimestamp hash]);
}

@end

NS_ASSUME_NONNULL_END
21 changes: 11 additions & 10 deletions Firestore/Example/Tests/API/FIRGeoPointTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ @interface FIRGeoPointTests : XCTestCase
@implementation FIRGeoPointTests

- (void)testEquals {
XCTAssertEqualObjects([[FIRGeoPoint alloc] initWithLatitude:0 longitude:0],
[[FIRGeoPoint alloc] initWithLatitude:0 longitude:0]);
XCTAssertEqualObjects([[FIRGeoPoint alloc] initWithLatitude:1.23 longitude:4.56],
[[FIRGeoPoint alloc] initWithLatitude:1.23 longitude:4.56]);
XCTAssertNotEqualObjects([[FIRGeoPoint alloc] initWithLatitude:0 longitude:0],
[[FIRGeoPoint alloc] initWithLatitude:1 longitude:0]);
XCTAssertNotEqualObjects([[FIRGeoPoint alloc] initWithLatitude:0 longitude:0],
[[FIRGeoPoint alloc] initWithLatitude:0 longitude:1]);
XCTAssertNotEqualObjects([[FIRGeoPoint alloc] initWithLatitude:0 longitude:0],
[[NSObject alloc] init]);
FIRGeoPoint *foo = FSTTestGeoPoint(1.23, 4.56);
FIRGeoPoint *fooDup = FSTTestGeoPoint(1.23, 4.56);
FIRGeoPoint *differentLatitude = FSTTestGeoPoint(1.23, 0);
FIRGeoPoint *differentLongitude = FSTTestGeoPoint(0, 4.56);
XCTAssertEqualObjects(foo, fooDup);
XCTAssertNotEqualObjects(foo, differentLatitude);
XCTAssertNotEqualObjects(foo, differentLongitude);

XCTAssertEqual([foo hash], [fooDup hash]);
XCTAssertNotEqual([foo hash], [differentLatitude hash]);
XCTAssertNotEqual([foo hash], [differentLongitude hash]);
}

- (void)testComparison {
Expand Down
Loading