File: 01-simple.t.save

package info (click to toggle)
libfile-queue-perl 1.01a-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 116 kB
  • sloc: perl: 235; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 1,428 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!perl -T

use strict;
use Storable qw/freeze/;
use File::Queue;

use Test::Simple tests => 3;

my $queue_file = "t/rw/test_queue_$$";

my $struct =
[
  'text element 0, text element 0, text element 0, text element 0',
  'text element 1, text element 1, text element 1, text element 1',
  'text element 2, text element 2, text element 2, text element 2',
  'text element 3, text element 3, text element 3, text element 3',
  'text element 4, text element 4, text element 4, text element 4',
  'text element 5, text element 5, text element 5, text element 5',
  'text element 6, text element 6, text element 6, text element 6',
  'text element 7, text element 7, text element 7, text element 7',
  'text element 8, text element 8, text element 8, text element 8',
  'text element 9, text element 9, text element 9, text element 9',
];

my $q = File::Queue->new(File => $queue_file);

foreach my $elem (@$struct)
{
  $q->enq($elem);
}

$q->close;

$q = File::Queue->new(File => $queue_file);

my $peeked = $q->peek(scalar @$struct);

ok(freeze($struct) eq freeze($peeked), 'Checking struct vs peeked');

$q->close;

$q = File::Queue->new(File => $queue_file);

my $deqed;
while(my $elem = $q->deq())
{
  push @$deqed, $elem;
}

ok(freeze($struct) eq freeze($deqed), 'Checking struct vs deqed');

my $delete_success = 1;
eval
{
  $q->delete();
};
if($@)
{
  $delete_success = 0;
}

ok($delete_success, 'Checking delete function');