You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
828 B
28 lines
828 B
use strict; |
|
use warnings; |
|
|
|
use Test::More tests => 19; |
|
|
|
use Subtitle::TimePoint; |
|
|
|
my $p = Subtitle::TimePoint->new; |
|
is(ref $p, 'Subtitle::TimePoint'); |
|
can_ok($p, qw(new parse time shift)); |
|
|
|
# valid timespec |
|
is($p->parse('0/0'), undef); |
|
is($p->time, 0.0), is($p->shift, 0.0); |
|
is($p->parse('0.3/0'), undef); |
|
is($p->time, 0.3), is($p->shift, 0.0); |
|
is($p->parse('1:17/-4.1'), undef); |
|
is($p->time, 77), is($p->shift, -4.1); |
|
is($p->parse('2:15:03.515/+3:02.7'), undef); |
|
is($p->time, 8103.515), is($p->shift, 182.7); |
|
# invalid timespec |
|
is($p->parse('0.3/-'), "wrong timespec, expected <time>/[+-]<time>, abort"); |
|
is($p->parse('1:17/-4.'), "can't parse time: -4."); |
|
is($p->parse(':47/-5.4'), "can't parse time: :47"); |
|
is($p->parse('1:1.2/-5'), "can't parse time: 1:1.2"); |
|
is($p->parse('5:31./7'), "can't parse time: 5:31."); |
|
|
|
1;
|
|
|