### ----------------------------------------------------
### -- HTML::Entity::Fast
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use Test;
use HTML::Entity::Fast;

plan 8;

my $with         = 'Text with <entities> & «more» © fo =⃥';
my $without      = 'Text without entities';
my $encoded-with = 'Text with &lt;entities&gt; &amp; &laquo;more&raquo; &copy; fo &bne;';

is encode-html-entities($with), $encoded-with, 'encoding with entities';
is encode-html-entities($without),   $without, 'encoding without entities';

is decode-html-entities($encoded-with), $with, 'decoding with entities';
is decode-html-entities($without),   $without, 'decoding without entities';

is decode-html-entities('&#060;foo&#062;bar'), '<foo>bar',
  'decoding decimal numerical entities';
is decode-html-entities('&#x3C;bar&#X3e;foo'), '<bar>foo',
  'decoding hexadecimal numerical entities';

my $w-encode = whitelist-in-encode("<",">");
my $w-decode = whitelist-in-decode('&amp;');

is encode-html-entities('<ent> & ©', $w-encode),
  '<ent> &amp; &copy;', 'encode with white-listed';
is decode-html-entities('&lt;ent&gt; &amp; &copy;', $w-decode),
  '<ent> &amp; ©', 'decode with white-listed';

# vim: expandtab shiftwidth=4


