From da79b7833b1956c02a51af81efceff81436c2ad9 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sat, 11 Jun 2016 17:08:40 +0000 Subject: [PATCH] + t/format-msub.t --- t/format-msub.t | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 t/format-msub.t diff --git a/t/format-msub.t b/t/format-msub.t new file mode 100644 index 0000000..e90ec9f --- /dev/null +++ b/t/format-msub.t @@ -0,0 +1,29 @@ +use strict; +use warnings; + +use Test::More tests => 9; + +use Subtitle::MSub; + +my $msub = Subtitle::MSub->new(debug => 1); +is(ref $msub, 'Subtitle::MSub'); +can_ok($msub, qw(new parse)); + +my $sample = <<"EOF"; +{1}{1} 15.0 +{30}{45} Test event +{45}{60} Test event|with line wrap + +EOF +my @lines = split(/[\r\n]+/, $sample); +my $cnt = $msub->parse(\@lines); +is($cnt, 2); +my @events = @{ $msub->{events} }; +is($events[0]->{timing}->[0], 2.0); +is($events[0]->{timing}->[1], 3.0); +is($events[0]->{text}, "Test event"); +is($events[1]->{timing}->[0], 3.0); +is($events[1]->{timing}->[1], 4.0); +is($events[1]->{text}, "Test event\nwith line wrap"); + +exit 0;