Permalink
Browse files

Added test for string collation in views

We have a custom string collation routine based on
CFString (in couch_icu_driver.m) and it wasn't sorting
strings the way CouchDB expects.
This new test case will fail until the corresponding
patch to iErl14 that fixes the bug is committed.

Change-Id: I32141934bc51b43963c9343f239635b0b9098e34
Reviewed-on: http://review.couchbase.org/9724
Reviewed-by: Chris Anderson <jchris@couchbase.com>
Tested-by: Jens Alfke <jens@couchbase.com>
  • Loading branch information...
1 parent 279d382 commit 3e2b3a6ef4d78e0ee02edfb3ecfa0bd333b243f2 @snej snej committed Sep 22, 2011
Showing with 26 additions and 0 deletions.
  1. +26 −0 EmptyApp/Tests/EmptyAppTests.m
View
26 EmptyApp/Tests/EmptyAppTests.m
@@ -172,4 +172,30 @@ - (void)test3_BigNums {
}
+- (void)test4_Collation {
+ // Test string collation order -- this is important because it's implemented in platform
+ // specific code, couch_icu_driver.m.
+ [self send: @"PUT" toPath: @"/unittestdb" body: nil];
+ [self send: @"PUT" toPath: @"/unittestdb/doc1" body: @"{\"str\":\"a\"}"];
+ [self send: @"PUT" toPath: @"/unittestdb/doc2" body: @"{\"str\":\"A\"}"];
+ [self send: @"PUT" toPath: @"/unittestdb/doc3" body: @"{\"str\":\"aa\"}"];
+ [self send: @"PUT" toPath: @"/unittestdb/doc4" body: @"{\"str\":\"b\"}"];
+ [self send: @"PUT" toPath: @"/unittestdb/doc5" body: @"{\"str\":\"B\"}"];
+
+ [self send: @"PUT" toPath: @"/unittestdb/_design/collation"
+ body: @"{\"views\":{\"simple\":{\"map\":\"function(doc){emit(doc.str,null);}\"}}}"];
+
+ NSString* result = [self send: @"GET" toPath: @"/unittestdb/_design/collation/_view/simple"
+ body: nil responseHeaders: NULL];
+ STAssertEqualObjects(result, @"{\"total_rows\":5,\"offset\":0,\"rows\":[\r\n"
+ "{\"id\":\"doc1\",\"key\":\"a\",\"value\":null},\r\n"
+ "{\"id\":\"doc2\",\"key\":\"A\",\"value\":null},\r\n"
+ "{\"id\":\"doc3\",\"key\":\"aa\",\"value\":null},\r\n"
+ "{\"id\":\"doc4\",\"key\":\"b\",\"value\":null},\r\n"
+ "{\"id\":\"doc5\",\"key\":\"B\",\"value\":null}\r\n"
+ "]}\n",
+ nil);
+}
+
+
@end

0 comments on commit 3e2b3a6

Please sign in to comment.