Alex 'AdUser' Z
9 years ago
3 changed files with 105 additions and 50 deletions
@ -0,0 +1,44 @@
|
||||
use strict; |
||||
use warnings; |
||||
|
||||
use Test::More tests => 11; |
||||
|
||||
use Subtitle::Utils qw(:timing); |
||||
|
||||
my ($timing, $time); |
||||
|
||||
$timing = "123:11:15.459"; |
||||
$time = parse_timing($timing); |
||||
is($time, (123 * 3600 + 11 * 60 + 15 + 0.459)); |
||||
|
||||
$timing = "123:11:15.45"; |
||||
$time = parse_timing($timing); |
||||
is($time, (123 * 3600 + 11 * 60 + 15 + 0.450)); |
||||
|
||||
$timing = "123:11:15.4"; |
||||
$time = parse_timing($timing); |
||||
is($time, (123 * 3600 + 11 * 60 + 15 + 0.400)); |
||||
|
||||
$timing = "123:11:15,4"; |
||||
$time = parse_timing($timing); |
||||
is($time, (123 * 3600 + 11 * 60 + 15 + 0.400)); |
||||
|
||||
$timing = "123:60:15.45"; |
||||
$time = parse_timing($timing); |
||||
is($time, -1); |
||||
|
||||
$timing = "123:11:65.45"; |
||||
$time = parse_timing($timing); |
||||
is($time, -1); |
||||
|
||||
$timing = "123:11:15.4500"; |
||||
$time = parse_timing($timing); |
||||
is($time, -1); |
||||
|
||||
my ($hrs, $min, $sec, $msec); |
||||
|
||||
($hrs, $min, $sec, $msec) = make_timing(8 * 3600 + 11 * 60 + 15 + 0.46); |
||||
is($hrs, 8); |
||||
is($min, 11); |
||||
is($sec, 15); |
||||
is($msec, 460); |
Loading…
Reference in new issue