From 18e73c14a2145332eceb9458ac305fb1bbe7723d Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Thu, 22 Jan 2009 14:11:12 +0000 Subject: [PATCH] New basic time()and microtime() tests. Tested on Windows, Linux and Linux 64 bit --- ext/date/tests/microtime_basic.phpt | 20 ++++++++ ext/date/tests/microtime_error.phpt | 72 +++++++++++++++++++++++++++++ ext/date/tests/time_basic.phpt | 16 +++++++ ext/date/tests/time_error.phpt | 20 ++++++++ 4 files changed, 128 insertions(+) create mode 100644 ext/date/tests/microtime_basic.phpt create mode 100644 ext/date/tests/microtime_error.phpt create mode 100644 ext/date/tests/time_basic.phpt create mode 100644 ext/date/tests/time_error.phpt 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-- + +===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..400df61779 --- /dev/null +++ b/ext/date/tests/microtime_error.phpt @@ -0,0 +1,72 @@ +--TEST-- +Test wrong number of arguments for microtime() +--FILE-- +'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=== diff --git a/ext/date/tests/time_basic.phpt b/ext/date/tests/time_basic.phpt new file mode 100644 index 0000000000..ad788f907e --- /dev/null +++ b/ext/date/tests/time_basic.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test return type and value for expected input time() +--FILE-- + +===DONE=== +--EXPECTF-- +int(%d) +===DONE=== diff --git a/ext/date/tests/time_error.phpt b/ext/date/tests/time_error.phpt new file mode 100644 index 0000000000..3792570cfe --- /dev/null +++ b/ext/date/tests/time_error.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test wrong number of arguments for time() +--FILE-- + +===DONE=== +--EXPECTF-- + +-- Too many arguments -- +int(%d) +===DONE=== -- 2.50.1