my
$self
= {
'date'
=>
'20'
};
my
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '20' is right."
);
$self
= {
'date'
=>
'200'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '200' is right."
);
$self
= {
'date'
=>
'2000'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '2000' is right."
);
$self
= {
'date'
=>
'2000-01'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '2000-01' is right."
);
$self
= {
'date'
=>
'2000-1'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '2000-1' is right."
);
$self
= {
'date'
=>
'2000-01-01'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '2000-01-01' is right."
);
$self
= {
'date'
=>
'2000-01-1'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '2000-01-1' is right."
);
$self
= {
'date'
=>
'2000-1-1'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '2000-1-1' is right."
);
$self
= {
'date'
=>
'-20'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '-20' is right."
);
$self
= {
'date'
=>
'-200'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '-200' is right."
);
$self
= {
'date'
=>
'-2000'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '-2000' is right."
);
$self
= {
'date'
=>
'-2000-01'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '-2000-01' is right."
);
$self
= {
'date'
=>
'-2000-1'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '-2000-1' is right."
);
$self
= {
'date'
=>
'-2000-01-01'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '-2000-01-01' is right."
);
$self
= {
'date'
=>
'-2000-01-1'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '-2000-01-1' is right."
);
$self
= {
'date'
=>
'-2000-1-1'
};
$ret
= check_date(
$self
,
'date'
);
is(
$ret
,
undef
,
"Date '-2000-1-1' is right."
);
$self
= {
'date'
=>
'foo'
};
eval
{
check_date(
$self
,
'date'
);
};
is(
$EVAL_ERROR
,
"Parameter 'date' is in bad format.\n"
,
"Parameter 'date' is in bad format (foo)."
);
clean();
my
$actual_year
= DateTime->now->year;
$self
= {
'date'
=>
$actual_year
+ 1};
eval
{
check_date(
$self
,
'date'
);
};
is(
$EVAL_ERROR
,
"Parameter 'date' has year greater than actual year.\n"
,
"Parameter 'date' has year greater than actual year."
);
clean();