Skip to content

Instantly share code, notes, and snippets.

@kcmoffat
Last active May 6, 2016 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kcmoffat/e3eb47bc348632f042618a74dfc02824 to your computer and use it in GitHub Desktop.
Save kcmoffat/e3eb47bc348632f042618a74dfc02824 to your computer and use it in GitHub Desktop.
Push ID Generator Test
#import <XCTest/XCTest.h>
#import <Firebase/Firebase.h>
- (void)testGeneratePushId
{
Firebase *ref = [[Firebase alloc] initWithUrl:@"INSERT SOME FIREBASE URL HERE"];
NSMutableSet *set = [NSMutableSet set];
NSMutableArray *pushIds = [NSMutableArray array];
for (int i = 0; i < 100000; i++) {
NSString *pushId = [ref childByAutoId].key;
XCTAssert(![set containsObject:pushId], @"Duplicate key");
XCTAssert(!(i > 0 && !([pushId compare:[pushIds lastObject]] == NSOrderedDescending)),@"Not monotonically increasing");
[set addObject:pushId];
[pushIds addObject:pushId];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment