From 014eabe9ccfb29ea798f6c4012d7059bef567631 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sun, 12 Jun 2016 11:55:00 +0000 Subject: [PATCH] + t/format-srt.t --- t/format-srt.t | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 t/format-srt.t diff --git a/t/format-srt.t b/t/format-srt.t new file mode 100644 index 0000000..f4c3530 --- /dev/null +++ b/t/format-srt.t @@ -0,0 +1,36 @@ +use strict; +use warnings; + +use Test::More tests => 9; + +use Subtitle::SRT; + +my $srt = Subtitle::SRT->new(debug => 1); +is(ref $srt, 'Subtitle::SRT'); +can_ok($srt, qw(new parse)); + +my $sample = <<"EOF"; +1 +00:00:00,100 --> 00:00:08,000 +kirari hikaru yume o taisetsu ni dakishimete + + +2 +00:00:08,100 --> 00:00:12,000 +ippo dzutsu aruite yukou + +EOF + +my @lines = split(/\r?\n/, $sample); +my $cnt = $srt->parse(\@lines); +is($cnt, 2); + +my @events = @{ $srt->{events} }; +is($events[0]->{timing}->[0], 0.1); +is($events[0]->{timing}->[1], 8.0); +is($events[0]->{text}, "kirari hikaru yume o taisetsu ni dakishimete\n"); +is($events[1]->{timing}->[0], 8.1); +is($events[1]->{timing}->[1], 12.0); +is($events[1]->{text}, "ippo dzutsu aruite yukou\n"); + +exit 0;