use
5.014;
subtest
'String'
=>
sub
{
my
$header
= ZMQx::RPC::Header->new(
type
=>
'string'
);
my
$msg
= ZMQx::RPC::Message->new(
header
=>
$header
);
my
$test
= [
'abc'
,
chr
(0x05d0) ];
my
$encoded
=
$msg
->_encode_payload(
$test
);
my
$decoded
=
$msg
->_decode_payload(
$encoded
);
cmp_deeply(
$test
,
$decoded
,
"Payload matches initial / enjoying perl unicode"
);
utf8::upgrade(
$_
)
foreach
(
@$test
);
cmp_deeply(
$test
,
$decoded
,
"Payload matches initial / real match"
);
};
subtest
'Raw'
=>
sub
{
my
$header
= ZMQx::RPC::Header->new(
type
=>
'raw'
);
my
$msg
= ZMQx::RPC::Message->new(
header
=>
$header
);
my
$test
= [
'abc'
,
chr
(0x05d0) ];
my
$raw
= encode_json(
$test
);
my
$encoded
=
$msg
->_encode_payload( [
$raw
] );
my
$decoded
=
$msg
->_decode_payload(
$encoded
);
my
$returned
= decode_json(
$decoded
->[0] );
cmp_deeply(
$test
,
$returned
,
"Payload matches initial"
);
};
subtest
'JSON'
=>
sub
{
my
$header
= ZMQx::RPC::Header->new(
type
=>
'JSON'
);
my
$msg
= ZMQx::RPC::Message->new(
header
=>
$header
);
my
$test
= [ [
'abc'
,
chr
(0x05d0) ] ];
my
$encoded
=
$msg
->_encode_payload(
$test
);
my
$decoded
=
$msg
->_decode_payload(
$encoded
);
cmp_deeply(
$test
,
$decoded
,
"Payload matches initial"
);
};
done_testing();
1;