diff options
author | zxu <zxu@google.com> | 2018-01-25 18:39:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-25 18:39:46 -0500 |
commit | 7226b4adf38e4732dfb9a840d25f86d3e5533bdb (patch) | |
tree | 01c7d79608eae5221deca452f8e461f2758b1ef0 /Firestore/Example | |
parent | 53064743963d7e5cc12f7a42bb036814f5a6df17 (diff) |
port TargetIdGenerator to iOS (#709)
* port TargetIdGenerator to iOS
* fix style
* move pointer property to instance variable
* TriggerTravis
Diffstat (limited to 'Firestore/Example')
-rw-r--r-- | Firestore/Example/Firestore.xcodeproj/project.pbxproj | 4 | ||||
-rw-r--r-- | Firestore/Example/Tests/Core/FSTTargetIDGeneratorTests.m | 94 |
2 files changed, 0 insertions, 98 deletions
diff --git a/Firestore/Example/Firestore.xcodeproj/project.pbxproj b/Firestore/Example/Firestore.xcodeproj/project.pbxproj index 7bc57fc..7c6508a 100644 --- a/Firestore/Example/Firestore.xcodeproj/project.pbxproj +++ b/Firestore/Example/Firestore.xcodeproj/project.pbxproj @@ -111,7 +111,6 @@ DE51B1CE1F0D48CD0013853F /* FSTEventManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AA1F0D48AC0013853F /* FSTEventManagerTests.m */; }; DE51B1CF1F0D48CD0013853F /* FSTQueryListenerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */; }; DE51B1D01F0D48CD0013853F /* FSTQueryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */; }; - DE51B1D11F0D48CD0013853F /* FSTTargetIDGeneratorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */; }; DE51B1D21F0D48CD0013853F /* FSTTimestampTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */; }; DE51B1D31F0D48CD0013853F /* FSTViewSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */; }; DE51B1D41F0D48CD0013853F /* FSTViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B11F0D48AC0013853F /* FSTViewTests.m */; }; @@ -331,7 +330,6 @@ DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTQueryListenerTests.m; sourceTree = "<group>"; }; DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTQueryTests.m; sourceTree = "<group>"; }; DE51B1AD1F0D48AC0013853F /* FSTSyncEngine+Testing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FSTSyncEngine+Testing.h"; sourceTree = "<group>"; }; - DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTTargetIDGeneratorTests.m; sourceTree = "<group>"; }; DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTTimestampTests.m; sourceTree = "<group>"; }; DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTViewSnapshotTest.m; sourceTree = "<group>"; }; DE51B1B11F0D48AC0013853F /* FSTViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTViewTests.m; sourceTree = "<group>"; }; @@ -718,7 +716,6 @@ DE51B1AA1F0D48AC0013853F /* FSTEventManagerTests.m */, DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */, DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */, - DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */, DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */, DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */, DE51B1B11F0D48AC0013853F /* FSTViewTests.m */, @@ -1253,7 +1250,6 @@ DE51B1F41F0D491B0013853F /* FSTRemoteEventTests.m in Sources */, 548DB927200D590300E00ABC /* assert_test.cc in Sources */, 54E928241F33953300C1953E /* FSTEventAccumulator.m in Sources */, - DE51B1D11F0D48CD0013853F /* FSTTargetIDGeneratorTests.m in Sources */, 5436F32420008FAD006E51E3 /* string_printf_test.cc in Sources */, DE51B1EF1F0D49140013853F /* FSTDocumentTests.m in Sources */, DE51B1DC1F0D490D0013853F /* FSTLocalSerializerTests.m in Sources */, diff --git a/Firestore/Example/Tests/Core/FSTTargetIDGeneratorTests.m b/Firestore/Example/Tests/Core/FSTTargetIDGeneratorTests.m deleted file mode 100644 index 6f54fd1..0000000 --- a/Firestore/Example/Tests/Core/FSTTargetIDGeneratorTests.m +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 "Firestore/Source/Core/FSTTargetIDGenerator.h" - -#import <XCTest/XCTest.h> - -NS_ASSUME_NONNULL_BEGIN - -@interface FSTTargetIDGenerator () -- (instancetype)initWithGeneratorID:(NSInteger)generatorID startingAfterID:(FSTTargetID)after; -@end - -@interface FSTTargetIDGeneratorTests : XCTestCase -@end - -@implementation FSTTargetIDGeneratorTests - -- (void)testConstructor { - XCTAssertEqual([[[FSTTargetIDGenerator alloc] initWithGeneratorID:0 startingAfterID:0] nextID], - 2); - XCTAssertEqual([[[FSTTargetIDGenerator alloc] initWithGeneratorID:1 startingAfterID:0] nextID], - 1); - - XCTAssertEqual([[FSTTargetIDGenerator generatorForLocalStoreStartingAfterID:0] nextID], 2); - XCTAssertEqual([[FSTTargetIDGenerator generatorForSyncEngineStartingAfterID:0] nextID], 1); -} - -- (void)testSkipPast { - FSTTargetIDGenerator *gen = - [[FSTTargetIDGenerator alloc] initWithGeneratorID:1 startingAfterID:-1]; - XCTAssertEqual([gen nextID], 1); - - gen = [[FSTTargetIDGenerator alloc] initWithGeneratorID:1 startingAfterID:2]; - XCTAssertEqual([gen nextID], 3); - - gen = [[FSTTargetIDGenerator alloc] initWithGeneratorID:1 startingAfterID:4]; - XCTAssertEqual([gen nextID], 5); - - for (int i = 4; i < 12; ++i) { - FSTTargetIDGenerator *gen0 = - [[FSTTargetIDGenerator alloc] initWithGeneratorID:0 startingAfterID:i]; - FSTTargetIDGenerator *gen1 = - [[FSTTargetIDGenerator alloc] initWithGeneratorID:1 startingAfterID:i]; - XCTAssertEqual([gen0 nextID], i + 2 & ~1, @"Skip failed for index %d", i); - XCTAssertEqual([gen1 nextID], i + 1 | 1, @"Skip failed for index %d", i); - } - - gen = [[FSTTargetIDGenerator alloc] initWithGeneratorID:1 startingAfterID:12]; - XCTAssertEqual([gen nextID], 13); - - gen = [[FSTTargetIDGenerator alloc] initWithGeneratorID:0 startingAfterID:22]; - XCTAssertEqual([gen nextID], 24); -} - -- (void)testIncrement { - FSTTargetIDGenerator *gen = - [[FSTTargetIDGenerator alloc] initWithGeneratorID:0 startingAfterID:0]; - XCTAssertEqual([gen nextID], 2); - XCTAssertEqual([gen nextID], 4); - XCTAssertEqual([gen nextID], 6); - gen = [[FSTTargetIDGenerator alloc] initWithGeneratorID:0 startingAfterID:46]; - XCTAssertEqual([gen nextID], 48); - XCTAssertEqual([gen nextID], 50); - XCTAssertEqual([gen nextID], 52); - XCTAssertEqual([gen nextID], 54); - - gen = [[FSTTargetIDGenerator alloc] initWithGeneratorID:1 startingAfterID:0]; - XCTAssertEqual([gen nextID], 1); - XCTAssertEqual([gen nextID], 3); - XCTAssertEqual([gen nextID], 5); - gen = [[FSTTargetIDGenerator alloc] initWithGeneratorID:1 startingAfterID:46]; - XCTAssertEqual([gen nextID], 47); - XCTAssertEqual([gen nextID], 49); - XCTAssertEqual([gen nextID], 51); - XCTAssertEqual([gen nextID], 53); -} - -@end - -NS_ASSUME_NONNULL_END |