File: 12missing-element-has-o-as-cdata.t

package info (click to toggle)
libxml-semanticdiff-perl 1.0007-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 340 kB
  • sloc: perl: 703; xml: 532; sh: 4; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,075 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# This is a regression test file for bug:
#
#   http://rt.cpan.org/Ticket/Display.html?id=2322
#
# It seems to already have been fixed by the time this test was written.

use strict;
use warnings;

use Test::More tests => 1;

use XML::SemanticDiff;

package MyDiffHandler;

sub new
{
    my $class = shift;

    my $self = {};

    bless $self, $class;

    $self->{save_CData} = [];

    return $self;
}

sub missing_element
{
    my $self = shift;

    my ($elem, $properties) = @_;

    push @{$self->{save_CData}}, { cdata => $properties->{CData} };

    return {};
}

package main;

my $handler = MyDiffHandler->new();

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

my $xml_with_empty_element = <<'EOF';
<root><b>Quark</b><hello /></root>
EOF

my $xml_without_empty_element = <<'EOF';
<root><b>Quark</b></root>
EOF

my @results = $diff->compare(
    $xml_with_empty_element,
    $xml_without_empty_element,
);

# TEST
is_deeply ($handler->{save_CData},
    [ { cdata => undef } ],
    "Testing that the cdata for an empty element is the empty string."
);