Browse Source

* t/format-ssa-header.t

master
Alex 'AdUser' Z 9 years ago
parent
commit
6edf544cd7
  1. 52
      t/format-ssa-header.t

52
t/format-ssa-header.t

@ -1,13 +1,11 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 32; use Test::More tests => 43;
use Subtitle::SSA::Header; use Subtitle::SSA::Header;
my (@lines, $header, $sample); my $sample = <<"EOF";
$sample = <<"EOF";
[Script Info] [Script Info]
; Script generated by Aegisub 2.1.9 ; Script generated by Aegisub 2.1.9
; http://www.aegisub.org/ ; http://www.aegisub.org/
@ -27,35 +25,22 @@ Last Style Storage: Some style
Audio File: ?video Audio File: ?video
EOF EOF
$header = Subtitle::SSA::Header->new(version => 'ssa'); my @headers;
@lines = split /\n/, $sample; my @lines = split /\n/, $sample;
diag scalar @lines; splice @lines, 0, 3; # skip section header and comments
shift @lines; # skip header
foreach my $line (@lines) { foreach my $line (@lines) {
ok($header->parse($line), 'line parsing'); my $header = Subtitle::SSA::Header->new;
ok($header->parse($line), "line parsing");
my ($name, $value) = split(": ", $line, 2);
is($header->{name} => $name);
is($header->{value} => $value);
my $key = $header->hash_key();
push @headers, $header;
} }
is($header->get('ScriptType') => 'v4.00+');
is($header->get('Title') => 'Some title');
is($header->get('WrapStyle') => 0);
is($header->get('PlayResX') => 1280);
is($header->get('PlayResY') => 720);
is($header->get('ScaledBorderAndShadow') => 'yes');
is($header->get('Video Aspect Ratio') => 0);
is($header->get('Video Zoom') => 4);
is($header->get('Video Position') => 11787);
is($header->get('Original Translation') => 'Some author');
is($header->get('Original Editing') => 'Some corrector');
is($header->get('Collisions') => 'Normal');
is($header->get('Last Style Storage') => 'Some style');
is($header->get('Audio File') => '?video');
is($header->{_vers} => 'ass'); # changed with ScriptType
$sample = <<"EOF"; $sample = <<"EOF";
[Script Info]
; generated with Subtitle::SSA
ScriptType: v4.00+
Title: Some title Title: Some title
ScriptType: v4.00+
WrapStyle: 0 WrapStyle: 0
PlayResX: 1280 PlayResX: 1280
PlayResY: 720 PlayResY: 720
@ -68,13 +53,14 @@ Original Editing: Some corrector
Collisions: Normal Collisions: Normal
Last Style Storage: Some style Last Style Storage: Some style
Audio File: ?video Audio File: ?video
EOF EOF
is($sample => $header->to_string()); @lines = ();
foreach my $h (@headers) {
push @lines, $h->to_string();
}
my $out = join("\n" => @lines) . "\n";
use File::Slurp qw(write_file); is($sample => $out);
write_file('a.txt', $sample);
write_file('b.txt', $header->to_string());
exit 0; exit 0;

Loading…
Cancel
Save