use strict; use warnings; use Test::More tests => 11; use Subtitle::Utils qw(:timing); ## parse_timing() # valid timecodes is(parse_timing('123:11:15.459'), (123 * 3600 + 11 * 60 + 15 + 0.459)); is(parse_timing('123:11:15.45'), (123 * 3600 + 11 * 60 + 15 + 0.450)); is(parse_timing('123:11:15.4'), (123 * 3600 + 11 * 60 + 15 + 0.400)); is(parse_timing('123:11:15,4'), (123 * 3600 + 11 * 60 + 15 + 0.400)); # invalid timecodes is(parse_timing('123:60:15.45'), -1); is(parse_timing('123:11:65.45'), -1); is(parse_timing('123:11:15.4500'), -1); ## make_timing() my @ts = make_timing(8*3600 + 11*60 + 15 + 0.46); is($ts[0], 8); is($ts[1], 11); is($ts[2], 15); is($ts[3], 460);