mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
New testcases for strspn() function
This commit is contained in:
parent
0aa09167c1
commit
b17d0085f3
41
ext/standard/tests/strings/strspn_basic.phpt
Normal file
41
ext/standard/tests/strings/strspn_basic.phpt
Normal file
@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
Test strspn() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided, it works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing strspn() : basic functionality
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : basic functionality ***\n";
|
||||
|
||||
|
||||
// Initialise all required variables
|
||||
$str = "this is the test string";
|
||||
$mask = "htes ";
|
||||
$start = 8;
|
||||
$len = 30;
|
||||
|
||||
// Calling strspn() with all possible arguments
|
||||
var_dump( strspn($str, $mask, $start, $len) );
|
||||
|
||||
// Calling strspn() with three arguments and default len argument
|
||||
var_dump( strspn($str, $mask, $start) );
|
||||
|
||||
// Calling strspn() with default arguments
|
||||
var_dump( strspn($str, $mask) );
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : basic functionality ***
|
||||
int(11)
|
||||
int(11)
|
||||
int(2)
|
||||
Done
|
57
ext/standard/tests/strings/strspn_error.phpt
Normal file
57
ext/standard/tests/strings/strspn_error.phpt
Normal file
@ -0,0 +1,57 @@
|
||||
--TEST--
|
||||
Test strspn() function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test strspn() : for error conditons
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : error conditions ***\n";
|
||||
|
||||
// Zero arguments
|
||||
echo "\n-- Testing strspn() function with Zero arguments --\n";
|
||||
var_dump( strspn() );
|
||||
|
||||
//Test strspn with one more than the expected number of arguments
|
||||
echo "\n-- Testing strspn() function with more than expected no. of arguments --\n";
|
||||
$str = 'string_val';
|
||||
$mask = 'string_val';
|
||||
$start = 2;
|
||||
$len = 20;
|
||||
|
||||
|
||||
$extra_arg = 10;
|
||||
var_dump( strspn($str,$mask,$start,$len, $extra_arg) );
|
||||
|
||||
// Testing strspn withone less than the expected number of arguments
|
||||
echo "\n-- Testing strspn() function with less than expected no. of arguments --\n";
|
||||
$str = 'string_val';
|
||||
var_dump( strspn($str) );
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : error conditions ***
|
||||
|
||||
-- Testing strspn() function with Zero arguments --
|
||||
|
||||
Warning: strspn() expects at least 2 parameters, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing strspn() function with more than expected no. of arguments --
|
||||
|
||||
Warning: strspn() expects at most 4 parameters, 5 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing strspn() function with less than expected no. of arguments --
|
||||
|
||||
Warning: strspn() expects at least 2 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
Done
|
275
ext/standard/tests/strings/strspn_variation1.phpt
Normal file
275
ext/standard/tests/strings/strspn_variation1.phpt
Normal file
@ -0,0 +1,275 @@
|
||||
--TEST--
|
||||
Test strspn() function : usage variations - unexpected values for str argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing strspn() : with different unexpected values for str argument
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : with unexpected values for str argument ***\n";
|
||||
|
||||
// Initialise function arguments not being substititued (if any)
|
||||
$mask = 'abons1234567890';
|
||||
$start = 1;
|
||||
$len = 10;
|
||||
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// declaring class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "object";
|
||||
}
|
||||
}
|
||||
|
||||
// creating a file resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
|
||||
//array of values to iterate over
|
||||
$values = array(
|
||||
|
||||
// int data
|
||||
0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float data
|
||||
10.5,
|
||||
-10.5,
|
||||
10.5e10,
|
||||
10.6E-10,
|
||||
.5,
|
||||
|
||||
// array data
|
||||
array(),
|
||||
array(0),
|
||||
array(1),
|
||||
array(1, 2),
|
||||
array('color' => 'red', 'item' => 'pen'),
|
||||
|
||||
// null data
|
||||
NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
"",
|
||||
'',
|
||||
|
||||
// object data
|
||||
new sample,
|
||||
|
||||
// undefined data
|
||||
$undefined_var,
|
||||
|
||||
// unset data
|
||||
$unset_var,
|
||||
|
||||
// resource
|
||||
$file_handle
|
||||
);
|
||||
|
||||
// loop through each element of the array for str
|
||||
|
||||
foreach($values as $value) {
|
||||
echo "\n-- Iteration with str value as \"$value\" \n";
|
||||
var_dump( strspn($value,$mask) ); // with default args
|
||||
var_dump( strspn($value,$mask,$start) ); // with default len value
|
||||
var_dump( strspn($value,$mask,$start,$len) ); // with all args
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose($file_handle);
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : with unexpected values for str argument ***
|
||||
|
||||
Notice: Undefined variable: undefined_var in %s on line %d
|
||||
|
||||
Notice: Undefined variable: unset_var in %s on line %d
|
||||
|
||||
-- Iteration with str value as "0"
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with str value as "1"
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with str value as "12345"
|
||||
int(5)
|
||||
int(4)
|
||||
int(4)
|
||||
|
||||
-- Iteration with str value as "-2345"
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
|
||||
-- Iteration with str value as "10.5"
|
||||
int(2)
|
||||
int(1)
|
||||
int(1)
|
||||
|
||||
-- Iteration with str value as "-10.5"
|
||||
int(0)
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with str value as "105000000000"
|
||||
int(12)
|
||||
int(11)
|
||||
int(10)
|
||||
|
||||
-- Iteration with str value as "1.06E-9"
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with str value as "0.5"
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with str value as "Array"
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with str value as "Array"
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with str value as "Array"
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with str value as "Array"
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with str value as "Array"
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with str value as ""
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with str value as ""
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with str value as "1"
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with str value as ""
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with str value as "1"
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with str value as ""
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with str value as ""
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with str value as ""
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with str value as "object"
|
||||
int(2)
|
||||
int(1)
|
||||
int(1)
|
||||
|
||||
-- Iteration with str value as ""
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with str value as ""
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with str value as "Resource id #%d"
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, resource given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, resource given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 1 to be string, resource given in %s on line %d
|
||||
NULL
|
||||
Done
|
274
ext/standard/tests/strings/strspn_variation10.phpt
Normal file
274
ext/standard/tests/strings/strspn_variation10.phpt
Normal file
@ -0,0 +1,274 @@
|
||||
--TEST--
|
||||
Test strspn() function : usage variations - with varying mask & default start and len args
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing strspn() : with varying mask and default start and len arguments
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : with different mask strings and default start and len arguments ***\n";
|
||||
|
||||
// initialing required variables
|
||||
// defining different strings
|
||||
$strings = array(
|
||||
"",
|
||||
'',
|
||||
"\n",
|
||||
'\n',
|
||||
"hello\tworld\nhello\nworld\n",
|
||||
'hello\tworld\nhello\nworld\n',
|
||||
"1234hello45world\t123",
|
||||
'1234hello45world\t123',
|
||||
"hello\0world\012",
|
||||
'hello\0world\012',
|
||||
chr(0).chr(0),
|
||||
chr(0)."hello\0world".chr(0),
|
||||
chr(0).'hello\0world'.chr(0),
|
||||
"hello".chr(0)."world",
|
||||
'hello'.chr(0).'world',
|
||||
"hello\0\100\xaaaworld",
|
||||
'hello\0\100\xaaaworld'
|
||||
);
|
||||
|
||||
// define the array of mask strings
|
||||
$mask_array = array(
|
||||
"",
|
||||
'',
|
||||
"f\n\trelshti \l",
|
||||
'f\n\trelsthi \l',
|
||||
"\telh",
|
||||
"t\ ",
|
||||
'\telh',
|
||||
"felh\t\ ",
|
||||
" \t",
|
||||
"fhel\t\i\100\xa"
|
||||
);
|
||||
|
||||
|
||||
// loop through each element of the array for mask argument
|
||||
|
||||
$count = 1;
|
||||
foreach($strings as $str) {
|
||||
echo "\n-- Iteration $count --\n";
|
||||
foreach($mask_array as $mask) {
|
||||
var_dump( strspn($str,$mask) );
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : with different mask strings and default start and len arguments ***
|
||||
|
||||
-- Iteration 1 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 2 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 3 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
|
||||
-- Iteration 4 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
int(2)
|
||||
int(0)
|
||||
int(1)
|
||||
int(1)
|
||||
int(1)
|
||||
int(0)
|
||||
int(1)
|
||||
|
||||
-- Iteration 5 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 6 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 7 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 8 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 9 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 10 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 11 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 12 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 13 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 14 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 15 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 16 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 17 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
Done
|
1306
ext/standard/tests/strings/strspn_variation11.phpt
Normal file
1306
ext/standard/tests/strings/strspn_variation11.phpt
Normal file
File diff suppressed because it is too large
Load Diff
2878
ext/standard/tests/strings/strspn_variation12.phpt
Normal file
2878
ext/standard/tests/strings/strspn_variation12.phpt
Normal file
File diff suppressed because it is too large
Load Diff
274
ext/standard/tests/strings/strspn_variation2.phpt
Normal file
274
ext/standard/tests/strings/strspn_variation2.phpt
Normal file
@ -0,0 +1,274 @@
|
||||
--TEST--
|
||||
Test strspn() function : usage variations - unexpected values for mask argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing strspn() : with different unexpected values for mask argument
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : with diferent unexpected values of mask argument ***\n";
|
||||
|
||||
$str = 'string_val';
|
||||
$start = 1;
|
||||
$len = 10;
|
||||
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// declaring class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "object";
|
||||
}
|
||||
}
|
||||
|
||||
// creating a file resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
|
||||
//array of values to iterate over
|
||||
$values = array(
|
||||
|
||||
// int data
|
||||
0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float data
|
||||
10.5,
|
||||
-10.5,
|
||||
10.5e10,
|
||||
10.6E-10,
|
||||
.5,
|
||||
|
||||
// array data
|
||||
array(),
|
||||
array(0),
|
||||
array(1),
|
||||
array(1, 2),
|
||||
array('color' => 'red', 'item' => 'pen'),
|
||||
|
||||
// null data
|
||||
NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
"",
|
||||
'',
|
||||
|
||||
// object data
|
||||
new sample(),
|
||||
|
||||
// undefined data
|
||||
$undefined_var,
|
||||
|
||||
// unset data
|
||||
$unset_var,
|
||||
|
||||
// resource
|
||||
$file_handle
|
||||
);
|
||||
|
||||
// loop through each element of the array for mask
|
||||
|
||||
foreach($values as $value) {
|
||||
echo "\n-- Iteration with mask value as \"$value\" -- \n";
|
||||
var_dump( strspn($str,$value) ); // with defalut args
|
||||
var_dump( strspn($str,$value,$start) ); // with default len value
|
||||
var_dump( strspn($str,$value,$start,$len) ); // with all args
|
||||
};
|
||||
|
||||
// close the resource
|
||||
fclose($file_handle);
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : with diferent unexpected values of mask argument ***
|
||||
|
||||
Notice: Undefined variable: undefined_var in %s on line %d
|
||||
|
||||
Notice: Undefined variable: unset_var in %s on line %d
|
||||
|
||||
-- Iteration with mask value as "0" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "1" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "12345" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "-2345" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "10.5" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "-10.5" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "105000000000" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "1.06E-9" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "0.5" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with mask value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with mask value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with mask value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with mask value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with mask value as "" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "1" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "1" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "object" --
|
||||
int(0)
|
||||
int(1)
|
||||
int(1)
|
||||
|
||||
-- Iteration with mask value as "" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "" --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with mask value as "Resource id #%d" --
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, resource given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, resource given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 2 to be string, resource given in %s on line %d
|
||||
NULL
|
||||
Done
|
245
ext/standard/tests/strings/strspn_variation3.phpt
Normal file
245
ext/standard/tests/strings/strspn_variation3.phpt
Normal file
@ -0,0 +1,245 @@
|
||||
--TEST--
|
||||
Test strspn() function : usage variations - unexpected values of start argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing strspn() : with unexpected values of start argument
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : with unexpected values of start argument ***\n";
|
||||
|
||||
// initialing required variables
|
||||
$str = 'string_val';
|
||||
$mask = 'soibtFTf1234567890';
|
||||
$len = 10;
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// declaring class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "object";
|
||||
}
|
||||
}
|
||||
|
||||
// creating a file resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
|
||||
//array of values to iterate over
|
||||
$values = array(
|
||||
|
||||
// float data
|
||||
10.5,
|
||||
-10.5,
|
||||
10.5e10,
|
||||
10.6E-10,
|
||||
.5,
|
||||
|
||||
// array data
|
||||
array(),
|
||||
array(0),
|
||||
array(1),
|
||||
array(1, 2),
|
||||
array('color' => 'red', 'item' => 'pen'),
|
||||
|
||||
// null data
|
||||
NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
"",
|
||||
'',
|
||||
|
||||
// string data
|
||||
"string",
|
||||
'string',
|
||||
|
||||
// object data
|
||||
new sample(),
|
||||
|
||||
// undefined data
|
||||
$undefined_var,
|
||||
|
||||
// unset data
|
||||
$unset_var,
|
||||
|
||||
// resource
|
||||
$file_handle
|
||||
);
|
||||
|
||||
// loop through each element of the array for start
|
||||
|
||||
foreach($values as $value) {
|
||||
echo "\n-- Iteration with start value as \"$value\" --\n";
|
||||
var_dump( strspn($str,$mask,$value) ); // with default len value
|
||||
var_dump( strspn($str,$mask,$value,$len) ); // with all args
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose($file_handle);
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : with unexpected values of start argument ***
|
||||
|
||||
Notice: Undefined variable: undefined_var in %s on line %d
|
||||
|
||||
Notice: Undefined variable: unset_var in %s on line %d
|
||||
|
||||
-- Iteration with start value as "10.5" --
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration with start value as "-10.5" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "105000000000" --
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
||||
-- Iteration with start value as "1.06E-9" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "0.5" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "1" --
|
||||
int(1)
|
||||
int(1)
|
||||
|
||||
-- Iteration with start value as "" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "1" --
|
||||
int(1)
|
||||
int(1)
|
||||
|
||||
-- Iteration with start value as "" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "string" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "string" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "object" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with start value as "" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "" --
|
||||
int(2)
|
||||
int(2)
|
||||
|
||||
-- Iteration with start value as "Resource id #%d" --
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, resource given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: strspn() expects parameter 3 to be long, resource given in %s on line %d
|
||||
NULL
|
||||
Done
|
198
ext/standard/tests/strings/strspn_variation4.phpt
Normal file
198
ext/standard/tests/strings/strspn_variation4.phpt
Normal file
@ -0,0 +1,198 @@
|
||||
--TEST--
|
||||
Test strspn() function : usage variations - unexpected values of len argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing strspn() : with unexpected values of len argument
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : with unexpected values of len argument ***\n";
|
||||
|
||||
// initialing required variables
|
||||
$str = 'string_val';
|
||||
$mask = 'soibtFTf1234567890';
|
||||
$start = 0;
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// declaring class
|
||||
class sample {
|
||||
public function __toString() {
|
||||
return "object";
|
||||
}
|
||||
}
|
||||
|
||||
// creating a file resource
|
||||
$file_handle = fopen(__FILE__, 'r');
|
||||
|
||||
|
||||
//array of values to iterate over
|
||||
$values = array(
|
||||
|
||||
// float data
|
||||
10.5,
|
||||
-10.5,
|
||||
10.5e10,
|
||||
10.6E-10,
|
||||
.5,
|
||||
|
||||
// array data
|
||||
array(),
|
||||
array(0),
|
||||
array(1),
|
||||
array(1, 2),
|
||||
array('color' => 'red', 'item' => 'pen'),
|
||||
|
||||
// null data
|
||||
NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
"",
|
||||
'',
|
||||
|
||||
// string data
|
||||
"string",
|
||||
'string',
|
||||
|
||||
// object data
|
||||
new sample(),
|
||||
|
||||
// undefined data
|
||||
$undefined_var,
|
||||
|
||||
// unset data
|
||||
$unset_var,
|
||||
|
||||
// resource
|
||||
$file_handle
|
||||
);
|
||||
|
||||
// loop through each element of the array for start
|
||||
|
||||
foreach($values as $value) {
|
||||
echo "\n-- Iteration with len value as \"$value\" --\n";
|
||||
var_dump( strspn($str,$mask,$start,$value) ); // with all args
|
||||
};
|
||||
|
||||
// closing the resource
|
||||
fclose($file_handle);
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : with unexpected values of len argument ***
|
||||
|
||||
Notice: Undefined variable: undefined_var in %s on line %d
|
||||
|
||||
Notice: Undefined variable: unset_var in %s on line %d
|
||||
|
||||
-- Iteration with len value as "10.5" --
|
||||
int(2)
|
||||
|
||||
-- Iteration with len value as "-10.5" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "105000000000" --
|
||||
int(2)
|
||||
|
||||
-- Iteration with len value as "1.06E-9" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "0.5" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "Array" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, array given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "1" --
|
||||
int(1)
|
||||
|
||||
-- Iteration with len value as "" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "1" --
|
||||
int(1)
|
||||
|
||||
-- Iteration with len value as "" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "string" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "string" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "object" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Iteration with len value as "" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "" --
|
||||
int(0)
|
||||
|
||||
-- Iteration with len value as "Resource id #%d" --
|
||||
|
||||
Warning: strspn() expects parameter 4 to be long, resource given in %s on line %d
|
||||
NULL
|
||||
Done
|
BIN
ext/standard/tests/strings/strspn_variation5.phpt
Normal file
BIN
ext/standard/tests/strings/strspn_variation5.phpt
Normal file
Binary file not shown.
179
ext/standard/tests/strings/strspn_variation6.phpt
Normal file
179
ext/standard/tests/strings/strspn_variation6.phpt
Normal file
@ -0,0 +1,179 @@
|
||||
--TEST--
|
||||
Test strspn() function : usage variations - with heredoc strings, varying mask & default start and len args
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing strspn() : with heredoc string, varying mask and default start and len arguments
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : with different mask strings ***\n";
|
||||
|
||||
// initialing required variables
|
||||
// defining different heredoc strings
|
||||
$empty_heredoc = <<<EOT
|
||||
EOT;
|
||||
|
||||
$heredoc_with_newline = <<<EOT
|
||||
\n
|
||||
|
||||
EOT;
|
||||
|
||||
$heredoc_with_characters = <<<EOT
|
||||
first line of heredoc string
|
||||
second line of heredoc string
|
||||
third line of heredocstring
|
||||
EOT;
|
||||
|
||||
$heredoc_with_newline_and_tabs = <<<EOT
|
||||
hello\tworld\nhello\nworld\n
|
||||
EOT;
|
||||
|
||||
$heredoc_with_alphanumerics = <<<EOT
|
||||
hello123world456
|
||||
1234hello\t1234
|
||||
EOT;
|
||||
|
||||
$heredoc_with_embedded_nulls = <<<EOT
|
||||
hello\0world\0hello
|
||||
\0hello\0
|
||||
EOT;
|
||||
|
||||
$heredoc_with_hexa_octal = <<<EOT
|
||||
hello\0\100\xaaworld\0hello
|
||||
\0hello\0
|
||||
EOT;
|
||||
|
||||
// defining array of different heredoc strings
|
||||
$heredoc_strings = array(
|
||||
$empty_heredoc,
|
||||
$heredoc_with_newline,
|
||||
$heredoc_with_characters,
|
||||
$heredoc_with_newline_and_tabs,
|
||||
$heredoc_with_alphanumerics,
|
||||
$heredoc_with_embedded_nulls,
|
||||
$heredoc_with_hexa_octal
|
||||
);
|
||||
|
||||
// defining array of different mask strings
|
||||
$mask_array = array(
|
||||
"",
|
||||
'',
|
||||
"fh\ne\trlsti \l",
|
||||
'fieh\n\trlsti \l',
|
||||
"\t",
|
||||
"lt\ ",
|
||||
'l\t',
|
||||
"fl\t\eh ",
|
||||
"l \te",
|
||||
"lf\the\i\100\xaa"
|
||||
);
|
||||
|
||||
|
||||
// loop through each element of the array for different heredoc and mask strings
|
||||
|
||||
$count = 1;
|
||||
|
||||
foreach($heredoc_strings as $str) {
|
||||
echo "\n-- Iteration $count --\n";
|
||||
foreach($mask_array as $mask) {
|
||||
var_dump( strspn($str,$mask) ); // with default start and len value
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : with different mask strings ***
|
||||
|
||||
-- Iteration 1 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 2 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
|
||||
-- Iteration 3 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(8)
|
||||
int(11)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
int(2)
|
||||
|
||||
-- Iteration 4 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 5 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 6 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
|
||||
-- Iteration 7 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(4)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(4)
|
||||
int(0)
|
||||
int(4)
|
||||
Done
|
612
ext/standard/tests/strings/strspn_variation7.phpt
Normal file
612
ext/standard/tests/strings/strspn_variation7.phpt
Normal file
@ -0,0 +1,612 @@
|
||||
--TEST--
|
||||
Test strspn() function : usage variations - with heredoc strings, varying start and default len args
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
|
||||
* Description: Finds length of initial segment consisting entirely of characters found in mask.
|
||||
If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions: none
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing strspn() : with heredoc string, varying start and default len arguments
|
||||
*/
|
||||
|
||||
echo "*** Testing strspn() : with different start values ***\n";
|
||||
|
||||
// initialing required variables
|
||||
// defining different heredoc strings
|
||||
$empty_heredoc = <<<EOT
|
||||
EOT;
|
||||
|
||||
$heredoc_with_newline = <<<EOT
|
||||
\n
|
||||
|
||||
EOT;
|
||||
|
||||
$heredoc_with_characters = <<<EOT
|
||||
first line of heredoc string
|
||||
second line of heredoc string
|
||||
third line of heredocstring
|
||||
EOT;
|
||||
|
||||
$heredoc_with_newline_and_tabs = <<<EOT
|
||||
hello\tworld\nhello\nworld\n
|
||||
EOT;
|
||||
|
||||
$heredoc_with_alphanumerics = <<<EOT
|
||||
hello123world456
|
||||
1234hello\t1234
|
||||
EOT;
|
||||
|
||||
$heredoc_with_embedded_nulls = <<<EOT
|
||||
hello\0world\0hello
|
||||
\0hello\0
|
||||
EOT;
|
||||
|
||||
$heredoc_with_hexa_octal = <<<EOT
|
||||
hello\0\100\xaaworld\0hello
|
||||
\0hello\0
|
||||
EOT;
|
||||
|
||||
// defining array of different heredoc strings
|
||||
$heredoc_strings = array(
|
||||
$empty_heredoc,
|
||||
$heredoc_with_newline,
|
||||
$heredoc_with_characters,
|
||||
$heredoc_with_newline_and_tabs,
|
||||
$heredoc_with_alphanumerics,
|
||||
$heredoc_with_embedded_nulls,
|
||||
$heredoc_with_hexa_octal
|
||||
);
|
||||
|
||||
// defining array of different mask strings
|
||||
$mask_array = array(
|
||||
"",
|
||||
'',
|
||||
"f\nh\trstie \l",
|
||||
'f\n\thrstei \l',
|
||||
"\t",
|
||||
"t\ e",
|
||||
'\t',
|
||||
"f\te\h ",
|
||||
" \t",
|
||||
"f\t\ih\100e\xa"
|
||||
);
|
||||
|
||||
// defining array of different start values
|
||||
$start_array = array(
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
-1,
|
||||
-2,
|
||||
2147483647, // max positive integer
|
||||
-2147483648, // min negative integer
|
||||
);
|
||||
|
||||
|
||||
// loop through each element of the array for heredoc strings, mask strings and start values
|
||||
|
||||
$count = 1;
|
||||
|
||||
foreach($heredoc_strings as $str) {
|
||||
echo "\n-- Iteration $count --\n";
|
||||
foreach($mask_array as $mask) {
|
||||
foreach($start_array as $start) {
|
||||
var_dump( strspn($str,$mask,$start) ); // with default len value
|
||||
}
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing strspn() : with different start values ***
|
||||
|
||||
-- Iteration 1 --
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
|
||||
-- Iteration 2 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(1)
|
||||
int(2)
|
||||
bool(false)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(1)
|
||||
int(2)
|
||||
bool(false)
|
||||
int(2)
|
||||
|
||||
-- Iteration 3 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(8)
|
||||
int(7)
|
||||
int(6)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(8)
|
||||
int(11)
|
||||
int(10)
|
||||
int(9)
|
||||
int(0)
|
||||
int(1)
|
||||
bool(false)
|
||||
int(11)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
|
||||
-- Iteration 4 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(4)
|
||||
int(3)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(4)
|
||||
int(4)
|
||||
int(3)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(4)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
|
||||
-- Iteration 5 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(4)
|
||||
int(3)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(4)
|
||||
int(4)
|
||||
int(3)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(4)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
|
||||
-- Iteration 6 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(4)
|
||||
int(3)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(4)
|
||||
int(4)
|
||||
int(3)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(4)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
|
||||
-- Iteration 7 --
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(4)
|
||||
int(3)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(4)
|
||||
int(4)
|
||||
int(3)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(4)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(0)
|
||||
int(2)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
bool(false)
|
||||
int(2)
|
||||
Done
|
1894
ext/standard/tests/strings/strspn_variation8.phpt
Normal file
1894
ext/standard/tests/strings/strspn_variation8.phpt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
ext/standard/tests/strings/strspn_variation9.phpt
Normal file
BIN
ext/standard/tests/strings/strspn_variation9.phpt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user