From commits-return-6702-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Sat Jul 30 00:04:51 2011 Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D98D26F97 for ; Sat, 30 Jul 2011 00:04:51 +0000 (UTC) Received: (qmail 36476 invoked by uid 500); 30 Jul 2011 00:04:51 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 36434 invoked by uid 500); 30 Jul 2011 00:04:51 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 36397 invoked by uid 99); 30 Jul 2011 00:04:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Jul 2011 00:04:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Jul 2011 00:04:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 42FA523889E1 for ; Sat, 30 Jul 2011 00:04:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1152399 - /couchdb/trunk/test/etap/020-btree-basics.t Date: Sat, 30 Jul 2011 00:04:30 -0000 To: commits@couchdb.apache.org From: randall@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110730000430.42FA523889E1@eris.apache.org> Author: randall Date: Sat Jul 30 00:04:29 2011 New Revision: 1152399 URL: http://svn.apache.org/viewvc?rev=1152399&view=rev Log: add an etap test for btree traversal callbacks Modified: couchdb/trunk/test/etap/020-btree-basics.t Modified: couchdb/trunk/test/etap/020-btree-basics.t URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/020-btree-basics.t?rev=1152399&r1=1152398&r2=1152399&view=diff ============================================================================== --- couchdb/trunk/test/etap/020-btree-basics.t (original) +++ couchdb/trunk/test/etap/020-btree-basics.t Sat Jul 30 00:04:29 2011 @@ -174,6 +174,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) -> @@ -234,6 +235,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).