~ubuntu-branches/ubuntu/utopic/libxml-bare-perl/utopic-proposed

« back to all changes in this revision

Viewing changes to t/escaped_xml.t

  • Committer: Package Import Robot
  • Author(s): Nuno Carvalho, gregor herrmann, Salvatore Bonaccorso, Axel Beckert, Nuno Carvalho
  • Date: 2013-09-17 15:54:28 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130917155428-4d0xb5cissw2323f
Tags: 0.53-1
* Team upload.

[ gregor herrmann ]
* debian/control: update {versioned,alternative} (build) dependencies.

[ Salvatore Bonaccorso ]
* Change Vcs-Git to canonical URI (git://anonscm.debian.org)
* Change search.cpan.org based URIs to metacpan.org based URIs

[ Axel Beckert ]
* debian/copyright: migrate pre-1.0 format to 1.0 using "cme fix dpkg-
  copyright"

[ Nuno Carvalho ]
* New upstream release.
* debian/copyright: update copyright years.
* debian/control: update standards version.
* debian/control: update debhelper required version, in order to pass all
  the hardening flags to EUMM.
* Add lintian override to apparently false-positive warning.
* Add set of patches accepted upstream but still not included in this
  release, visit https://rt.cpan.org/Public/Bug/Display.html?id=88155
  for details.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
 
3
 
use strict;
4
 
use warnings;
5
 
 
6
 
use Test::Harness;
7
 
use Test::More;
8
 
##use Data::Dump qw[dump];    # only needed for diag
9
 
 
10
 
use_ok('XML::Bare');
11
 
 
12
 
my $data = {
13
 
    hash => "#",
14
 
    amp  => '&',
15
 
    gt   => '>',
16
 
    lt   => '<',
17
 
    quot => '"',
18
 
    apos => "\'",
19
 
};
20
 
ok( $data, 'Built data hash' );
21
 
 
22
 
# build XML string with quoted values
23
 
my $xmldata = "<data>\n";
24
 
foreach ( keys %{$data} ) {
25
 
    $xmldata .= "<$_>";
26
 
    $xmldata .= ( $data->{$_} =~ /[\&\<\>\"\']/ ) ? ( '&' . $_ . ';' ) : $data->{$_};
27
 
    $xmldata .= "</$_>";
28
 
}
29
 
$xmldata .= " < /data>\n";
30
 
 
31
 
ok( $xmldata, 'Built XML string' );
32
 
##diag( dump($xmldata) );
33
 
 
34
 
# parse the provided XML into a hash
35
 
my $hash = XML::Bare::xmlin($xmldata);
36
 
ok( $hash, 'Parsed XML string into hash' );
37
 
 
38
 
##diag( dump( { wanted => $data, got => $hash } ) );
39
 
 
40
 
is_deeply( $hash, $data, 'Data retreived is correct' );
41
 
 
42
 
done_testing;