Debian Codegraph @

t/message-decode-xml.t

raw
1 # https://rt.cpan.org/Public/Bug/Display.html?id=52572
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 plan tests => 2;
8
9 use Encode qw( encode );
10 use HTTP::Headers qw( );
11 use HTTP::Response qw( );
12 use PerlIO::encoding qw( );
13
14 {
15 my $builder = Test::More->builder;
16 local $PerlIO::encoding::fallback = Encode::PERLQQ();
17 binmode $builder->output, ":encoding(US-ASCII)";
18 binmode $builder->failure_output, ":encoding(US-ASCII)";
19 binmode $builder->todo_output, ":encoding(US-ASCII)";
20 }
21
22 for my $enc (qw( UTF-8 UTF-16le )) {
23 my $file = encode($enc,
24 ($enc =~ /^UTF-/ ? "\x{FEFF}" : "") .
25 qq{<?xml version="1.0" encoding="$enc"?>\n} .
26 qq{<root>\x{C9}ric</root>\n}
27 );
28
29 my $headers = HTTP::Headers->new(Content_Type => "application/xml");
30 my $response = HTTP::Response->new(200, "OK", $headers, $file);
31
32 is($response->decoded_content, qq(<?xml version="1.0"?>\n<root>\x{c9}ric</root>\n), $enc);
33 }