perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: modperl-2.0/t/response/TestAPR bucket.pm
Date Thu, 15 Jul 2004 15:25:36 GMT
randyk      2004/07/15 08:25:36

  Modified:    t/response/TestAPR bucket.pm
  Added:       t/apr-ext bucket.t
               t/lib/TestAPRlib bucket.pm
  Log:
  Reviewed by:	stas
  put common bucket tests under t/lib/TestAPRlib/, and call
  them from both t/apr/ and t/apr-ext/.
  
  Revision  Changes    Path
  1.1                  modperl-2.0/t/apr-ext/bucket.t
  
  Index: bucket.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  use Apache::Test;
  
  use TestAPRlib::bucket;
  
  plan tests => TestAPRlib::bucket::num_of_tests();
  
  TestAPRlib::bucket::test();
  
  
  
  1.1                  modperl-2.0/t/lib/TestAPRlib/bucket.pm
  
  Index: bucket.pm
  ===================================================================
  package TestAPRlib::bucket;
  
  # a mix of APR::Bucket and APR::BucketType tests
  
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  
  use APR::Bucket ();
  use APR::BucketType ();
  
  sub num_of_tests {
      return 11;
  }
  
  sub test {
  
      # new: basic
      {
          my $data = "foobar";
          my $b = APR::Bucket->new($data);
  
          t_debug('$b is defined');
          ok defined $b;
  
          t_debug('$b ISA APR::Bucket object');
          ok $b->isa('APR::Bucket');
  
          my $type = $b->type;
          ok t_cmp($type->name, 'mod_perl SV bucket', "type");
  
          ok t_cmp($b->length, length($data), "modperl b->length");
      }
  
      # new: offset
      {
          my $data   = "foobartar";
          my $offset = 3;
          my $real = substr $data, $offset;
          my $b = APR::Bucket->new($data, $offset);
          my $rlen = $b->read(my $read);
          ok t_cmp($read, $real, 'new($data, $offset)/buffer');
          ok t_cmp($rlen, length($read), 'new($data, $offset)/len');
          ok t_cmp($b->start, $offset, 'offset');
  
      }
  
      # new: offset+len
      {
          my $data   = "foobartar";
          my $offset = 3;
          my $len    = 3;
          my $real = substr $data, $offset, $len;
          my $b = APR::Bucket->new($data, $offset, $len);
          my $rlen = $b->read(my $read);
          ok t_cmp($read, $real, 'new($data, $offset, $len)/buffer');
          ok t_cmp($rlen, length($read), 'new($data, $offse, $lent)/len');
      }
  
      # new: offset+ too big len
      {
          my $data   = "foobartar";
          my $offset = 3;
          my $len    = 10;
          my $real = substr $data, $offset, $len;
          my $b = eval { APR::Bucket->new($data, $offset, $len) };
          ok t_cmp($@,
                   qr/the length argument can't be bigger than the total/,
                   'new($data, $offset, $len_too_big)');
      }
  
      # remove
      {
          my $b = APR::Bucket->new("aaa");
          # remove $b when it's not attached to anything (not sure if
          # that should be an error)
          $b->remove;
          ok 1;
  
          # real remove from bb is tested in many other filter tests
      }
  }
  
  1;
  
  
  
  
  1.7       +5 -67     modperl-2.0/t/response/TestAPR/bucket.pm
  
  Index: bucket.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestAPR/bucket.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- bucket.pm	8 Jul 2004 06:06:33 -0000	1.6
  +++ bucket.pm	15 Jul 2004 15:25:36 -0000	1.7
  @@ -16,79 +16,17 @@
   
   use Apache::Const -compile => 'OK';
   
  +use TestAPRlib::bucket;
  +
   sub handler {
   
       my $r = shift;
   
  -    plan $r, tests => 29;
  -
  -    my $ba = $r->connection->bucket_alloc;
  -
  -    # new: basic
  -    {
  -        my $data = "foobar";
  -        my $b = APR::Bucket->new($data);
  -
  -        t_debug('$b is defined');
  -        ok defined $b;
  -
  -        t_debug('$b ISA APR::Bucket object');
  -        ok $b->isa('APR::Bucket');
  -
  -        my $type = $b->type;
  -        ok t_cmp($type->name, 'mod_perl SV bucket', "type");
  +    plan $r, tests => 18 + TestAPRlib::bucket::num_of_tests();
   
  -        ok t_cmp($b->length, length($data), "modperl b->length");
  -    }
  -
  -    # new: offset
  -    {
  -        my $data   = "foobartar";
  -        my $offset = 3;
  -        my $real = substr $data, $offset;
  -        my $b = APR::Bucket->new($data, $offset);
  -        my $rlen = $b->read(my $read);
  -        ok t_cmp($read, $real, 'new($data, $offset)/buffer');
  -        ok t_cmp($rlen, length($read), 'new($data, $offset)/len');
  -        ok t_cmp($b->start, $offset, 'offset');
  -
  -    }
  -
  -    # new: offset+len
  -    {
  -        my $data   = "foobartar";
  -        my $offset = 3;
  -        my $len    = 3;
  -        my $real = substr $data, $offset, $len;
  -        my $b = APR::Bucket->new($data, $offset, $len);
  -        my $rlen = $b->read(my $read);
  -        ok t_cmp($read, $real, 'new($data, $offset, $len)/buffer');
  -        ok t_cmp($rlen, length($read), 'new($data, $offse, $lent)/len');
  -    }
  -
  -    # new: offset+ too big len
  -    {
  -        my $data   = "foobartar";
  -        my $offset = 3;
  -        my $len    = 10;
  -        my $real = substr $data, $offset, $len;
  -        my $b = eval { APR::Bucket->new($data, $offset, $len) };
  -        ok t_cmp($@,
  -                 qr/the length argument can't be bigger than the total/,
  -                 'new($data, $offset, $len_too_big)');
  -    }
  -
  -    # remove
  -    {
  -        my $b = APR::Bucket->new("aaa");
  -        # remove $b when it's not attached to anything (not sure if
  -        # that should be an error)
  -        $b->remove;
  -        ok 1;
  -
  -        # real remove from bb is tested in many other filter tests
  -    }
  +    TestAPRlib::bucket::test();
   
  +    my $ba = $r->connection->bucket_alloc;
   
       # eos_create / type / length
       {
  
  
  

Mime
View raw message