File: undef_round_trip.t

package info (click to toggle)
libbson-xs-perl 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,708 kB
  • sloc: ansic: 9,734; perl: 1,049; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (7)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use strict;
use warnings;

use Test::More;
use lib 't/lib';
use lib 't/pvtlib';
use CleanEnv;

use BSON;
use Tie::IxHash;

my $c = BSON->new;

# PERL-543 deflation to BSON then back (via database?) caused undef to be an empty string

subtest 'tied Tie::IxHash' => sub {
  my %h;
  tie( %h, 'Tie::IxHash', h => undef );

  my $bin = $c->encode_one( \%h );
  my $doc = $c->decode_one( $bin );

  is $doc->{h}, undef, 'round trip undef';
};

subtest 'OO Tie::IxHash' => sub {
  my $h = Tie::IxHash->new( h => undef );

  my $bin = $c->encode_one( $h );
  my $doc = $c->decode_one( $bin );

  is $doc->{h}, undef, 'round trip undef';
};

subtest 'standard hash' => sub {
  my %doc = ( h => undef );

  my $bin = $c->encode_one( \%doc );
  my $doc = $c->decode_one( $bin );

  is $doc->{h}, undef, 'round trip undef';
};

done_testing;