From 916f33c309b53f981400e39a0d65281fd03c6754 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Sat, 30 Jul 2011 00:37:37 +0000 Subject: 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 --- test/etap/020-btree-basics.t | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') 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). -- cgit v1.2.3