You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by ra...@apache.org on 2005/04/24 00:29:06 UTC
svn commit: r164423 - in /perl/modperl/trunk/t: apr-ext/brigade.t
lib/TestAPRlib/brigade.pm response/TestAPR/brigade.pm
Author: randyk
Date: Sat Apr 23 15:29:04 2005
New Revision: 164423
URL: http://svn.apache.org/viewcvs?rev=164423&view=rev
Log:
add apr-ext tests for APR::Brigade
Added:
perl/modperl/trunk/t/apr-ext/brigade.t (with props)
perl/modperl/trunk/t/lib/TestAPRlib/brigade.pm (with props)
Modified:
perl/modperl/trunk/t/response/TestAPR/brigade.pm
Added: perl/modperl/trunk/t/apr-ext/brigade.t
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/apr-ext/brigade.t?rev=164423&view=auto
==============================================================================
--- perl/modperl/trunk/t/apr-ext/brigade.t (added)
+++ perl/modperl/trunk/t/apr-ext/brigade.t Sat Apr 23 15:29:04 2005
@@ -0,0 +1,11 @@
+#!perl -T
+
+use strict;
+use warnings FATAL => 'all';
+use Apache::Test;
+
+use TestAPRlib::brigade;
+
+plan tests => TestAPRlib::brigade::num_of_tests();
+
+TestAPRlib::brigade::test();
Propchange: perl/modperl/trunk/t/apr-ext/brigade.t
------------------------------------------------------------------------------
svn:eol-style = native
Added: perl/modperl/trunk/t/lib/TestAPRlib/brigade.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/lib/TestAPRlib/brigade.pm?rev=164423&view=auto
==============================================================================
--- perl/modperl/trunk/t/lib/TestAPRlib/brigade.pm (added)
+++ perl/modperl/trunk/t/lib/TestAPRlib/brigade.pm Sat Apr 23 15:29:04 2005
@@ -0,0 +1,106 @@
+package TestAPRlib::brigade;
+
+# testing APR::Brigade in this tests.
+# Other tests do that too:
+# TestAPR::flatten : flatten()
+# TestAPR::bucket : is_empty(), first(), last()
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use APR::Pool ();
+use APR::Brigade ();
+use APR::Bucket ();
+use APR::BucketAlloc ();
+
+use Apache2::Const -compile => 'OK';
+
+sub num_of_tests {
+ return 14;
+}
+
+sub test {
+
+ my $p = APR::Pool->new();
+ my $ba = APR::BucketAlloc->new($p);
+
+ # basic + pool + destroy
+ {
+ my $bb = APR::Brigade->new($p, $ba);
+
+ t_debug('$bb is defined');
+ ok defined $bb;
+
+ t_debug('$bb ISA APR::Brigade object');
+ ok $bb->isa('APR::Brigade');
+
+ my $pool = $bb->pool;
+
+ t_debug('$pool is defined');
+ ok defined $pool;
+
+ t_debug('$pool ISA APR::Pool object');
+ ok $pool->isa('APR::Pool');
+
+ t_debug("destroy");
+ $bb->destroy;
+ ok 1;
+ }
+
+ # concat / split / length / flatten
+ {
+ my $bb1 = APR::Brigade->new($p, $ba);
+ $bb1->insert_head(APR::Bucket->new($ba, "11"));
+ $bb1->insert_tail(APR::Bucket->new($ba, "12"));
+
+ my $bb2 = APR::Brigade->new($p, $ba);
+ $bb2->insert_head(APR::Bucket->new($ba, "21"));
+ $bb2->insert_tail(APR::Bucket->new($ba, "22"));
+
+ # concat
+ $bb1->concat($bb2);
+ # bb1: 11, 12, 21, 22
+ ok t_cmp($bb1->length, 8, "total data length in bb");
+ my $len = $bb1->flatten(my $data);
+ ok t_cmp($len, 8, "bb flatten/len");
+ ok t_cmp($data, "11122122", "bb flatten/data");
+ t_debug('$bb2 is empty');
+ ok $bb2->is_empty;
+
+ # split
+ my $b = $bb1->first; # 11
+ $b = $bb1->next($b); # 12
+ my $bb3 = $bb1->split($b);
+
+ # bb1: 11, bb3: 12, 21, 22
+ $len = $bb1->flatten($data);
+ ok t_cmp($len, 2, "bb1 flatten/len");
+ ok t_cmp($data, "11", "bb1 flatten/data");
+ $len = $bb3->flatten($data);
+ ok t_cmp($len, 6, "bb3 flatten/len");
+ ok t_cmp($data, "122122", "bb3 flatten/data");
+ }
+
+ # out-of-scope pools
+ {
+ my $bb1 = APR::Brigade->new(APR::Pool->new, $ba);
+ $bb1->insert_head(APR::Bucket->new($ba, "11"));
+ $bb1->insert_tail(APR::Bucket->new($ba, "12"));
+
+ # try to overwrite the temp pool data
+ require APR::Table;
+ my $table = APR::Table::make(APR::Pool->new, 50);
+ $table->set($_ => $_) for 'aa'..'za';
+ # now test that we are still OK
+
+ my $len = $bb1->flatten(my $data);
+ ok t_cmp($data, "1112", "correct data");
+ }
+
+ Apache2::Const::OK;
+}
+
+1;
Propchange: perl/modperl/trunk/t/lib/TestAPRlib/brigade.pm
------------------------------------------------------------------------------
svn:eol-style = native
Modified: perl/modperl/trunk/t/response/TestAPR/brigade.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/response/TestAPR/brigade.pm?rev=164423&r1=164422&r2=164423&view=diff
==============================================================================
--- perl/modperl/trunk/t/response/TestAPR/brigade.pm (original)
+++ perl/modperl/trunk/t/response/TestAPR/brigade.pm Sat Apr 23 15:29:04 2005
@@ -16,12 +16,16 @@
use Apache2::Const -compile => 'OK';
+use TestAPRlib::brigade;
+
sub handler {
my $r = shift;
my $ba = $r->connection->bucket_alloc;
- plan $r, tests => 14;
+ plan $r, tests => 14 + TestAPRlib::brigade::num_of_tests();
+
+ TestAPRlib::brigade::test();
# basic + pool + destroy
{