File: 02_roundtrip.t

package info (click to toggle)
libtime-duration-parse-perl 0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: perl: 40; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;
use Test::More 0.88;
use Time::Duration::Parse;

eval { require Time::Duration };
if ($@) {
    plan skip_all => 'Time::Duration is required';
}

plan tests => 2000;

my @tests = map int rand(100_000), 1..1000;

for my $test (@tests) {
    my $spec = Time::Duration::duration_exact($test);
    is parse_duration($spec), $test, "$spec - $test";
}

for my $test (@tests) {
    my $spec = Time::Duration::concise(Time::Duration::duration_exact($test));
    is parse_duration($spec), $test, "$spec - $test";
}