diff --git a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm index b1cd36a5c49..0f5627c95bf 100644 --- a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm @@ -896,6 +896,30 @@ - (void)testSdkOrdersQueryByDocumentIdTheSameWayOnlineAndOffline { ]]; } +- (void)testSnapshotListenerSortsNumbersSameWayAsServer { + FIRCollectionReference *collRef = [self collectionRefWithDocuments:@{ + @"intMin" : @{@"value" : @LLONG_MIN}, + @"doubleMin" : @{@"value" : @((double)LLONG_MIN - 100)}, + @"intMax" : @{@"value" : @LLONG_MAX}, + @"doubleMax" : @{@"value" : @((double)LLONG_MAX + 100)}, + @"NaN" : @{@"value" : [NSNumber numberWithFloat:NAN]}, + @"integerMax" : @{@"value" : @(INT_MAX)}, + @"integerMin" : @{@"value" : @(INT_MAX)}, + @"negativeInfinity" : @{@"value" : @(-INFINITY)}, + @"positiveInfinity" : @{@"value" : @(INFINITY)} + }]; + + FIRQuery *query = [collRef queryOrderedByField:@"value"]; + FIRQuerySnapshot *getSnapshot = [self readDocumentSetForRef:query]; + + id registration = + [query addSnapshotListener:self.eventAccumulator.valueEventHandler]; + FIRQuerySnapshot *watchSnapshot = [self.eventAccumulator awaitEventWithName:@"Snapshot"]; + XCTAssertEqualObjects(FIRQuerySnapshotGetIDs(watchSnapshot), FIRQuerySnapshotGetIDs(getSnapshot)); + + [registration remove]; +} + - (void)testCollectionGroupQueriesWithWhereFiltersOnArbitraryDocumentIDs { // Use .document() to get a random collection group name to use but ensure it starts with 'b' // for predictable ordering.