File: 01_parse.t

package info (click to toggle)
libxml-treepp-perl 0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 680 kB
  • sloc: perl: 810; xml: 58; sh: 41; makefile: 2
file content (21 lines) | stat: -rwxr-xr-x 773 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# ----------------------------------------------------------------
    use strict;
    use Test::More tests => 4;
    BEGIN { use_ok('XML::TreePP') };
# ----------------------------------------------------------------
    my $tpp = XML::TreePP->new();
    my $source = '<root attr="AAA">BBB</root>';
    my $tree = $tpp->parse( $source );

    is( $tree->{root}->{"#text"}, "BBB", "text node" );
    is( $tree->{root}->{"-attr"}, "AAA", "attributes" );

    my $back = $tpp->write( $tree );
    my $test = $source;
    $back =~ s/\s+//sg;
    $back =~ s/<\?.*?\?>//s;
    $test =~ s/\s+//sg;
    is( $back, $test, "parse and write" );
# ----------------------------------------------------------------
;1;
# ----------------------------------------------------------------