File: 30346.t

package info (click to toggle)
libtest-file-perl 1.29-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 180 kB
  • ctags: 40
  • sloc: perl: 771; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 1,037 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use strict;

use Test::Builder::Tester;
use Test::More tests => 3;

use Test::File;

use Cwd;

# File does not exist
{
my $file = "no_such_file-" . "$$" . time() . "b$<$>m";

unlink $file;

my $name = "$file is not empty";
test_out( "not ok 1 - $name");
test_diag( 
	"File [$file] does not exist!\n" .
	"#   Failed test '$name'\n". 
	"#   at $0 line " . line_num(+5) . "." 
	);
file_not_empty_ok( $file );
test_test( $name );
}



# File exists, non zero size
{
my $file = $0; # hey, that's me!

my $name = "$file is not empty";
test_out( "ok 1 - $name");
file_not_empty_ok( $file );
test_test( $name );
}



# File exists, zero size
{
require File::Spec;
my $file = File::Spec->catfile( qw(t rt file_not_empty_ok_test) );
open my $fh, ">", $file;
truncate $fh, 0;
close $fh;

my $name = "$file is not empty";
test_out( "not ok 1 - $name");
test_diag( 
	"File [$file] exists with zero size!\n" .
	"#   Failed test '$name'\n". 
	"#   at $0 line " . line_num(+5) . "." 
	);
file_not_empty_ok( $file );
test_test( $name );

unlink $file;
}