| 12
 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
 61
 62
 63
 64
 65
 
 | use strict;
use warnings;
use Test::More tests => 14;
use File::LibMagic qw( :complete );
# check for constants
my $fail = 0;
my @names = qw(
    MAGIC_CHECK MAGIC_COMPRESS MAGIC_CONTINUE MAGIC_DEBUG MAGIC_DEVICES
    MAGIC_ERROR MAGIC_MIME MAGIC_NONE MAGIC_PRESERVE_ATIME MAGIC_RAW
    MAGIC_SYMLINK
);
foreach my $constname (@names) {
    next if ( eval "my \$a = $constname; 1" );
    if ( $@ =~ /^Your vendor has not defined constants macro $constname/ ) {
        diag "pass: $@";
    }
    else {
        diag "fail: $@";
        $fail = 1;
    }
}
ok( $fail == 0 , 'Constants' );
# try loading a non-standard magic file
{
    my $handle = magic_open(MAGIC_NONE);
    magic_load( $handle, 't/samples/magic' );
    is( magic_buffer( $handle, "Hello World\n" ), 'ASCII text' );
    is( magic_buffer( $handle, "Footastic\n" ), 'A foo file' );
    is( magic_file( $handle, 't/samples/foo.txt' ), 'ASCII text'           );
    is( magic_file( $handle, 't/samples/foo.c'   ), 'ASCII C program text' );
    is( magic_file( $handle, 't/samples/foo.foo' ), 'A foo file' );
    magic_close($handle);
}
# test the traditional empty string for magic_load
{
    my $handle = magic_open(MAGIC_NONE);
    magic_load( $handle, q{} );
    is( magic_buffer( $handle, "Hello World\n" ), 'ASCII text' );
    is( magic_file( $handle, 't/samples/foo.txt' ), 'ASCII text'           );
    is( magic_file( $handle, 't/samples/foo.c'   ), 'ASCII C program text' );
    is( magic_file( $handle, 't/samples/foo.foo' ), 'ASCII text' );
    magic_close($handle);
}
# test undef as the filename for magic_load
{
    my $handle = magic_open(MAGIC_NONE);
    magic_load( $handle, undef );
    is( magic_buffer( $handle, "Hello World\n" ), 'ASCII text' );
    is( magic_file( $handle, 't/samples/foo.txt' ), 'ASCII text'           );
    is( magic_file( $handle, 't/samples/foo.c'   ), 'ASCII C program text' );
    is( magic_file( $handle, 't/samples/foo.foo' ), 'ASCII text' );
    magic_close($handle);
}
 |