Bump version to 0.12.0
[WWW-OrangeHRM-Client.git] / t / string2time_duration.t
blob673318ffba4fa1a977b59b61bc77fb7012e42197
1 use strict;
2 use warnings;
3 use Test::More tests => 15;
4 use DateTime::Duration;
6 BEGIN {
7     use_ok('WWW::OrangeHRM::Client', qw(string2time_duration));
10 ok(
11     !DateTime::Duration->compare(
12         string2time_duration('12:34'),
13         DateTime::Duration->new(hours=>12, minutes=>34)
14     ),
15     '12:34'
17 ok(
18     !DateTime::Duration->compare(
19         string2time_duration('12'),
20         DateTime::Duration->new(hours=>12, minutes=>00)
21     ),
22     '12 hours'
25 ok(
26     !DateTime::Duration->compare(
27         string2time_duration('01:02'),
28         DateTime::Duration->new(hours=>1, minutes=>2)
29     ),
30     '01:02'
33 ok(
34     !DateTime::Duration->compare(
35         string2time_duration('1:2'),
36         DateTime::Duration->new(hours=>1, minutes=>2)
37     ),
38     '1:2'
41 is(
42     string2time_duration('x1:2'),
43     'x1:2',
44     'x1:2'
47 is(
48     string2time_duration('x1:2', 1),
49     undef,
50     'strict x1:2'
53 is(
54     string2time_duration('1:x2'),
55     '1:x2',
56     '1:x2'
59 is(
60     string2time_duration('1:x2', 1),
61     undef,
62     'strict 1:x2'
65 is(
66     string2time_duration('x'),
67     'x',
68     'x'
71 is(
72     string2time_duration('x', 1),
73     undef,
74     'strict x'
77 ok(
78     !DateTime::Duration->compare(
79         string2time_duration(''),
80         DateTime::Duration->new(hours=>0, minutes=>0)
81     ),
82     'empty string'
85 ok(
86     !DateTime::Duration->compare(
87         string2time_duration('', 1),
88         DateTime::Duration->new(hours=>0, minutes=>0)
89     ),
90     'strict emptry string'
93 is(
94     string2time_duration(undef),
95     undef,
96     'undef'
99 is(
100     string2time_duration(undef, 1),
101     undef,
102     'strict undef'