From commits-return-7021-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Wed Sep 21 10:53:45 2005 Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 5599 invoked from network); 21 Sep 2005 10:53:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Sep 2005 10:53:45 -0000 Received: (qmail 33191 invoked by uid 500); 21 Sep 2005 10:53:44 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 33158 invoked by uid 500); 21 Sep 2005 10:53:44 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 33143 invoked by uid 99); 21 Sep 2005 10:53:44 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 21 Sep 2005 03:53:44 -0700 Received: (qmail 5525 invoked by uid 65534); 21 Sep 2005 10:53:24 -0000 Message-ID: <20050921105324.5524.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r290680 - in /apr/apr-util/branches/1.2.x: include/apr_buckets.h test/testbuckets.c Date: Wed, 21 Sep 2005 10:53:23 -0000 To: commits@apr.apache.org From: jorton@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jorton Date: Wed Sep 21 03:53:18 2005 New Revision: 290680 URL: http://svn.apache.org/viewcvs?rev=290680&view=rev Log: Merge r290556, r290679 from trunk: * include/apr_buckets.h (apr_brigade_partition): Document the return value semantics. * test/testbuckets.c (test_bucket_content): New function. (test_partition): New test. Modified: apr/apr-util/branches/1.2.x/include/apr_buckets.h apr/apr-util/branches/1.2.x/test/testbuckets.c Modified: apr/apr-util/branches/1.2.x/include/apr_buckets.h URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/1.2.x/include/apr_buckets.h?rev=290680&r1=290679&r2=290680&view=diff ============================================================================== --- apr/apr-util/branches/1.2.x/include/apr_buckets.h (original) +++ apr/apr-util/branches/1.2.x/include/apr_buckets.h Wed Sep 21 03:53:18 2005 @@ -697,6 +697,10 @@ * @param b The brigade to partition * @param point The offset at which to partition the brigade * @param after_point Returns a pointer to the first bucket after the partition + * @return APR_SUCCESS on success, APR_INCOMPLETE if the contents of the + * brigade were shorter than @a point, or an error code. + * @remark if APR_INCOMPLETE is returned, @a after_point will be set to + * the brigade sentinel. */ APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b, apr_off_t point, Modified: apr/apr-util/branches/1.2.x/test/testbuckets.c URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/1.2.x/test/testbuckets.c?rev=290680&r1=290679&r2=290680&view=diff ============================================================================== --- apr/apr-util/branches/1.2.x/test/testbuckets.c (original) +++ apr/apr-util/branches/1.2.x/test/testbuckets.c Wed Sep 21 03:53:18 2005 @@ -209,6 +209,22 @@ apr_bucket_alloc_destroy(ba); } +/* Test that bucket E has content EDATA of length ELEN. */ +static void test_bucket_content(abts_case *tc, + apr_bucket *e, + const char *edata, + apr_size_t elen) +{ + const char *adata; + apr_size_t alen; + + apr_assert_success(tc, "read from bucket", + apr_bucket_read(e, &adata, &alen, + APR_BLOCK_READ)); + + ABTS_ASSERT(tc, "read expected length", alen == elen); + ABTS_STR_NEQUAL(tc, edata, adata, elen); +} static void test_splits(abts_case *tc, void *ctx) { @@ -414,6 +430,36 @@ apr_bucket_alloc_destroy(ba); } +static const char hello[] = "hello, world"; + +static void test_partition(abts_case *tc, void *data) +{ + apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); + apr_bucket_brigade *bb = apr_brigade_create(p, ba); + apr_bucket *e; + + e = apr_bucket_immortal_create(hello, strlen(hello), ba); + APR_BRIGADE_INSERT_HEAD(bb, e); + + apr_assert_success(tc, "partition brigade", + apr_brigade_partition(bb, 5, &e)); + + test_bucket_content(tc, APR_BRIGADE_FIRST(bb), + "hello", 5); + + test_bucket_content(tc, APR_BRIGADE_LAST(bb), + ", world", 7); + + ABTS_ASSERT(tc, "partition returns APR_INCOMPLETE", + apr_brigade_partition(bb, 8192, &e)); + + ABTS_ASSERT(tc, "APR_INCOMPLETE partition returned sentinel", + e == APR_BRIGADE_SENTINEL(bb)); + + apr_brigade_destroy(bb); + apr_bucket_alloc_destroy(ba); +} + abts_suite *testbuckets(abts_suite *suite) { suite = ADD_SUITE(suite); @@ -428,6 +474,7 @@ abts_run_test(suite, test_insertfile, NULL); abts_run_test(suite, test_manyfile, NULL); abts_run_test(suite, test_truncfile, NULL); + abts_run_test(suite, test_partition, NULL); return suite; }