wharmby         Thu Jan 22 14:11:14 2009 UTC

  Modified files:              
    /php-src/ext/date/tests     microtime_error.phpt time_basic.phpt 
                                microtime_basic.phpt time_error.phpt 
  Log:
  New basic  time()and microtime() tests. Tested on Windows, Linux and Linux 64 
bit
  
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/microtime_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/date/tests/microtime_error.phpt
diff -u /dev/null php-src/ext/date/tests/microtime_error.phpt:1.2
--- /dev/null   Thu Jan 22 14:11:14 2009
+++ php-src/ext/date/tests/microtime_error.phpt Thu Jan 22 14:11:13 2009
@@ -0,0 +1,71 @@
+--TEST--
+Test wrong number of arguments for microtime()
+--FILE--
+<?php
+/* 
+ * proto mixed microtime([bool get_as_float])
+ * Function is implemented in ext/standard/microtime.c
+*/ 
+
+$opt_arg_0 = true;
+$extra_arg = 1;
+
+echo "\n-- Too many arguments --\n";
+var_dump(microtime($opt_arg_0, $extra_arg));
+
+
+echo "\n-- Bad Arg types --\n";
+
+$bad_args = array(null,
+                                 1.5,
+                                 "hello",
+                                 array('k'=>'v', array(0)),
+                                 new stdClass,
+                                 1);
+foreach ($bad_args as $bad_arg) {
+       echo "\n--> bad arg: ";
+       var_dump($bad_arg);
+       var_dump(microtime($bad_arg));
+}
+
+?>
+===DONE===
+--EXPECTF--
+-- Too many arguments --
+
+Warning: microtime() expects at most 1 parameter, 2 given in %s on line %d
+NULL
+
+-- Bad Arg types --
+
+--> bad arg: NULL
+unicode(%d) "%s"
+
+--> bad arg: float(1.5)
+float(%f)
+
+--> bad arg: unicode(5) "hello"
+float(%f)
+
+--> bad arg: array(2) {
+  [u"k"]=>
+  unicode(1) "v"
+  [0]=>
+  array(1) {
+    [0]=>
+    int(0)
+  }
+}
+
+Warning: microtime() expects parameter 1 to be boolean, array given in %s on 
line %d
+NULL
+
+--> bad arg: object(stdClass)#1 (0) {
+}
+
+Warning: microtime() expects parameter 1 to be boolean, object given in %s on 
line %d
+NULL
+
+--> bad arg: int(1)
+float(%f)
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/time_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/date/tests/time_basic.phpt
diff -u /dev/null php-src/ext/date/tests/time_basic.phpt:1.2
--- /dev/null   Thu Jan 22 14:11:14 2009
+++ php-src/ext/date/tests/time_basic.phpt      Thu Jan 22 14:11:14 2009
@@ -0,0 +1,16 @@
+--TEST--
+Test return type and value for expected input time()
+--FILE--
+<?php
+/* 
+ * proto int time(void)
+ * Function is implemented in ext/date/php_date.c
+*/ 
+
+var_dump(time());
+
+?>
+===DONE===
+--EXPECTF--
+int(%d)
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/microtime_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/date/tests/microtime_basic.phpt
diff -u /dev/null php-src/ext/date/tests/microtime_basic.phpt:1.2
--- /dev/null   Thu Jan 22 14:11:14 2009
+++ php-src/ext/date/tests/microtime_basic.phpt Thu Jan 22 14:11:14 2009
@@ -0,0 +1,20 @@
+--TEST--
+Test return type and value for expected input microtime()
+--FILE--
+<?php
+/* 
+ * proto mixed microtime([bool get_as_float])
+ * Function is implemented in ext/standard/microtime.c
+*/ 
+
+var_dump(microtime());
+var_dump(microtime(true));
+var_dump(microtime(false));
+
+?>
+===DONE===
+--EXPECTF--
+unicode(%d) "%s %s"
+float(%s)
+unicode(%d) "%s %s"
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/time_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/date/tests/time_error.phpt
diff -u /dev/null php-src/ext/date/tests/time_error.phpt:1.2
--- /dev/null   Thu Jan 22 14:11:14 2009
+++ php-src/ext/date/tests/time_error.phpt      Thu Jan 22 14:11:14 2009
@@ -0,0 +1,20 @@
+--TEST--
+Test wrong number of arguments for time()
+--FILE--
+<?php
+/* 
+ * proto int time(void)
+ * Function is implemented in ext/date/php_date.c
+*/ 
+
+// Extra arguments are ignored
+$extra_arg = 1;
+echo "\n-- Too many arguments --\n";
+var_dump (time($extra_arg));
+?>
+===DONE===
+--EXPECTF--
+
+-- Too many arguments --
+int(%d)
+===DONE===
\ No newline at end of file



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to