diff --git a/t/xmlrpc.t b/t/xmlrpc.t index 8ec2e3d55..c01d04b9e 100644 --- a/t/xmlrpc.t +++ b/t/xmlrpc.t @@ -110,6 +110,14 @@ subtest 'encode_xml_value type selection' => sub { # Plain strings. like(encode_xml_value('hello'), qr{^hello\s*$}, 'word -> string'); like(encode_xml_value(''), qr{^\s*$}, 'empty string -> empty '); + my @warnings; + my $undef_xml; + { + local $SIG{__WARN__} = sub { push(@warnings, @_); }; + $undef_xml = encode_xml_value(undef); + } + like($undef_xml, qr{^\s*$}, 'undef -> empty '); + is_deeply(\@warnings, [], 'undef emits no warnings'); # A value with control characters cannot live in a (the # printable-range regex fails), so it must fall through to base64. @@ -189,6 +197,19 @@ subtest 'parse_xml_value' => sub { is(parse_xml_value(value_tree('1')),1, 'boolean parsed'); is(parse_xml_value(value_tree('2.5')),'2.5', 'double parsed'); is(parse_xml_value(value_tree('hi')), 'hi', 'string parsed'); + my @warnings; + { + local $SIG{__WARN__} = sub { push(@warnings, @_); }; + is(parse_xml_value(value_tree('')), '', + 'empty string parsed'); + is(parse_xml_value(value_tree('')), '', 'implicit empty string parsed'); + is(parse_xml_value(value_tree('')), '', + 'empty base64 parsed'); + my $empty_name = parse_xml_value(value_tree( + 'x')); + is_deeply($empty_name, { '' => 'x' }, 'empty struct member name parsed'); + } + is_deeply(\@warnings, [], 'empty XML values emit no warnings'); # base64 is decoded back to its raw bytes. my $b64 = encode_base64("ab\x00cd");