File: 30346.t

package info (click to toggle)
libtest-file-perl 1.41-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 244 kB
  • ctags: 54
  • sloc: perl: 986; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,186 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
use strict;

use Test::Builder::Tester;
use Test::More 0.95;

use_ok( 'Test::File' );

use Cwd;

require 't/setup_common';

subtest file_does_not_exist => sub {
	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 );
	};

subtest file_exists_non_zero => sub {
	my $file = 'min_file';
	diag( "File is $file with size " . (-s $file) . " bytes" );
	
	my $name = "$file is not empty";
	test_out( "ok 1 - $name");
	file_not_empty_ok( $file );
	test_test( $name );
	};

subtest file_exists_zero_size => sub {
	require File::Spec;
	my $file = '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;
	};

done_testing();