From 4786d297ad72306c0c1d25b464c9de024fd965a8 Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Sun, 18 Jan 2009 14:40:25 +0000 Subject: [PATCH] New sscanf() tests. Tested on Windows. Linux and Linux 64 bit --- ext/standard/tests/strings/sscanf_basic1.phpt | 44 +++++ ext/standard/tests/strings/sscanf_basic2.phpt | 44 +++++ ext/standard/tests/strings/sscanf_basic3.phpt | 43 +++++ ext/standard/tests/strings/sscanf_basic4.phpt | 43 +++++ ext/standard/tests/strings/sscanf_basic5.phpt | 58 ++++++ ext/standard/tests/strings/sscanf_basic6.phpt | 47 +++++ ext/standard/tests/strings/sscanf_basic7.phpt | 47 +++++ ext/standard/tests/strings/sscanf_basic8.phpt | 65 +++++++ ext/standard/tests/strings/sscanf_error.phpt | 44 +++++ .../tests/strings/sscanf_variation1.phpt | 169 ++++++++++++++++++ .../tests/strings/sscanf_variation2.phpt | 153 ++++++++++++++++ 11 files changed, 757 insertions(+) create mode 100644 ext/standard/tests/strings/sscanf_basic1.phpt create mode 100644 ext/standard/tests/strings/sscanf_basic2.phpt create mode 100644 ext/standard/tests/strings/sscanf_basic3.phpt create mode 100644 ext/standard/tests/strings/sscanf_basic4.phpt create mode 100644 ext/standard/tests/strings/sscanf_basic5.phpt create mode 100644 ext/standard/tests/strings/sscanf_basic6.phpt create mode 100644 ext/standard/tests/strings/sscanf_basic7.phpt create mode 100644 ext/standard/tests/strings/sscanf_basic8.phpt create mode 100644 ext/standard/tests/strings/sscanf_error.phpt create mode 100644 ext/standard/tests/strings/sscanf_variation1.phpt create mode 100644 ext/standard/tests/strings/sscanf_variation2.phpt diff --git a/ext/standard/tests/strings/sscanf_basic1.phpt b/ext/standard/tests/strings/sscanf_basic1.phpt new file mode 100644 index 0000000000..eb5d8c7de5 --- /dev/null +++ b/ext/standard/tests/strings/sscanf_basic1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test sscanf() function : basic functionality - string format +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing sscanf() : basic functionality - using string format *** + +-- Try sccanf() WITHOUT optional args -- +unicode(6) "Widget" +unicode(7) "1234789" +unicode(2) "25" + +-- Try sccanf() WITH optional args -- +int(3) +unicode(6) "Widget" +unicode(7) "1234789" +unicode(2) "25" +===DONE=== diff --git a/ext/standard/tests/strings/sscanf_basic2.phpt b/ext/standard/tests/strings/sscanf_basic2.phpt new file mode 100644 index 0000000000..add410e3dc --- /dev/null +++ b/ext/standard/tests/strings/sscanf_basic2.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test sscanf() function : basic functionality - integer format +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing sscanf() : basic functionality - using integer format *** + +-- Try sccanf() WITHOUT optional args -- +unicode(6) "Widget" +int(1234789) +int(25) + +-- Try sccanf() WITH optional args -- +int(3) +unicode(6) "Widget" +int(1234789) +int(25) +===DONE=== diff --git a/ext/standard/tests/strings/sscanf_basic3.phpt b/ext/standard/tests/strings/sscanf_basic3.phpt new file mode 100644 index 0000000000..3f1aaa067e --- /dev/null +++ b/ext/standard/tests/strings/sscanf_basic3.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test sscanf() function : basic functionality - float format +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing sscanf() : basic functionality -- using float format *** + +-- Try sccanf() WITHOUT optional args -- +unicode(6) "Widget" +float(111.53) +float(22.345) +float(12.4) + +-- Try sccanf() WITH optional args -- +int(4) +unicode(6) "Widget" +float(111.53) +float(22.345) +float(12.4) +===DONE=== diff --git a/ext/standard/tests/strings/sscanf_basic4.phpt b/ext/standard/tests/strings/sscanf_basic4.phpt new file mode 100644 index 0000000000..43649c2df7 --- /dev/null +++ b/ext/standard/tests/strings/sscanf_basic4.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test sscanf() function : basic functionality - char format +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing sscanf() : basic functionality - using char format *** + +-- Try sccanf() WITHOUT optional args -- +unicode(1) "X" +unicode(1) "A" +unicode(1) "B" +unicode(1) "C" + +-- Try sccanf() WITH optional args -- +int(4) +unicode(1) "X" +unicode(1) "A" +unicode(1) "B" +unicode(1) "C" +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/sscanf_basic5.phpt b/ext/standard/tests/strings/sscanf_basic5.phpt new file mode 100644 index 0000000000..5dbbf44813 --- /dev/null +++ b/ext/standard/tests/strings/sscanf_basic5.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test sscanf() function : basic functionality - exponential format +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing sscanf() : basic functionality -using exponential format *** + +-- Try sccanf() WITHOUT optional args -- +float(10.12345) +float(10123.45) +float(10123.45) +float(-101234.5) +float(10.12345) +float(10123.45) +float(10123.45) +float(-101234.5) + +-- Try sccanf() WITH optional args -- +int(4) +float(10.12345) +float(10123.45) +float(10123.45) +float(-101234.5) +int(4) +float(10.12345) +float(10123.45) +float(10123.45) +float(-101234.5) +===DONE=== diff --git a/ext/standard/tests/strings/sscanf_basic6.phpt b/ext/standard/tests/strings/sscanf_basic6.phpt new file mode 100644 index 0000000000..1addcf3c9d --- /dev/null +++ b/ext/standard/tests/strings/sscanf_basic6.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test sscanf() function : basic functionality - unsigned format +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing sscanf() : basic functionality - using unsigned format *** + +-- Try sccanf() WITHOUT optional args -- +unicode(10) "4294967285" +int(11) +int(11) +unicode(10) "4294967285" +NULL +NULL + +-- Try sccanf() WITH optional args -- +int(4) +unicode(10) "4294967285" +int(11) +int(11) +unicode(10) "4294967285" +NULL +NULL +===DONE=== diff --git a/ext/standard/tests/strings/sscanf_basic7.phpt b/ext/standard/tests/strings/sscanf_basic7.phpt new file mode 100644 index 0000000000..1d54054d4b --- /dev/null +++ b/ext/standard/tests/strings/sscanf_basic7.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test sscanf() function : basic functionality - octal format +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing sscanf() : basic functionality - using octal format *** + +-- Try sccanf() WITHOUT optional args -- +int(83) +int(-83) +int(83) +int(10) +NULL +NULL + +-- Try sccanf() WITH optional args -- +int(4) +int(83) +int(-83) +int(83) +int(10) +NULL +NULL +===DONE=== diff --git a/ext/standard/tests/strings/sscanf_basic8.phpt b/ext/standard/tests/strings/sscanf_basic8.phpt new file mode 100644 index 0000000000..4773f026af --- /dev/null +++ b/ext/standard/tests/strings/sscanf_basic8.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test sscanf() function : basic functionality - hexadecimal format +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing sscanf() : basic functionality - - using hexadecimal format *** + +-- Try sccanf() WITHOUT optional args -- +int(297) +int(303) +int(4667) +int(-4667) +int(6844) +int(1) +int(297) +int(303) +int(4667) +int(-4667) +int(6844) +int(1) + +-- Try sccanf() WITH optional args -- +int(6) +int(297) +int(303) +int(4667) +int(-4667) +int(6844) +int(1) +int(6) +int(297) +int(303) +int(4667) +int(-4667) +int(6844) +int(1) +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/sscanf_error.phpt b/ext/standard/tests/strings/sscanf_error.phpt new file mode 100644 index 0000000000..8d883a1f92 --- /dev/null +++ b/ext/standard/tests/strings/sscanf_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test sscanf() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing sscanf() : error conditions *** + +-- Testing sscanf() function with no arguments -- + +Warning: sscanf() expects at least 2 parameters, 0 given in %s on line %d +NULL + +-- Testing sscanf() function with one argument -- + +Warning: sscanf() expects at least 2 parameters, 1 given in %s on line %d +NULL + +-- Testing sscanf() function with more than expected no. of arguments -- + +Warning: sscanf(): Variable is not assigned by any conversion specifiers in %s on line %d +int(-1) +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/sscanf_variation1.phpt b/ext/standard/tests/strings/sscanf_variation1.phpt new file mode 100644 index 0000000000..5597de740c --- /dev/null +++ b/ext/standard/tests/strings/sscanf_variation1.phpt @@ -0,0 +1,169 @@ +--TEST-- +Test sscanf() function : usage variations - unexpected inputs for '$str' argument +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing sscanf() function: with unexpected inputs for 'str' argument *** +-- Iteration 1 -- +array(1) { + [0]=> + unicode(1) "0" +} +-- Iteration 2 -- +array(1) { + [0]=> + unicode(1) "1" +} +-- Iteration 3 -- +array(1) { + [0]=> + unicode(2) "-2" +} +-- Iteration 4 -- +array(1) { + [0]=> + unicode(10) "2147483647" +} +-- Iteration 5 -- +array(1) { + [0]=> + unicode(11) "-2147483648" +} +-- Iteration 6 -- +array(1) { + [0]=> + unicode(4) "10.5" +} +-- Iteration 7 -- +array(1) { + [0]=> + unicode(5) "-20.5" +} +-- Iteration 8 -- +array(1) { + [0]=> + unicode(12) "101234567000" +} +-- Iteration 9 -- + +Warning: sscanf() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: sscanf() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: sscanf() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- +array(1) { + [0]=> + unicode(1) "1" +} +-- Iteration 13 -- +NULL +-- Iteration 14 -- +array(1) { + [0]=> + unicode(1) "1" +} +-- Iteration 15 -- +NULL +-- Iteration 16 -- +NULL +-- Iteration 17 -- +NULL +-- Iteration 18 -- +array(1) { + [0]=> + unicode(6) "sample" +} +-- Iteration 19 -- + +Warning: sscanf() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 20 -- +NULL +-- Iteration 21 -- +NULL +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/sscanf_variation2.phpt b/ext/standard/tests/strings/sscanf_variation2.phpt new file mode 100644 index 0000000000..a196a77bee --- /dev/null +++ b/ext/standard/tests/strings/sscanf_variation2.phpt @@ -0,0 +1,153 @@ +--TEST-- +Test sscanf() function : usage variations - unexpected inputs for '$format' argument +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing sscanf() function: with unexpected inputs for 'format' argument *** +-- Iteration 1 -- +array(0) { +} +-- Iteration 2 -- +array(0) { +} +-- Iteration 3 -- +array(0) { +} +-- Iteration 4 -- +array(0) { +} +-- Iteration 5 -- +array(0) { +} +-- Iteration 6 -- +array(0) { +} +-- Iteration 7 -- +array(0) { +} +-- Iteration 8 -- +array(0) { +} +-- Iteration 9 -- + +Warning: sscanf() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: sscanf() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: sscanf() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- +array(0) { +} +-- Iteration 13 -- +array(0) { +} +-- Iteration 14 -- +array(0) { +} +-- Iteration 15 -- +array(0) { +} +-- Iteration 16 -- +array(0) { +} +-- Iteration 17 -- +array(0) { +} +-- Iteration 18 -- +array(0) { +} +-- Iteration 19 -- + +Warning: sscanf() expects parameter 2 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 20 -- +array(0) { +} +-- Iteration 21 -- +array(0) { +} +===DONE=== \ No newline at end of file -- 2.50.1