File: 04namespaces.t

package info (click to toggle)
libxml-semanticdiff-perl 1.00.00-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 232 kB
  • sloc: perl: 535; xml: 532; makefile: 13
file content (46 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (2)
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
use Test;
BEGIN { plan tests => 4 }

use XML::SemanticDiff;

my $xml1 = <<'EOX';    
<?xml version="1.0"?>
<root xmlns="http://localhost/foo">
<el1 el1attr="good"/>
<el2 el2attr="good">Some Text</el2>
<el3/>
</root>
EOX

my $xml2 = <<'EOX';    
<?xml version="1.0"?>
<foo:root xmlns:foo="http://localhost/foo">
<foo:el1 el1attr="good"/>
<foo:el2 el2attr="good">Some Text</foo:el2>
<foo:el3/>
</foo:root>
EOX

my $xml3 = <<'EOX';    
<?xml version="1.0"?>
<root xmlns="http://localhost/foo">
<el1 xmlns="http://localhost/bar" el1attr="good"/>
<el2 el2attr="good">Some Text</el2>
<el3/>
</root>
EOX

my $diff = XML::SemanticDiff->new();

my @results = $diff->compare($xml1, $xml2);

ok(@results == 0);

@results = $diff->compare($xml1, $xml3);

ok(@results == 1);

ok($results[0]->{context} eq '/root[1]/el1[1]');

ok($results[0]->{message} =~ /namespace/gi);