| 1 |
package main; |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
use Test::More tests => 3; |
| 6 |
use Data::Dumper; |
| 7 |
$Data::Dumper::Indent = 0; |
| 8 |
$Data::Dumper::Sortkeys = 1; |
| 9 |
|
| 10 |
use XML::Hash::XS 'xml2hash'; |
| 11 |
$XML::Hash::XS::keep_root = 0; |
| 12 |
|
| 13 |
our $xml_decl_utf8 = qq{<?xml version="1.0" encoding="utf-8"?>}; |
| 14 |
|
| 15 |
{ |
| 16 |
is |
| 17 |
Dumper(xml2hash("<root><node> </node><node_with_attr attr=\" \"/></root>", suppress_empty => 0)), |
| 18 |
Dumper({node => ' ', node_with_attr => {attr => ' '}}), |
| 19 |
'don`t suppress empty nodes', |
| 20 |
; |
| 21 |
} |
| 22 |
|
| 23 |
{ |
| 24 |
is |
| 25 |
Dumper(xml2hash("<root><node> </node><node_with_attr attr=\" \"/></root>", suppress_empty => '')), |
| 26 |
Dumper({node => '', node_with_attr => {attr => ''}}), |
| 27 |
'suppress empty nodes to empty string', |
| 28 |
; |
| 29 |
} |
| 30 |
|
| 31 |
{ |
| 32 |
is |
| 33 |
Dumper(xml2hash("<root><node> </node><node_with_attr attr=\" \"/></root>", suppress_empty => undef)), |
| 34 |
Dumper({node => undef, node_with_attr => {attr => undef}}), |
| 35 |
'suppress empty nodes to undefined value', |
| 36 |
; |
| 37 |
} |