From: Edgar R. Sandi Date: Sat, 1 Apr 2017 04:26:09 +0000 (-0300) Subject: pull-request/2456: X-Git-Tag: php-7.2.0alpha1~155 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebdbebee298a86ddddf922e2e817f101fdea4edb;p=php pull-request/2456: increase test coverage in calendar extension consistent warnings in calendar extension --- diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index c00507d86a..d6df68cebb 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -313,7 +313,7 @@ PHP_FUNCTION(cal_info) if (cal != -1 && (cal < 0 || cal >= CAL_NUM_CALS)) { - php_error_docref(NULL, E_WARNING, "invalid calendar ID " ZEND_LONG_FMT ".", cal); + php_error_docref(NULL, E_WARNING, "invalid calendar ID " ZEND_LONG_FMT, cal); RETURN_FALSE; } @@ -335,7 +335,7 @@ PHP_FUNCTION(cal_days_in_month) } if (cal < 0 || cal >= CAL_NUM_CALS) { - php_error_docref(NULL, E_WARNING, "invalid calendar ID " ZEND_LONG_FMT ".", cal); + php_error_docref(NULL, E_WARNING, "invalid calendar ID " ZEND_LONG_FMT, cal); RETURN_FALSE; } @@ -344,7 +344,7 @@ PHP_FUNCTION(cal_days_in_month) sdn_start = calendar->to_jd(year, month, 1); if (sdn_start == 0) { - php_error_docref(NULL, E_WARNING, "invalid date."); + php_error_docref(NULL, E_WARNING, "invalid date"); RETURN_FALSE; } @@ -381,7 +381,7 @@ PHP_FUNCTION(cal_to_jd) } if (cal < 0 || cal >= CAL_NUM_CALS) { - php_error_docref(NULL, E_WARNING, "invalid calendar ID " ZEND_LONG_FMT ".", cal); + php_error_docref(NULL, E_WARNING, "invalid calendar ID " ZEND_LONG_FMT, cal); RETURN_FALSE; } @@ -403,7 +403,7 @@ PHP_FUNCTION(cal_from_jd) } if (cal < 0 || cal >= CAL_NUM_CALS) { - php_error_docref(NULL, E_WARNING, "invalid calendar ID " ZEND_LONG_FMT "", cal); + php_error_docref(NULL, E_WARNING, "invalid calendar ID " ZEND_LONG_FMT, cal); RETURN_FALSE; } calendar = &cal_conversion_table[cal]; @@ -623,7 +623,7 @@ PHP_FUNCTION(jdtojewish) RETURN_STRING(date); } else { if (year <= 0 || year > 9999) { - php_error_docref(NULL, E_WARNING, "Year out of range (0-9999)."); + php_error_docref(NULL, E_WARNING, "Year out of range (0-9999)"); RETURN_FALSE; } diff --git a/ext/calendar/tests/cal_days_in_month_error1.phpt b/ext/calendar/tests/cal_days_in_month_error1.phpt new file mode 100644 index 0000000000..c413a8163a --- /dev/null +++ b/ext/calendar/tests/cal_days_in_month_error1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test cal_days_in_month() function : error conditions +--CREDITS-- +edgarsandi - +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: cal_days_in_month(): invalid calendar ID -1 in %s on line %d +bool(false) + +Warning: cal_days_in_month(): invalid date in %s on line %d +bool(false) \ No newline at end of file diff --git a/ext/calendar/tests/cal_from_jd_error1.phpt b/ext/calendar/tests/cal_from_jd_error1.phpt new file mode 100644 index 0000000000..1d2cf39c07 --- /dev/null +++ b/ext/calendar/tests/cal_from_jd_error1.phpt @@ -0,0 +1,13 @@ +--TEST-- +Test cal_from_jd() function : error conditions +--CREDITS-- +edgarsandi - +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: cal_from_jd(): invalid calendar ID -1 in %s on line %d +bool(false) \ No newline at end of file diff --git a/ext/calendar/tests/cal_info.phpt b/ext/calendar/tests/cal_info.phpt index 7edb4ce67c..68f31c16da 100644 --- a/ext/calendar/tests/cal_info.phpt +++ b/ext/calendar/tests/cal_info.phpt @@ -213,4 +213,4 @@ Array [calsymbol] => CAL_JULIAN ) -Warning: cal_info(): invalid calendar ID 99999. in %s on line %d +Warning: cal_info(): invalid calendar ID 99999 in %s on line %d diff --git a/ext/calendar/tests/cal_to_jd_error1.phpt b/ext/calendar/tests/cal_to_jd_error1.phpt new file mode 100644 index 0000000000..9bee0658a5 --- /dev/null +++ b/ext/calendar/tests/cal_to_jd_error1.phpt @@ -0,0 +1,13 @@ +--TEST-- +Test cal_to_jd() function : error conditions +--CREDITS-- +edgarsandi - +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: cal_to_jd(): invalid calendar ID -1 in %s on line %d +bool(false) \ No newline at end of file diff --git a/ext/calendar/tests/gregoriantojd.phpt b/ext/calendar/tests/gregoriantojd.phpt index ec3628e899..1a3d0f1712 100644 --- a/ext/calendar/tests/gregoriantojd.phpt +++ b/ext/calendar/tests/gregoriantojd.phpt @@ -9,10 +9,14 @@ echo gregoriantojd( 1, 1, 1582). "\n"; echo gregoriantojd(10, 5, 1582). "\n"; echo gregoriantojd( 1, 1, 1970). "\n"; echo gregoriantojd( 1, 1, 2999). "\n"; +echo gregoriantojd( 1, 1, -4714). "\n"; +echo gregoriantojd( 11, 24, -4714). "\n"; ?> --EXPECT-- 0 2298874 2299151 2440588 -2816423 \ No newline at end of file +2816423 +0 +0 \ No newline at end of file diff --git a/ext/calendar/tests/jdtogregorian.phpt b/ext/calendar/tests/jdtogregorian.phpt index 6b1956f477..b882d5f08d 100644 --- a/ext/calendar/tests/jdtogregorian.phpt +++ b/ext/calendar/tests/jdtogregorian.phpt @@ -5,6 +5,7 @@ jdtogregorian() --FILE-- --EXPECT-- 0/0/0 +11/25/-4714 1/1/1582 10/5/1582 1/1/1970 diff --git a/ext/calendar/tests/jdtojewish.phpt b/ext/calendar/tests/jdtojewish.phpt index bc0ecbdd88..78efd2a3e4 100644 --- a/ext/calendar/tests/jdtojewish.phpt +++ b/ext/calendar/tests/jdtojewish.phpt @@ -16,6 +16,11 @@ var_dump(jdtojewish(gregoriantojd(10,28,2002))."\r\n". jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM)."\r\n". jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n". jdtojewish(gregoriantojd(3,10,2007))."\r\n"); + +echo jdtojewish(gregoriantojd(11,5,2002)) . "\n"; +echo jdtojewish(gregoriantojd(11,29,2004)) . "\n"; +echo jdtojewish(gregoriantojd(1,1,9998)) . "\n"; +echo jdtojewish(gregoriantojd(1,1,9998),true) . "\n"; ?> --EXPECTF-- string(%d) "2/22/5763 @@ -30,3 +35,8 @@ string(%d) "2/22/5763 á' çùåï ä' àìôéí úùñ"â 7/20/5767 " +2/30/5763 +3/16/5765 +3/8/13758 + +Warning: jdtojewish(): Year out of range (0-9999) in %s on line %d \ No newline at end of file diff --git a/ext/calendar/tests/jdtojulian.phpt b/ext/calendar/tests/jdtojulian.phpt index 6c87aa7e54..2f8f4aa937 100644 --- a/ext/calendar/tests/jdtojulian.phpt +++ b/ext/calendar/tests/jdtojulian.phpt @@ -5,6 +5,7 @@ jdtojulian() --FILE-- --EXPECT-- 0/0/0 +1/2/-4713 12/22/1581 9/25/1582 12/19/1969 diff --git a/ext/calendar/tests/jdtounix_error1.phpt b/ext/calendar/tests/jdtounix_error1.phpt new file mode 100644 index 0000000000..2d54cf22be --- /dev/null +++ b/ext/calendar/tests/jdtounix_error1.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test jdtounix() function : error conditions +--CREDITS-- +edgarsandi - +--INI-- +date.timezone=UTC +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(false) \ No newline at end of file diff --git a/ext/calendar/tests/juliantojd.phpt b/ext/calendar/tests/juliantojd.phpt index 9563e041a1..c9ba3955d0 100644 --- a/ext/calendar/tests/juliantojd.phpt +++ b/ext/calendar/tests/juliantojd.phpt @@ -9,10 +9,12 @@ echo juliantojd( 1, 1, 1582). "\n"; echo juliantojd(10, 5, 1582). "\n"; echo juliantojd( 1, 1, 1970). "\n"; echo juliantojd( 1, 1, 2999). "\n"; +echo juliantojd( 1, 1, -4713). "\n"; ?> --EXPECT-- 0 2298884 2299161 2440601 -2816443 \ No newline at end of file +2816443 +0 \ No newline at end of file diff --git a/ext/calendar/tests/unixtojd.phpt b/ext/calendar/tests/unixtojd.phpt index 6183cae9ee..01b3773007 100644 --- a/ext/calendar/tests/unixtojd.phpt +++ b/ext/calendar/tests/unixtojd.phpt @@ -30,11 +30,13 @@ putenv('TZ=UTC'); // -this incorrect localtime is passed to the julian date conversion (GregorianToSDN) function which works (probably correctly) // but returns -1 day from expected because its input is -1 from expected +echo unixtojd(). "\n"; echo unixtojd(40000). "\n"; echo unixtojd(1000000000). "\n"; echo unixtojd(1152459009). "\n"; ?> ---EXPECT-- +--EXPECTF-- +%d 2440588 2452162 2453926 diff --git a/ext/calendar/tests/unixtojd_error1.phpt b/ext/calendar/tests/unixtojd_error1.phpt new file mode 100644 index 0000000000..b19bcd6d16 --- /dev/null +++ b/ext/calendar/tests/unixtojd_error1.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test unixtojd() function : error conditions +--CREDITS-- +edgarsandi - +--SKIPIF-- + +--INI-- +date.timezone=UTC +--FILE-- + +--EXPECTF-- +bool(false) +int(%d) +int(%d) +int(%d) +bool(false) \ No newline at end of file diff --git a/ext/date/tests/cal_days_in_month_invalid_calendar.phpt b/ext/date/tests/cal_days_in_month_invalid_calendar.phpt deleted file mode 100644 index 3550b91e7a..0000000000 --- a/ext/date/tests/cal_days_in_month_invalid_calendar.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -cal_days_in_month: test invalid parameter ---CREDITS-- -Havard Eide -#PHPTestFest2009 Norway 2009-06-09 \o/ ---SKIPIF-- - ---INI-- -date.timezone=UTC ---FILE-- - ---EXPECTF-- -Warning: cal_days_in_month(): invalid calendar ID 99. in %s on line %d - diff --git a/ext/date/tests/cal_days_in_month_invalid_date.phpt b/ext/date/tests/cal_days_in_month_invalid_date.phpt deleted file mode 100644 index 031527074f..0000000000 --- a/ext/date/tests/cal_days_in_month_invalid_date.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -cal_days_in_month: test invalid parameter ---CREDITS-- -Havard Eide -#PHPTestFest2009 Norway 2009-06-09 \o/ ---SKIPIF-- - ---INI-- -date.timezone=UTC ---FILE-- - ---EXPECTF-- -Warning: cal_days_in_month(): invalid date. in %s on line %d -