]> granicus.if.org Git - php/commitdiff
additional test cases added, should now cover all functions and modes
authorHartmut Holzgraefe <hholzgra@php.net>
Sun, 9 Jul 2006 16:30:02 +0000 (16:30 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Sun, 9 Jul 2006 16:30:02 +0000 (16:30 +0000)
allthough still not all edge cases

13 files changed:
ext/calendar/tests/cal_from_jd.phpt [new file with mode: 0644]
ext/calendar/tests/cal_info.phpt [new file with mode: 0644]
ext/calendar/tests/easter_date.phpt [new file with mode: 0644]
ext/calendar/tests/gregoriantojd.phpt [new file with mode: 0644]
ext/calendar/tests/jddayofweek.phpt [new file with mode: 0644]
ext/calendar/tests/jdmonthname.phpt [new file with mode: 0644]
ext/calendar/tests/jdtofrench.phpt [new file with mode: 0644]
ext/calendar/tests/jdtogregorian.phpt [new file with mode: 0644]
ext/calendar/tests/jdtojulian.phpt [new file with mode: 0644]
ext/calendar/tests/jdtounix.phpt [new file with mode: 0644]
ext/calendar/tests/jewishtojd.phpt [new file with mode: 0644]
ext/calendar/tests/juliantojd.phpt [new file with mode: 0644]
ext/calendar/tests/unixtojd.phpt [new file with mode: 0644]

diff --git a/ext/calendar/tests/cal_from_jd.phpt b/ext/calendar/tests/cal_from_jd.phpt
new file mode 100644 (file)
index 0000000..9614522
--- /dev/null
@@ -0,0 +1,60 @@
+--TEST--
+cal_from_jd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+print_r(cal_from_jd(1748326, CAL_GREGORIAN));
+print_r(cal_from_jd(1748324, CAL_JULIAN));
+print_r(cal_from_jd( 374867, CAL_JEWISH));
+print_r(cal_from_jd(      0, CAL_FRENCH));
+?>
+--EXPECT--
+Array
+(
+    [date] => 8/26/74
+    [month] => 8
+    [day] => 26
+    [year] => 74
+    [dow] => 0
+    [abbrevdayname] => Sun
+    [dayname] => Sunday
+    [abbrevmonth] => Aug
+    [monthname] => August
+)
+Array
+(
+    [date] => 8/26/74
+    [month] => 8
+    [day] => 26
+    [year] => 74
+    [dow] => 5
+    [abbrevdayname] => Fri
+    [dayname] => Friday
+    [abbrevmonth] => Aug
+    [monthname] => August
+)
+Array
+(
+    [date] => 8/26/74
+    [month] => 8
+    [day] => 26
+    [year] => 74
+    [dow] => 4
+    [abbrevdayname] => Thu
+    [dayname] => Thursday
+    [abbrevmonth] => Nisan
+    [monthname] => Nisan
+)
+Array
+(
+    [date] => 0/0/0
+    [month] => 0
+    [day] => 0
+    [year] => 0
+    [dow] => 1
+    [abbrevdayname] => Mon
+    [dayname] => Monday
+    [abbrevmonth] => 
+    [monthname] => 
+)
diff --git a/ext/calendar/tests/cal_info.phpt b/ext/calendar/tests/cal_info.phpt
new file mode 100644 (file)
index 0000000..ae57a87
--- /dev/null
@@ -0,0 +1,214 @@
+--TEST--
+cal_info()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+  print_r(cal_info());
+  print_r(cal_info(1));
+  print_r(cal_info(99999));
+?>
+--EXPECT--
+Array
+(
+    [0] => Array
+        (
+            [months] => Array
+                (
+                    [1] => January
+                    [2] => February
+                    [3] => March
+                    [4] => April
+                    [5] => May
+                    [6] => June
+                    [7] => July
+                    [8] => August
+                    [9] => September
+                    [10] => October
+                    [11] => November
+                    [12] => December
+                )
+
+            [abbrevmonths] => Array
+                (
+                    [1] => Jan
+                    [2] => Feb
+                    [3] => Mar
+                    [4] => Apr
+                    [5] => May
+                    [6] => Jun
+                    [7] => Jul
+                    [8] => Aug
+                    [9] => Sep
+                    [10] => Oct
+                    [11] => Nov
+                    [12] => Dec
+                )
+
+            [maxdaysinmonth] => 31
+            [calname] => Gregorian
+            [calsymbol] => CAL_GREGORIAN
+        )
+
+    [1] => Array
+        (
+            [months] => Array
+                (
+                    [1] => January
+                    [2] => February
+                    [3] => March
+                    [4] => April
+                    [5] => May
+                    [6] => June
+                    [7] => July
+                    [8] => August
+                    [9] => September
+                    [10] => October
+                    [11] => November
+                    [12] => December
+                )
+
+            [abbrevmonths] => Array
+                (
+                    [1] => Jan
+                    [2] => Feb
+                    [3] => Mar
+                    [4] => Apr
+                    [5] => May
+                    [6] => Jun
+                    [7] => Jul
+                    [8] => Aug
+                    [9] => Sep
+                    [10] => Oct
+                    [11] => Nov
+                    [12] => Dec
+                )
+
+            [maxdaysinmonth] => 31
+            [calname] => Julian
+            [calsymbol] => CAL_JULIAN
+        )
+
+    [2] => Array
+        (
+            [months] => Array
+                (
+                    [1] => Tishri
+                    [2] => Heshvan
+                    [3] => Kislev
+                    [4] => Tevet
+                    [5] => Shevat
+                    [6] => AdarI
+                    [7] => AdarII
+                    [8] => Nisan
+                    [9] => Iyyar
+                    [10] => Sivan
+                    [11] => Tammuz
+                    [12] => Av
+                    [13] => Elul
+                )
+
+            [abbrevmonths] => Array
+                (
+                    [1] => Tishri
+                    [2] => Heshvan
+                    [3] => Kislev
+                    [4] => Tevet
+                    [5] => Shevat
+                    [6] => AdarI
+                    [7] => AdarII
+                    [8] => Nisan
+                    [9] => Iyyar
+                    [10] => Sivan
+                    [11] => Tammuz
+                    [12] => Av
+                    [13] => Elul
+                )
+
+            [maxdaysinmonth] => 30
+            [calname] => Jewish
+            [calsymbol] => CAL_JEWISH
+        )
+
+    [3] => Array
+        (
+            [months] => Array
+                (
+                    [1] => Vendemiaire
+                    [2] => Brumaire
+                    [3] => Frimaire
+                    [4] => Nivose
+                    [5] => Pluviose
+                    [6] => Ventose
+                    [7] => Germinal
+                    [8] => Floreal
+                    [9] => Prairial
+                    [10] => Messidor
+                    [11] => Thermidor
+                    [12] => Fructidor
+                    [13] => Extra
+                )
+
+            [abbrevmonths] => Array
+                (
+                    [1] => Vendemiaire
+                    [2] => Brumaire
+                    [3] => Frimaire
+                    [4] => Nivose
+                    [5] => Pluviose
+                    [6] => Ventose
+                    [7] => Germinal
+                    [8] => Floreal
+                    [9] => Prairial
+                    [10] => Messidor
+                    [11] => Thermidor
+                    [12] => Fructidor
+                    [13] => Extra
+                )
+
+            [maxdaysinmonth] => 30
+            [calname] => French
+            [calsymbol] => CAL_FRENCH
+        )
+
+)
+Array
+(
+    [months] => Array
+        (
+            [1] => January
+            [2] => February
+            [3] => March
+            [4] => April
+            [5] => May
+            [6] => June
+            [7] => July
+            [8] => August
+            [9] => September
+            [10] => October
+            [11] => November
+            [12] => December
+        )
+
+    [abbrevmonths] => Array
+        (
+            [1] => Jan
+            [2] => Feb
+            [3] => Mar
+            [4] => Apr
+            [5] => May
+            [6] => Jun
+            [7] => Jul
+            [8] => Aug
+            [9] => Sep
+            [10] => Oct
+            [11] => Nov
+            [12] => Dec
+        )
+
+    [maxdaysinmonth] => 31
+    [calname] => Julian
+    [calsymbol] => CAL_JULIAN
+)
+
+Warning: cal_info(): invalid calendar ID 99999. in /home/hartmut/projects/php/dev/head/ext/calendar/tests/cal_info.php on line 4
diff --git a/ext/calendar/tests/easter_date.phpt b/ext/calendar/tests/easter_date.phpt
new file mode 100644 (file)
index 0000000..0ba3ef3
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+easter_date()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo date("Y-m-d", easter_date(2000))."\n";       
+echo date("Y-m-d", easter_date(2001))."\n";      
+echo date("Y-m-d", easter_date(2002))."\n";      
+?>
+--EXPECT--
+2000-04-23
+2001-04-15
+2002-03-31
diff --git a/ext/calendar/tests/gregoriantojd.phpt b/ext/calendar/tests/gregoriantojd.phpt
new file mode 100644 (file)
index 0000000..ec3628e
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+gregoriantojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo gregoriantojd( 0, 0,    0). "\n";
+echo gregoriantojd( 1, 1, 1582). "\n";
+echo gregoriantojd(10, 5, 1582). "\n";
+echo gregoriantojd( 1, 1, 1970). "\n";
+echo gregoriantojd( 1, 1, 2999). "\n";
+?>
+--EXPECT--
+0
+2298874
+2299151
+2440588
+2816423
\ No newline at end of file
diff --git a/ext/calendar/tests/jddayofweek.phpt b/ext/calendar/tests/jddayofweek.phpt
new file mode 100644 (file)
index 0000000..34ad109
--- /dev/null
@@ -0,0 +1,101 @@
+--TEST--
+jddayofweek()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+foreach (array(2440588, 2452162, 2453926) as $jd) {
+  echo "### JD $jd ###\n";
+  for ($mode = 0; $mode <= 2; $mode++) {
+    echo "--- mode $mode ---\n";
+    for ($offset = 0; $offset <= 7; $offset++) {
+      echo jddayofweek($jd + $offset, $mode). "\n";
+    }
+  }
+}
+?>
+--EXPECT--
+### JD 2440588 ###
+--- mode 0 ---
+4
+5
+6
+0
+1
+2
+3
+4
+--- mode 1 ---
+Thursday
+Friday
+Saturday
+Sunday
+Monday
+Tuesday
+Wednesday
+Thursday
+--- mode 2 ---
+Thu
+Fri
+Sat
+Sun
+Mon
+Tue
+Wed
+Thu
+### JD 2452162 ###
+--- mode 0 ---
+0
+1
+2
+3
+4
+5
+6
+0
+--- mode 1 ---
+Sunday
+Monday
+Tuesday
+Wednesday
+Thursday
+Friday
+Saturday
+Sunday
+--- mode 2 ---
+Sun
+Mon
+Tue
+Wed
+Thu
+Fri
+Sat
+Sun
+### JD 2453926 ###
+--- mode 0 ---
+0
+1
+2
+3
+4
+5
+6
+0
+--- mode 1 ---
+Sunday
+Monday
+Tuesday
+Wednesday
+Thursday
+Friday
+Saturday
+Sunday
+--- mode 2 ---
+Sun
+Mon
+Tue
+Wed
+Thu
+Fri
+Sat
+Sun
diff --git a/ext/calendar/tests/jdmonthname.phpt b/ext/calendar/tests/jdmonthname.phpt
new file mode 100644 (file)
index 0000000..26dfc16
--- /dev/null
@@ -0,0 +1,314 @@
+--TEST--
+jddayofweek()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+foreach (array(2440588, 2452162, 2453926) as $jd) {
+  echo "### JD $jd ###\n";
+  for ($mode = 0; $mode <= 6; $mode++) {
+    echo "--- mode $mode ---\n";
+    for ($offset = 0; $offset <= 12; $offset++) {
+      echo jddayofweek($jd + $offset * 30, $mode). "\n";
+    }
+  }
+}
+?>
+--EXPECT--
+### JD 2440588 ###
+--- mode 0 ---
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+5
+0
+--- mode 1 ---
+Thursday
+Saturday
+Monday
+Wednesday
+Friday
+Sunday
+Tuesday
+Thursday
+Saturday
+Monday
+Wednesday
+Friday
+Sunday
+--- mode 2 ---
+Thu
+Sat
+Mon
+Wed
+Fri
+Sun
+Tue
+Thu
+Sat
+Mon
+Wed
+Fri
+Sun
+--- mode 3 ---
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+5
+0
+--- mode 4 ---
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+5
+0
+--- mode 5 ---
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+5
+0
+--- mode 6 ---
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+5
+0
+### JD 2452162 ###
+--- mode 0 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+--- mode 1 ---
+Sunday
+Tuesday
+Thursday
+Saturday
+Monday
+Wednesday
+Friday
+Sunday
+Tuesday
+Thursday
+Saturday
+Monday
+Wednesday
+--- mode 2 ---
+Sun
+Tue
+Thu
+Sat
+Mon
+Wed
+Fri
+Sun
+Tue
+Thu
+Sat
+Mon
+Wed
+--- mode 3 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+--- mode 4 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+--- mode 5 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+--- mode 6 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+### JD 2453926 ###
+--- mode 0 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+--- mode 1 ---
+Sunday
+Tuesday
+Thursday
+Saturday
+Monday
+Wednesday
+Friday
+Sunday
+Tuesday
+Thursday
+Saturday
+Monday
+Wednesday
+--- mode 2 ---
+Sun
+Tue
+Thu
+Sat
+Mon
+Wed
+Fri
+Sun
+Tue
+Thu
+Sat
+Mon
+Wed
+--- mode 3 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+--- mode 4 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+--- mode 5 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
+--- mode 6 ---
+0
+2
+4
+6
+1
+3
+5
+0
+2
+4
+6
+1
+3
\ No newline at end of file
diff --git a/ext/calendar/tests/jdtofrench.phpt b/ext/calendar/tests/jdtofrench.phpt
new file mode 100644 (file)
index 0000000..2794409
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+jdtofrench()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo jdtofrench(0). "\n";
+echo jdtofrench(2375840). "\n";
+echo jdtofrench(2375850). "\n";
+echo jdtofrench(2375940). "\n";
+echo jdtofrench(2376345). "\n";
+echo jdtofrench(2385940). "\n";
+?>
+--EXPECT--
+0/0/0
+1/1/1
+1/11/1
+4/11/1
+5/21/2
+0/0/0
\ No newline at end of file
diff --git a/ext/calendar/tests/jdtogregorian.phpt b/ext/calendar/tests/jdtogregorian.phpt
new file mode 100644 (file)
index 0000000..6b1956f
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+jdtogregorian()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo jdtogregorian(0). "\n";
+echo jdtogregorian(2298874). "\n";
+echo jdtogregorian(2299151). "\n";
+echo jdtogregorian(2440588). "\n";
+echo jdtogregorian(2816423). "\n";
+?>
+--EXPECT--
+0/0/0
+1/1/1582
+10/5/1582
+1/1/1970
+1/1/2999
\ No newline at end of file
diff --git a/ext/calendar/tests/jdtojulian.phpt b/ext/calendar/tests/jdtojulian.phpt
new file mode 100644 (file)
index 0000000..6c87aa7
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+jdtojulian()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo jdtojulian(0). "\n";
+echo jdtojulian(2298874). "\n";
+echo jdtojulian(2299151). "\n";
+echo jdtojulian(2440588). "\n";
+echo jdtojulian(2816423). "\n";
+?>
+--EXPECT--
+0/0/0
+12/22/1581
+9/25/1582
+12/19/1969
+12/12/2998
\ No newline at end of file
diff --git a/ext/calendar/tests/jdtounix.phpt b/ext/calendar/tests/jdtounix.phpt
new file mode 100644 (file)
index 0000000..055f7fe
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+jdtounix()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo date("Y-m-d",jdtounix(2440588)). "\n";
+echo date("Y-m-d",jdtounix(2452162)). "\n";
+echo date("Y-m-d",jdtounix(2453926)). "\n";
+?>
+--EXPECT--
+1970-01-01
+2001-09-09
+2006-07-09
diff --git a/ext/calendar/tests/jewishtojd.phpt b/ext/calendar/tests/jewishtojd.phpt
new file mode 100644 (file)
index 0000000..a9a2ff0
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+jewishtojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo jewishtojd(-1,-1,-1). "\n";
+echo jewishtojd(0,0,0). "\n";
+echo jewishtojd(1,1,1). "\n";
+echo jewishtojd(2,22,5763). "\n";
+?>
+--EXPECT--
+0
+0
+347998
+2452576
\ No newline at end of file
diff --git a/ext/calendar/tests/juliantojd.phpt b/ext/calendar/tests/juliantojd.phpt
new file mode 100644 (file)
index 0000000..9563e04
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+juliantojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo juliantojd( 0, 0,    0). "\n";
+echo juliantojd( 1, 1, 1582). "\n";
+echo juliantojd(10, 5, 1582). "\n";
+echo juliantojd( 1, 1, 1970). "\n";
+echo juliantojd( 1, 1, 2999). "\n";
+?>
+--EXPECT--
+0
+2298884
+2299161
+2440601
+2816443
\ No newline at end of file
diff --git a/ext/calendar/tests/unixtojd.phpt b/ext/calendar/tests/unixtojd.phpt
new file mode 100644 (file)
index 0000000..567a8c2
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+unixtojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo unixtojd(40000). "\n";
+echo unixtojd(1000000000). "\n";
+echo unixtojd(1152459009). "\n";
+?>
+--EXPECT--
+2440588
+2452162
+2453926