Permalink
Browse files

Added unit test for bignums in views

This tests the fix for issue CBMI-34.

Change-Id: I3e2012e64323c6ab3d182ea3eb0c6fd49ec36e83
Reviewed-on: http://review.couchbase.org/9230
Reviewed-by: Chris Anderson <jchris@couchbase.com>
Tested-by: Jens Alfke <jens@couchbase.com>
  • Loading branch information...
1 parent 0773827 commit bd461f75f4459d856414a096cc119ec69f16294b @snej snej committed Aug 25, 2011
Showing with 23 additions and 0 deletions.
  1. +23 −0 EmptyApp/Tests/EmptyAppTests.m
@@ -149,4 +149,27 @@ - (void)test3_UpdateViews {
}
+- (void)test3_BigNums {
+ // Test that large integers in documents don't break JS views [Issue CBMI-34]
+ [self send: @"PUT" toPath: @"/unittestdb" body: nil];
+ [self send: @"PUT" toPath: @"/unittestdb/doc1" body: @"{\"n\":1234}"];
+ [self send: @"PUT" toPath: @"/unittestdb/doc2" body: @"{\"n\":1313684610751}"];
+ [self send: @"PUT" toPath: @"/unittestdb/doc3" body: @"{\"n\":1313684610751.1234}"];
+
+ [self send: @"PUT" toPath: @"/unittestdb/_design/updateviews"
+ body: @"{\"views\":{\"simple\":{\"map\":\"function(doc){emit(doc._id,null);}\"}}}"];
+
+ NSDictionary* headers;
+ NSString* result = [self send: @"GET" toPath: @"/unittestdb/_design/updateviews/_view/simple"
+ body: nil responseHeaders: &headers];
+ NSLog(@"Result of view = %@", result);
+ STAssertEqualObjects(result, @"{\"total_rows\":3,\"offset\":0,\"rows\":[\r\n"
+ "{\"id\":\"doc1\",\"key\":\"doc1\",\"value\":null},\r\n"
+ "{\"id\":\"doc2\",\"key\":\"doc2\",\"value\":null},\r\n"
+ "{\"id\":\"doc3\",\"key\":\"doc3\",\"value\":null}\r\n"
+ "]}\n",
+ nil);
+}
+
+
@end

0 comments on commit bd461f7

Please sign in to comment.