You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ra...@apache.org on 2011/07/30 02:37:38 UTC

svn commit: r1152407 - /couchdb/branches/1.1.x/test/etap/020-btree-basics.t

Author: randall
Date: Sat Jul 30 00:37:37 2011
New Revision: 1152407

URL: http://svn.apache.org/viewvc?rev=1152407&view=rev
Log:
Backport of r1152399 from trunk

add an etap test for btree traversal callbacks

Modified:
    couchdb/branches/1.1.x/test/etap/020-btree-basics.t

Modified: couchdb/branches/1.1.x/test/etap/020-btree-basics.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/test/etap/020-btree-basics.t?rev=1152407&r1=1152406&r2=1152407&view=diff
==============================================================================
--- couchdb/branches/1.1.x/test/etap/020-btree-basics.t (original)
+++ couchdb/branches/1.1.x/test/etap/020-btree-basics.t Sat Jul 30 00:37:37 2011
@@ -127,6 +127,7 @@ test_btree(Btree, KeyValues) ->
     ok = test_key_access(Btree, KeyValues),
     ok = test_lookup_access(Btree, KeyValues),
     ok = test_final_reductions(Btree, KeyValues),
+    ok = test_traversal_callbacks(Btree, KeyValues),
     true.
 
 test_add_remove(Btree, OutKeyValues, RemainingKeyValues) ->
@@ -187,6 +188,18 @@ test_final_reductions(Btree, KeyValues) 
     KVLen = FoldLRed + FoldRRed,
     ok.
 
+test_traversal_callbacks(Btree, KeyValues) ->
+    FoldFun =
+    fun
+        (visit, GroupedKey, Unreduced, Acc) ->
+            {ok, Acc andalso false};
+        (traverse, _LK, _Red, Acc) ->
+            {skip, Acc andalso true}
+    end,
+    % With 250 items the root is a kp. Always skipping should reduce to true.
+    {ok, _, true} = couch_btree:fold(Btree, FoldFun, true, [{dir, fwd}]),
+    ok.
+
 shuffle(List) ->
    randomize(round(math:log(length(List)) + 0.5), List).