File: ref.t

package info (click to toggle)
libkiokudb-perl 0.57-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,396 kB
  • sloc: perl: 13,314; makefile: 12
file content (40 lines) | stat: -rw-r--r-- 785 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

use Storable qw(nfreeze thaw);

use KiokuDB::Reference;

foreach my $id (
    "foo",
    123,
    "la-la",
    "3B19C598-E873-4C65-80BA-0D1C4E961DC9",
    "9170dc3d7a22403e11ff4c8aa1cd14d20c0ebf65",
    pack("H*", "9170dc3d7a22403e11ff4c8aa1cd14d20c0ebf65"),
    "foo,bar",
) {
    foreach my $weak ( 1, 0, '', undef ) {
        my $ref = KiokuDB::Reference->new(
            id => $id,
            defined($weak) ? ( weak => $weak ) : (),
        );

        is( $ref->id, $id, "ID in constructor" );

        my $f = nfreeze($ref);

        isa_ok( my $copy = thaw($f), "KiokuDB::Reference", "thaw" );

        is( $copy->id, $id, "ID after thaw" );

        is_deeply( $copy, $ref, "eq deeply" );
    }
}


done_testing;