Data-BISON
view release on metacpan or search on metacpan
t/40.roundtrip.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Data::BISON::Encoder;
use Data::BISON::Decoder;
use Data::BISON::yEnc qw(encode_yEnc decode_yEnc);
use Data::Dumper;
use Test::More;
my @tests;
BEGIN {
my $struct = {
unicode => 'Ï',
nums => [ -1, 12345678, 1.25 ],
nested => {
hash => { slashed => '\\\\\\' },
array => [ [], [], {} ],
},
};
my $no_float = {
unicode => 'Ï',
nums => [ -1, 12345678, 0 ],
nested => {
hash => { name => '\\\\\\' },
array => [ [], [], {} ],
},
};
my $deeper = {
struct => $struct,
no_float => $no_float,
};
@tests = (
{
name => 'Simple roundtrip',
input => $no_float,
enc_args => {},
dec_args => {},
filter => sub { return shift },
},
{
name => 'With floats',
input => $struct,
enc_args => {},
dec_args => {},
filter => sub { return shift },
},
{
name => 'Deeper',
input => $deeper,
enc_args => {},
dec_args => {},
filter => sub { return shift },
},
{
name => 'Encoded with yEnc',
input => $deeper,
enc_args => { yenc => 1 },
dec_args => {},
filter => sub { return shift },
},
{
name => 'Encoded afer yEnc',
input => $deeper,
enc_args => {},
dec_args => {},
filter => sub { return encode_yEnc( shift ) },
},
{
name => 'Deeper w/doubles',
input => $deeper,
enc_args => { double => 1 },
dec_args => {},
filter => sub { return shift },
},
);
plan tests => 6 * @tests;
}
( run in 2.693 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )