cvs: pecl /date/tests 009.phpt 010.phpt
| From: | Pierre-Alain Joye | Date: | Fri, 09 Jan 2004 13:50:49 +0000 |
| Subject: | cvs: pecl /date/tests 009.phpt 010.phpt | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-701@lists.php.net to get a copy of this message | ||
pajoye Fri Jan 9 08:50:49 2004 EDT
Added files:
/pecl/date/tests 009.phpt 010.phpt
Log:
- Add arythmetic operations tests, days and months
Index: pecl/date/tests/009.phpt
+++ pecl/date/tests/009.phpt
--TEST--
Check arythmetic operations: days
--SKIPIF--
<?php dl('date.so'); if (!extension_loaded("date_time")) print
"skip"; ?>
--POST--
--GET--
--INI--
--FILE--
<?php
function date_dump($d)
{
echo date_get_day($d);
echo " ";
echo date_get_month($d);
echo " ";
echo date_get_year($d);
echo "\n";
}
if (!extension_loaded("date_time")) dl('date.so');
if (!function_exists('date_new')) {
echo "date extension not available.\n";
}
$dates = array(
array(1,array(3,1,1964),array(4,1,1964)),
array(1,array(13,11,1995),array(14,11,1995)),
array(-1,array(16,11,1995),array(15,11,1995),),
array(3,array(17,11,1995),array(20,11,1995)),
array(-3,array(20,11,1995),array(17,11,1995)),
array(1,array(28,2,1995),array(1,3,1995)),
array(11642,array(3,1,1964),array(18,11,1995)),
array(-11642,array(18,11,1995),array(3,1,1964))
);
$d = date_new();
/* add */
echo "*** add\n";
foreach ($dates as $date) {
$offset = $date[0];
$date1 = $date[1];
$rdate = $date[2];
date_set_dmy($d,$date1[0],$date1[1],$date1[2]);
date_add_days($d,$offset);
if (date_get_day($d) != $rdate[0] || date_get_month($d) != $rdate[1] || date_get_year($d) !=
$rdate[2] ) {
echo implode('/',$date1)."Failed.\n";
}
}
/* sub */
echo "*** sub\n";
foreach ($dates as $date) {
$offset = $date[0];
$date1 = $date[2];
$rdate = $date[1];
date_set_dmy($d,$date1[0],$date1[1],$date1[2]);
date_sub_days($d,$offset);
if ( (date_get_day($d) != $rdate[0]) || (date_get_month($d) != $rdate[1]) || (date_get_year($d) !=
$rdate[2]) ) {
echo implode('/',$date1)." Failed.\n";
}
}
echo "Done.\n";
?>
--EXPECT--
*** add
*** sub
Done.
Index: pecl/date/tests/010.phpt
+++ pecl/date/tests/010.phpt
--TEST--
Check arythmetic operations: months
--SKIPIF--
<?php dl('date.so'); if (!extension_loaded("date_time")) print
"skip"; ?>
--POST--
--GET--
--INI--
--FILE--
<?php
function date_dump($d)
{
echo date_get_day($d);
echo " ";
echo date_get_month($d);
echo " ";
echo date_get_year($d);
echo "\n";
}
if (!extension_loaded("date_time")) dl('date.so');
if (!function_exists('date_new')) {
echo "date extension not available.\n";
}
$dates = array(
array(1,array(3,1,1964),array(3,2,1964)),
array(1,array(13,11,1995),array(13,12,1995)),
array(-1,array(16,11,1995),array(16,10,1995),),
array(3,array(17,11,1995),array(17,2,1996)),
array(-3,array(17,2,1996),array(17,11,1995)),
array(1,array(28,2,1995),array(28,3,1995)),
array(-1,array(28,3,1995),array(28,2,1995))
//array(11642,array(3,1,1964),array(18,11,1995)),
//array(-11642,array(18,11,1995),array(3,1,1964))
);
$d = date_new();
/* add */
echo "*** add\n";
foreach ($dates as $date) {
$offset = $date[0];
$date1 = $date[1];
$rdate = $date[2];
date_set_dmy($d,$date1[0],$date1[1],$date1[2]);
date_add_months($d,$offset);
if (date_get_day($d) != $rdate[0] || date_get_month($d) != $rdate[1] || date_get_year($d) !=
$rdate[2] ) {
echo implode('/',$date1)."Failed.\n";
}
}
/* sub */
echo "*** sub\n";
foreach ($dates as $date) {
$offset = $date[0];
$date1 = $date[2];
$rdate = $date[1];
date_set_dmy($d,$date1[0],$date1[1],$date1[2]);
date_sub_months($d,$offset);
if ( (date_get_day($d) != $rdate[0]) || (date_get_month($d) != $rdate[1]) || (date_get_year($d) !=
$rdate[2]) ) {
echo implode('/',$date1)." Failed.\n";
}
}
echo "Done.\n";
?>
--EXPECT--
*** add
*** sub
Done.