File: 0-test.t

package info (click to toggle)
libencode-imaputf7-perl 1.07-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 188 kB
  • sloc: perl: 245; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 784 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
24
25
26
27
28
29
30
31
32
33
#!perl
use strict;
use warnings;

use Test::More tests => 2;
use Test::NoWarnings;

use Encode;
use Encode::IMAPUTF7;

use File::Spec;
use File::Basename;

my $dir = dirname(__FILE__);
opendir my $dh, $dir or die "$dir:$!";
my @file = sort grep {/\.utf$/o} readdir $dh;
closedir $dh;
for my $file (@file){
    my $path = File::Spec->catfile($dir, $file);
    open my $fh, '<', $path or die "$path:$!";
    my $content;
    if (PerlIO::Layer->find('perlio')){
        binmode $fh => ':utf8';
        $content = join('' => <$fh>);
    } else { # ugh!
        binmode $fh;
        $content = join('' => <$fh>);
        Encode::_utf8_on($content)
    }
    close $fh;
    is(Encode::decode("IMAP-UTF-7", Encode::encode("IMAP-UTF-7", $content)), $content,
       "IMAP-UTF-7 RT:$file");
}