You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
952 B
42 lines
952 B
6 years ago
|
use strict;
|
||
|
use warnings;
|
||
|
|
||
|
use Test::More tests => 62;
|
||
|
|
||
|
use Subtitle::SSA::File;
|
||
|
|
||
|
sub random_data {
|
||
|
my $data = '';
|
||
|
my $len = 100 + int(rand(100));
|
||
|
open my $FH, '<', '/dev/urandom'
|
||
|
or die "can't open: /dev/urandom -- $!\n";
|
||
|
read($FH, $data, $len);
|
||
|
close $FH;
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
my $file = Subtitle::SSA::File->new;
|
||
|
is(ref $file, 'Subtitle::SSA::File');
|
||
|
can_ok($file, qw(new error size type name parse_uue_line binary uue_line uue_block));
|
||
|
undef $file;
|
||
|
|
||
|
for (my $i = 0; $i < 15; $i++) {
|
||
|
my $bin = random_data();
|
||
|
$file = Subtitle::SSA::File->new;
|
||
|
$file->binary($bin);
|
||
|
is($file->size => length $bin);
|
||
|
my $uue = $file->uue_line;
|
||
|
isnt($uue, '');
|
||
|
ok(length($uue) % 4 != 1);
|
||
|
my $invalid = 0;
|
||
|
for my $char (split(//, $uue)) {
|
||
|
next if ord($char) >= 33 and ord($char) <= 96;
|
||
|
$invalid = 1;
|
||
|
diag sprintf("unexpected char in encoded text: %s (code 0x%02X)", $char, ord($char));
|
||
|
last;
|
||
|
}
|
||
|
is($invalid, 0);
|
||
|
}
|
||
|
|
||
|
exit 0;
|