From 6edf544cd7f5be63311967a74966381f974fdd6e Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Wed, 6 Jul 2016 17:29:42 +1000 Subject: [PATCH] * t/format-ssa-header.t --- t/format-ssa-header.t | 52 ++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/t/format-ssa-header.t b/t/format-ssa-header.t index 0c1b3f9..1c0e6ab 100644 --- a/t/format-ssa-header.t +++ b/t/format-ssa-header.t @@ -1,13 +1,11 @@ use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 43; use Subtitle::SSA::Header; -my (@lines, $header, $sample); - -$sample = <<"EOF"; +my $sample = <<"EOF"; [Script Info] ; Script generated by Aegisub 2.1.9 ; http://www.aegisub.org/ @@ -27,35 +25,22 @@ Last Style Storage: Some style Audio File: ?video EOF -$header = Subtitle::SSA::Header->new(version => 'ssa'); -@lines = split /\n/, $sample; -diag scalar @lines; -shift @lines; # skip header +my @headers; +my @lines = split /\n/, $sample; +splice @lines, 0, 3; # skip section header and comments 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"; -[Script Info] -; generated with Subtitle::SSA -ScriptType: v4.00+ Title: Some title +ScriptType: v4.00+ WrapStyle: 0 PlayResX: 1280 PlayResY: 720 @@ -68,13 +53,14 @@ Original Editing: Some corrector Collisions: Normal Last Style Storage: Some style Audio File: ?video - 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); -write_file('a.txt', $sample); -write_file('b.txt', $header->to_string()); +is($sample => $out); exit 0;