"Fossies" - the Fresh Open Source Software Archive

Member "MIME-Types-2.22/t/21accept.t" (9 Dec 2020, 728 Bytes) of package /linux/privat/MIME-Types-2.22.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env perl
    2 #
    3 # Test httpAccept()
    4 #
    5 
    6 use strict;
    7 use warnings;
    8 
    9 use Test::More tests => 9;
   10 
   11 use lib qw(lib t);
   12 
   13 use MIME::Types;
   14 
   15 my $a = MIME::Types->new;
   16 ok(defined $a);
   17 
   18 # simpelest case
   19 my @t1 = $a->httpAccept('text/html');
   20 cmp_ok(scalar @t1, '==', 1, 'simpelest case');
   21 is($t1[0], 'text/html');
   22 
   23 # more than one
   24 my @t2 = $a->httpAccept('text/html, text/aap, text/noot');
   25 cmp_ok(scalar @t2, '==', 3, 'more than one');
   26 is($t2[0], 'text/html', 'order must be kept');
   27 is($t2[1], 'text/aap');
   28 is($t2[2], 'text/noot');
   29 
   30 # with quality
   31 
   32 my @t3 = $a->httpAccept('*/*, text/*,text/aap, text/noot;q=3, text/mies;q=0.1');
   33 cmp_ok(scalar @t3, '==', 5, 'quality');
   34 is(join('#',@t3), 'text/noot#text/aap#text/*#*/*#text/mies');
   35 
   36