File: html.t

package info (click to toggle)
libbadger-perl 0.16-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 2,400 kB
  • sloc: perl: 11,004; makefile: 9
file content (68 lines) | stat: -rw-r--r-- 1,948 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#========================================================================
#
# t/codec/html.t
#
# Test the Badger::Codec::HTML module.
#
# Written by Andy Wardley <abw@wardley.org>
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
#========================================================================

use Badger::Test
    lib   => '../../lib',
    tests => 8,
    debug => 'Badger::Codec::HTML',
    args  => \@ARGV;

use Badger::Codecs
    codec => 'HTML';

use constant 
    Codec => 'Badger::Codec::HTML';


my $html = '<foo>"&bar"</foo>';
my $enc  = '&lt;foo&gt;&quot;&amp;bar&quot;&lt;/foo&gt;';

#-----------------------------------------------------------------------
# should be able to access via the Badger::Codec module
#-----------------------------------------------------------------------

is( Badger::Codecs->encode(html => $html), $enc, 'HTML encode() via Badger::Codec' );
is( Badger::Codecs->decode(html => $enc), $html, 'HTML decode() via Badger::Codec' );

#-----------------------------------------------------------------------
# and also directly
#-----------------------------------------------------------------------

is( Codec->encode($html), $enc, 'HTML codec encode() class method' );
is( Codec->decode($enc), $html, 'HTML codec decode() class method' );

my $codec = Codec->new();

is( $codec->encode($html), $enc, 'HTML codec encode() object method' );
is( $codec->decode($enc), $html, 'HTML codec decode() object method' );


#-----------------------------------------------------------------------
# and via the imported encode()/decode() functions
#-----------------------------------------------------------------------

is( encode($html), $enc, 'encode() function' );
is( decode($enc), $html, 'decode() function' );



__END__

# Local Variables:
# mode: Perl
# perl-indent-level: 4
# indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4: