summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Leeds <randall@apache.org>2011-07-30 00:37:37 +0000
committerRandall Leeds <randall@apache.org>2011-07-30 00:37:37 +0000
commit916f33c309b53f981400e39a0d65281fd03c6754 (patch)
tree90290065eeaaccf1d17f14e7d95b04b9c2f5b433
parent2a92b4b41f261a8ddca496d729a39bbd20c41320 (diff)
Backport of r1152399 from trunk
add an etap test for btree traversal callbacks git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1152407 13f79535-47bb-0310-9956-ffa450edef68
-rwxr-xr-xtest/etap/020-btree-basics.t13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/etap/020-btree-basics.t b/test/etap/020-btree-basics.t
index 18c4a836..8ab453ee 100755
--- a/test/etap/020-btree-basics.t
+++ b/test/etap/020-btree-basics.t
@@ -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).