File: 64tags.t

package info (click to toggle)
libhttp-proxy-perl 0.25-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 568 kB
  • sloc: perl: 2,392; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use Test::More tests => 14;
use strict;
use HTTP::Proxy::BodyFilter::tags;

my $filter = HTTP::Proxy::BodyFilter::tags->new();

# test the filter
for (
    [ '<b><i>foo</i></b> bar', '', '<b><i>foo</i></b> bar', '' ],
    [ '<b><i>foo</i></',       '', '<b><i>foo</i>',         '</' ],
    [ '>',                     '', '>',                     '' ],
    [ '><b>foo',               '', '><b>foo',               '' ],
    [ '><b>foo<i',             '', '><b>foo',               '<i' ],
    [ '><b>foo<i',             undef, '><b>foo<i',               undef ],
    [ '<!-- b> <b> --> > <>><', '', '<!-- b> <b> --> > <>>', '<'],
    # the following fails because of the implementation of the tags.pm
    # a stronger implementation requires parsing
    # [ 'x<a href="http://foo/>"', '', 'x', '<a href="http://foo/>"' ],
  )
{
    my ( $data, $buffer ) = @$_[ 0, 1 ];
    $filter->filter( \$data, undef, undef,
        ( defined $buffer ? \$buffer : undef ) );
    is( $data,   $_->[2], "Correct data" );
    is( $buffer, $_->[3], "Correct buffer" );
}