aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example/Database
diff options
context:
space:
mode:
authorGravatar Sebastian Schmidt <mrschmidt@google.com>2017-06-27 10:04:47 -0700
committerGravatar GitHub <noreply@github.com>2017-06-27 10:04:47 -0700
commitc67a8bdc583c23865f2f31f2e38fd368d3b2505c (patch)
tree33d5ce1ba400bb35c020743d6562a07c3e7b97de /Example/Database
parentd55b0b3f973ff6e8ed1bd75e08391c54446c1f51 (diff)
Fixing parsing for double numbers (#107)
NSJSONSerialization parses long values as doubles and returns NSNumber that are backed by doubles to the users. For NSNumbers that can be stored as longs, we can overwrite this behavior by re-running the initialization step.
Diffstat (limited to 'Example/Database')
-rw-r--r--Example/Database/Tests/Integration/FEventTests.m4
-rw-r--r--Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m20
2 files changed, 20 insertions, 4 deletions
diff --git a/Example/Database/Tests/Integration/FEventTests.m b/Example/Database/Tests/Integration/FEventTests.m
index 8b11e9d..cbd7f31 100644
--- a/Example/Database/Tests/Integration/FEventTests.m
+++ b/Example/Database/Tests/Integration/FEventTests.m
@@ -74,10 +74,6 @@
}
-- (void) testWriteTwoNestedLeafNodesChange {
-
-}
-
- (void) testSetMultipleEventListenersOnSameNode {
FTupleFirebase* tuple = [FTestHelpers getRandomNodePair];
diff --git a/Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m b/Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m
index 658a894..f26a913 100644
--- a/Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m
+++ b/Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m
@@ -491,6 +491,26 @@
XCTAssertEqualObjects([[engine serverCacheAtPath:PATH(@"foo")] dataHash], hashFor247);
}
+- (void)testIntegersAreReturnedsAsIntegers {
+ id intValue = @247;
+ id longValue = @1542405709418655810;
+ id doubleValue = @0xFFFFFFFFFFFFFFFFUL; // This number can't be represented as a signed long.
+
+ id<FNode> expectedData = NODE((@{@"int": @247, @"long": longValue, @"double": doubleValue}));
+ FLevelDBStorageEngine *engine = [self cleanStorageEngine];
+ [engine updateServerCache:expectedData atPath:PATH(@"foo") merge:NO];
+ id<FNode> actualData = [engine serverCacheAtPath:PATH(@"foo")];
+ NSNumber* actualInt = [actualData val][@"int"];
+ NSNumber* actualLong = [actualData val][@"long"];
+ NSNumber* actualDouble = [actualData val][@"double"];
+
+ XCTAssertEqualObjects([actualInt stringValue], [intValue stringValue]);
+ XCTAssertEqual(CFNumberGetType((CFNumberRef)actualInt), kCFNumberSInt64Type);
+ XCTAssertEqualObjects([actualLong stringValue ], [longValue stringValue]);
+ XCTAssertEqual(CFNumberGetType((CFNumberRef)actualLong), kCFNumberSInt64Type);
+ XCTAssertEqual(CFNumberGetType((CFNumberRef)actualDouble), kCFNumberFloat64Type);
+}
+
// TODO[offline]: Somehow test estimated server size?
// TODO[offline]: Test pruning!