summaryrefslogtreecommitdiff
path: root/fml/lib/IO/t/file_sequence_increment.pl
blob: 6ac196a26baa6bb79deced93cd764d96c9a37989 (plain)
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
#-*- perl -*-
#
#  Copyright (C) 2004 Ken'ichi Fukamachi
#   All rights reserved. This program is free software; you can
#   redistribute it and/or modify it under the same terms as Perl itself.
#
# $FML: sequence.pl,v 1.1 2004/04/11 12:58:40 fukachan Exp $
#

use strict;
use Carp;

my $debug = 0;
my $i     = 0;
my $file  = "/tmp/io.$$";
my $map   = "file:$file";
my %log   = ();
my %pid   = ();
my $fail  = 0;
my $reason = '';

use FML::Test::Utils;
my $tool = new FML::Test::Utils;
$tool->set_title("file sequence increment");

use IO::Adapter;

for my $i (0 .. 5) {
    my $obj = new IO::Adapter $map;
    my $id  = $obj->sequence_increment();

    unless ($id == ($i + 1)) {
	$reason .= "wrong sequence returned";
	$reason .= "\t\n";
	$fail++;
    }

    if ($obj->error()) {
	$reason .= $obj->error();
	$reason .= "\t\n";
	$fail++;
    }
}

if ($fail) {
    $tool->print_error($reason);
}
else {
    $tool->print_ok();
}

exit 0;