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;