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 69 70 71 72 73
|
#!/usr/bin/perl
use XML::DT ;
use Test::More tests => 8;
my $filename = "t/05_input.xml";
####
%h1=('-default' => sub{"<$q></$q>"});
$str = dt($filename,%h1);
$str =~ s/\s//g;
is($str, "<a></a>");
####
%h2=('c' => sub{ "<$q></$q>" },
'-default' => sub{"<$q>$c</$q>"});
$str = dt($filename,%h2);
$str =~ s/\s//g;
is($str, "<a><b><c></c><c></c></b><b><c></c><c></c></b><b><c></c><c></c></b></a>");
####
%h3=('-default' => sub{"$q:$c"});
$str = dt($filename,%h3);
$str =~ s/\s//g;
is($str, "a:b:c:aeiouc:aeioub:c:aeiouc:aeioub:c:aeiouc:aeiou");
####
%h4=(c => sub{ $v{title} },
'-default' => sub{
$v{title} ||="";
"$v{title}$c" });
$str = dt($filename,%h4);
$str =~ s/\s//g;
is($str, "zbrzbr");
###
# Isto no portvel!!!!!
#
# %h5=(-default=>sub{toxml});
# $str = dt($filename, %h5);
# is(`tail -14 t/05_input.xml`,$str);
###
$str = dtstring("<foo></foo>", -declr => 1);
is("<?xml version=\"1.0\"?>\n<foo/>",$str);
###
{
no utf8;
# use Encode;
# for my $straux ("<encoding></encoding>",
# qq{<encoding v="jos"></encoding>}) {
# $str = dtstring($straux, -inputenc=>'ISO-8859-1');
# is(decode("iso-8859-1",$str),$straux);
# }
###
for my $straux ("<encoding></encoding>",
qq{<encoding v="jos"></encoding>},
"<encoding></encoding>") {
$str = dtstring($straux, -outputenc=>'ISO-8859-1', -inputenc=>'ISO-8859-1');
is($str,$straux);
}
}
|