File: dom_encode.t

package info (click to toggle)
libxml-dom-perl 1.46-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 692 kB
  • sloc: perl: 4,216; xml: 4,117; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 584 bytes parent folder | download | duplicates (5)
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
BEGIN {print "1..3\n";}
END {print "not ok 1\n" unless $loaded;}
use XML::DOM;
use CheckAncestors;
use CmpDOM;
$loaded = 1;
print "ok 1\n";

my $test = 1;
sub assert_ok
{
    my $ok = shift;
    print "not " unless $ok;
    ++$test;
    print "ok $test\n";
    $ok;
}

#Test 2

my $str = <<END;
<?xml version="1.0"?>
<elt attr="foo &amp; bar ]]>"/>
END

my $expected = <<END;
<?xml version="1.0"?>
<elt attr="foo &amp; bar ]]&gt;"/>
END

my $parser = new XML::DOM::Parser;
my $doc = $parser->parse ($str);
assert_ok (not $@);

my $out = $doc->toString;
assert_ok ($out eq $expected);