File: 2-easy.t

package info (click to toggle)
libfile-libmagic-perl 0.96-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 232 kB
  • sloc: perl: 290; pascal: 88; ansic: 54; makefile: 13
file content (23 lines) | stat: -rw-r--r-- 680 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;
use warnings;
use Test::More tests => 6;

use File::LibMagic qw( :easy );

is( MagicBuffer("Hello World\n"),   'ASCII text'           );

is( MagicFile('t/samples/foo.txt'), 'ASCII text'           );
is( MagicFile('t/samples/foo.c'  ), 'C source, ASCII text' );

# check the error handling
eval { MagicBuffer(undef) };
like( $@, qr{MagicBuffer requires defined content}, 'MagicBuffer(undef)' );

eval { MagicFile(undef) };
like( $@, qr{MagicFile requires a filename}, 'MagicFile(undef)' );

TODO: {
    local $TODO = 'check libmagic version';
    eval { MagicFile('t/samples/missing') };
    like( $@, qr{libmagic cannot open .+ at .+}, 'MagicFile: missing file' );
}