summaryrefslogtreecommitdiff
path: root/t/02_magic.t
blob: 5108d97766712c007ea4f8a9510b0ecb0c25eaf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require Test::More;

no warnings;
@File::MimeInfo::DIRS = ('./t/mime'); # forceing non default value
#$File::MimeInfo::DEBUG = 1;

opendir MAGIC, 't/magic/';
my @files = grep {$_ !~ /^\./} readdir MAGIC;
closedir MAGIC;

Test::More->import( tests => (2 * scalar(@files) + 1) );

use_ok('File::MimeInfo::Magic', qw/mimetype magic/);

for (@files) {
	$type = $_;
	$type =~ tr#_#/#;
	$type =~ s#\.\w+$##;
	ok( mimetype("t/magic/$_") eq $type, "complete (magic) typing of $_");
	undef $type if $type eq "text/plain" || $type eq "application/octet-stream";
	ok( magic("t/magic/$_") eq $type, "magic typing of $_" );
}