File: util-checksum-yaml-xs.t

package info (click to toggle)
libjson-validator-perl 5.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,160 kB
  • sloc: perl: 3,015; makefile: 14
file content (30 lines) | stat: -rw-r--r-- 1,143 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
BEGIN {
  unshift @INC, sub {
    my $file = $_[1];
    die "Skipping $file in this test" if $file =~ m!Sereal\W+Encoder\.pm$!;
  };
}

use Mojo::Util 'md5_sum';
use JSON::Validator;
use JSON::Validator::Util qw(data_checksum);
use Test::More;

my $d_hash  = {foo => {}, bar => {}};
my $d_hash2 = {bar => {}, foo => {}};
my $d_undef = {foo => undef};
my $d_obj   = {foo => JSON::Validator::Error->new};
my $d_array  = ['foo', 'bar'];
my $d_array2 = ['bar', 'foo'];

ok !$INC{'Sereal/Encoder.pm'}, 'Sereal::Encoder was not loaded';

isnt data_checksum($d_array), data_checksum($d_array2), 'data_checksum array';
is data_checksum($d_hash),    data_checksum($d_hash2),  'data_checksum hash field order';
isnt data_checksum($d_hash),  data_checksum($d_undef),  'data_checksum hash not undef';
isnt data_checksum($d_hash),  data_checksum($d_obj),    'data_checksum hash not object';
isnt data_checksum($d_obj),   data_checksum($d_undef),  'data_checksum object not undef';
isnt data_checksum(3.14), md5_sum(3.15),         'data_checksum numeric';
is data_checksum(3.14),   data_checksum('3.14'), 'data_checksum numeric like string';

done_testing;