diff options
Diffstat (limited to 'ext/calendar')
-rw-r--r-- | ext/calendar/calendar.c | 12 | ||||
-rw-r--r-- | ext/calendar/tests/cal_days_in_month_error1.phpt | 17 | ||||
-rw-r--r-- | ext/calendar/tests/cal_from_jd_error1.phpt | 13 | ||||
-rw-r--r-- | ext/calendar/tests/cal_info.phpt | 2 | ||||
-rw-r--r-- | ext/calendar/tests/cal_to_jd_error1.phpt | 13 | ||||
-rw-r--r-- | ext/calendar/tests/gregoriantojd.phpt | 6 | ||||
-rw-r--r-- | ext/calendar/tests/jdtogregorian.phpt | 2 | ||||
-rw-r--r-- | ext/calendar/tests/jdtojewish.phpt | 10 | ||||
-rw-r--r-- | ext/calendar/tests/jdtojulian.phpt | 2 | ||||
-rw-r--r-- | ext/calendar/tests/jdtounix_error1.phpt | 14 | ||||
-rw-r--r-- | ext/calendar/tests/juliantojd.phpt | 4 | ||||
-rw-r--r-- | ext/calendar/tests/unixtojd.phpt | 4 | ||||
-rw-r--r-- | ext/calendar/tests/unixtojd_error1.phpt | 24 |
13 files changed, 113 insertions, 10 deletions
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 - <edgar.r.sandi@gmail.com> +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +var_dump(cal_days_in_month(-1, 4, 2017)); +var_dump(cal_days_in_month(CAL_GREGORIAN,0, 2009)); +?> +--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 - <edgar.r.sandi@gmail.com> +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +var_dump(cal_from_jd(1748326, -1)); +?> +--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 - <edgar.r.sandi@gmail.com> +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +var_dump(cal_to_jd(-1, 8, 26, 74)); +?> +--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-- <?php echo jdtogregorian(0). "\n"; +echo jdtogregorian(1). "\n"; echo jdtogregorian(2298874). "\n"; echo jdtogregorian(2299151). "\n"; echo jdtogregorian(2440588). "\n"; @@ -12,6 +13,7 @@ echo jdtogregorian(2816423). "\n"; ?> --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-- <?php echo jdtojulian(0). "\n"; +echo jdtojulian(1). "\n"; echo jdtojulian(2298874). "\n"; echo jdtojulian(2299151). "\n"; echo jdtojulian(2440588). "\n"; @@ -12,6 +13,7 @@ echo jdtojulian(2816423). "\n"; ?> --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 - <edgar.r.sandi@gmail.com> +--INI-- +date.timezone=UTC +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +var_dump(jdtounix(2440579)) . PHP_EOL; +?> +--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 - <edgar.r.sandi@gmail.com> +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--INI-- +date.timezone=UTC +--FILE-- +<?php +putenv('TZ=UTC'); + +var_dump(unixtojd(-1)) . PHP_EOL; +var_dump(unixtojd(false)) . PHP_EOL; +var_dump(unixtojd(null)) . PHP_EOL; +var_dump(unixtojd(time())) . PHP_EOL; +var_dump(unixtojd(PHP_INT_MAX)) . PHP_EOL; +?> +--EXPECTF-- +bool(false) +int(%d) +int(%d) +int(%d) +bool(false)
\ No newline at end of file |