diff options
| author | andy wharmby <wharmby@php.net> | 2009-01-22 14:11:08 +0000 |
|---|---|---|
| committer | andy wharmby <wharmby@php.net> | 2009-01-22 14:11:08 +0000 |
| commit | 0d4228940cccd1cbb7e8f04aec2768f66e3444b4 (patch) | |
| tree | f316bffa6173b9c1dace3b51bd2fb5fede3e7c80 /ext | |
| parent | c70c7ca7f919c15e653c6a1ab446e70e8da05e72 (diff) | |
| download | php-git-0d4228940cccd1cbb7e8f04aec2768f66e3444b4.tar.gz | |
New basic time()and microtime() tests. Tested on Windows, Linux and Linux 64 bit
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/date/tests/microtime_basic.phpt | 20 | ||||
| -rw-r--r-- | ext/date/tests/microtime_error.phpt | 72 | ||||
| -rw-r--r-- | ext/date/tests/time_basic.phpt | 16 | ||||
| -rw-r--r-- | ext/date/tests/time_error.phpt | 19 |
4 files changed, 127 insertions, 0 deletions
diff --git a/ext/date/tests/microtime_basic.phpt b/ext/date/tests/microtime_basic.phpt new file mode 100644 index 0000000000..88c4952295 --- /dev/null +++ b/ext/date/tests/microtime_basic.phpt @@ -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-- +string(%d) "%s %s" +float(%s) +string(%d) "%s %s" +===DONE=== diff --git a/ext/date/tests/microtime_error.phpt b/ext/date/tests/microtime_error.phpt new file mode 100644 index 0000000000..07ac90874f --- /dev/null +++ b/ext/date/tests/microtime_error.phpt @@ -0,0 +1,72 @@ +--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 11 +NULL + +-- Bad Arg types -- + +--> bad arg: NULL +string(%d) "%s %s" + +--> bad arg: float(1.5) +float(%s) + +--> bad arg: string(5) "hello" +float(%s) + +--> bad arg: array(2) { + ["k"]=> + string(1) "v" + [0]=> + array(1) { + [0]=> + int(0) + } +} + +Warning: microtime() expects parameter 1 to be boolean, array given in %s on line 25 +NULL + +--> bad arg: object(stdClass)#%d (0) { +} + +Warning: microtime() expects parameter 1 to be boolean, object given in %s on line 25 +NULL + +--> bad arg: int(1) +float(%s) +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/time_basic.phpt b/ext/date/tests/time_basic.phpt new file mode 100644 index 0000000000..116c0a4175 --- /dev/null +++ b/ext/date/tests/time_basic.phpt @@ -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 diff --git a/ext/date/tests/time_error.phpt b/ext/date/tests/time_error.phpt new file mode 100644 index 0000000000..853c1babe7 --- /dev/null +++ b/ext/date/tests/time_error.phpt @@ -0,0 +1,19 @@ +--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 "\nToo many arguments\n"; +var_dump (time($extra_arg)); +?> +===DONE=== +--EXPECTF-- +Too many arguments +int(%d) +===DONE===
\ No newline at end of file |
