#!perl
BEGIN
{
our
$DEBUG
=
exists
(
$ENV
{AUTHOR_TESTING} ) ?
$ENV
{AUTHOR_TESTING} : 0;
};
my
$f
= file( __FILE__ )->parent->child(
'testin/mignonne-ronsard.txt'
);
my
$check
= file( __FILE__ )->parent->child(
'testin/mignonne-ronsard.txt.qp'
)->load;
my
$str
=
$f
->load;
diag(
"String is:\n$str"
)
if
(
$DEBUG
);
my
$s
= HTTP::Promise::Stream::QuotedPrint->new(
debug
=>
$DEBUG
);
isa_ok(
$s
=> [
'HTTP::Promise::Stream::QuotedPrint'
] );
my
$enc
= Module::Generic::Scalar->new;
my
$rv
=
$s
->encode(
$f
=>
$enc
,
eol
=>
"\012"
);
diag(
"QuotedPrint text is:\n$enc"
)
if
(
$DEBUG
);
is(
"$enc"
=>
$check
);
my
$dec
= Module::Generic::Scalar->new;
my
$dec_io
=
$dec
->
open
(
'>'
);
$s
->decode(
$enc
=>
$dec_io
);
is(
"$dec"
=>
$str
);
done_testing();