File: 02encoding.t

package info (click to toggle)
libhtml-html5-entities-perl 0.004-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 220 kB
  • sloc: perl: 2,606; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use Test::More tests => 8;
use HTML::HTML5::Entities qw[encode_entities_numeric encode_entities];

ok($HTML::HTML5::Entities::hex, 'hex encoding by default');

$HTML::HTML5::Entities::hex = 0;
is(encode_entities('&'),               '&',           'encode_entities works');
is(encode_entities('a&b'),             'a&b',         'safe characters pass through');
is(encode_entities('a&b', 'a&'),       'a&b',     'unsafe characters can be specified');
is(encode_entities('a&b', qr/[&a-z]/), 'a&b', 'unsafe characters can be regexps');

is(encode_entities_numeric('&'), '&', 'numeric encoding works');

$HTML::HTML5::Entities::hex = 1;
is(encode_entities_numeric('&'), '&', 'hex encoding works');

my $var = '&';
encode_entities($var);
is($var, '&', 'in-place encoding works');