mirror of
https://github.com/php/php-src.git
synced 2024-09-25 20:07:26 +00:00
New testcases for ucwords() function
This commit is contained in:
parent
e47194d4dc
commit
fdf0a9e6a1
125
ext/standard/tests/strings/ucwords_basic.phpt
Normal file
125
ext/standard/tests/strings/ucwords_basic.phpt
Normal file
@ -0,0 +1,125 @@
|
||||
--TEST--
|
||||
Test ucwords() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string ucwords ( string $str )
|
||||
* Description: Uppercase the first character of each word in a string
|
||||
* Source code: ext/standard/string.c
|
||||
*/
|
||||
|
||||
echo "*** Testing ucwords() : basic functionality ***\n";
|
||||
|
||||
// lines with different whitespace charecter
|
||||
$str_array = array(
|
||||
"testing ucwords",
|
||||
'testing ucwords',
|
||||
'testing\tucwords',
|
||||
"testing\tucwords",
|
||||
"testing\nucwords",
|
||||
'testing\nucwords',
|
||||
"testing\vucwords",
|
||||
'testing\vucwords',
|
||||
"testing",
|
||||
'testing',
|
||||
' testing',
|
||||
" testing",
|
||||
"testing ucwords",
|
||||
'testing ucwords',
|
||||
'testing\rucwords',
|
||||
"testing\rucwords",
|
||||
'testing\fucwords',
|
||||
"testing\fucwords"
|
||||
);
|
||||
|
||||
// loop through the $strings array to test ucwords on each element
|
||||
$iteration = 1;
|
||||
for($index = 0; $index < count($str_array); $index++) {
|
||||
echo "-- Iteration $iteration --\n";
|
||||
var_dump( ucwords($str_array[$index]) );
|
||||
$iteration++;
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing ucwords() : basic functionality ***
|
||||
-- Iteration 1 --
|
||||
string(15) "Testing Ucwords"
|
||||
-- Iteration 2 --
|
||||
string(15) "Testing Ucwords"
|
||||
-- Iteration 3 --
|
||||
string(16) "Testing\tucwords"
|
||||
-- Iteration 4 --
|
||||
string(15) "Testing Ucwords"
|
||||
-- Iteration 5 --
|
||||
string(15) "Testing
|
||||
Ucwords"
|
||||
-- Iteration 6 --
|
||||
string(16) "Testing\nucwords"
|
||||
-- Iteration 7 --
|
||||
string(16) "Testing\vucwords"
|
||||
-- Iteration 8 --
|
||||
string(16) "Testing\vucwords"
|
||||
-- Iteration 9 --
|
||||
string(7) "Testing"
|
||||
-- Iteration 10 --
|
||||
string(7) "Testing"
|
||||
-- Iteration 11 --
|
||||
string(8) " Testing"
|
||||
-- Iteration 12 --
|
||||
string(8) " Testing"
|
||||
-- Iteration 13 --
|
||||
string(16) "Testing Ucwords"
|
||||
-- Iteration 14 --
|
||||
string(16) "Testing Ucwords"
|
||||
-- Iteration 15 --
|
||||
string(16) "Testing\rucwords"
|
||||
-- Iteration 16 --
|
||||
string(15) "Testing
|
||||
Ucwords"
|
||||
-- Iteration 17 --
|
||||
string(16) "Testing\fucwords"
|
||||
-- Iteration 18 --
|
||||
string(16) "Testing\fucwords"
|
||||
Done
|
||||
--UEXPECTF--
|
||||
*** Testing ucwords() : basic functionality ***
|
||||
-- Iteration 1 --
|
||||
unicode(15) "Testing Ucwords"
|
||||
-- Iteration 2 --
|
||||
unicode(15) "Testing Ucwords"
|
||||
-- Iteration 3 --
|
||||
unicode(16) "Testing\tucwords"
|
||||
-- Iteration 4 --
|
||||
unicode(15) "Testing Ucwords"
|
||||
-- Iteration 5 --
|
||||
unicode(15) "Testing
|
||||
Ucwords"
|
||||
-- Iteration 6 --
|
||||
unicode(16) "Testing\nucwords"
|
||||
-- Iteration 7 --
|
||||
unicode(16) "Testing\vucwords"
|
||||
-- Iteration 8 --
|
||||
unicode(16) "Testing\vucwords"
|
||||
-- Iteration 9 --
|
||||
unicode(7) "Testing"
|
||||
-- Iteration 10 --
|
||||
unicode(7) "Testing"
|
||||
-- Iteration 11 --
|
||||
unicode(8) " Testing"
|
||||
-- Iteration 12 --
|
||||
unicode(8) " Testing"
|
||||
-- Iteration 13 --
|
||||
unicode(16) "Testing Ucwords"
|
||||
-- Iteration 14 --
|
||||
unicode(16) "Testing Ucwords"
|
||||
-- Iteration 15 --
|
||||
unicode(16) "Testing\rucwords"
|
||||
-- Iteration 16 --
|
||||
unicode(15) "Testing
|
||||
Ucwords"
|
||||
-- Iteration 17 --
|
||||
unicode(16) "Testing\fucwords"
|
||||
-- Iteration 18 --
|
||||
unicode(16) "Testing\fucwords"
|
||||
Done
|
55
ext/standard/tests/strings/ucwords_error.phpt
Normal file
55
ext/standard/tests/strings/ucwords_error.phpt
Normal file
@ -0,0 +1,55 @@
|
||||
--TEST--
|
||||
Test ucwords() function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string ucwords ( string $str )
|
||||
* Description: Uppercase the first character of each word in a string
|
||||
* Source code: ext/standard/string.c
|
||||
*/
|
||||
|
||||
echo "*** Testing ucwords() : error conditions ***\n";
|
||||
|
||||
// Zero argument
|
||||
echo "\n-- Testing ucwords() function with Zero arguments --\n";
|
||||
var_dump( ucwords() );
|
||||
|
||||
// More than expected number of arguments
|
||||
echo "\n-- Testing ucwords() function with more than expected no. of arguments --\n";
|
||||
$str = 'string_val';
|
||||
$extra_arg = 10;
|
||||
|
||||
var_dump( ucwords($str, $extra_arg) );
|
||||
|
||||
// check if there were any changes made to $str
|
||||
var_dump($str);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing ucwords() : error conditions ***
|
||||
|
||||
-- Testing ucwords() function with Zero arguments --
|
||||
|
||||
Warning: ucwords() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing ucwords() function with more than expected no. of arguments --
|
||||
|
||||
Warning: ucwords() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
NULL
|
||||
string(10) "string_val"
|
||||
Done
|
||||
--UEXPECTF--
|
||||
*** Testing ucwords() : error conditions ***
|
||||
|
||||
-- Testing ucwords() function with Zero arguments --
|
||||
|
||||
Warning: ucwords() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing ucwords() function with more than expected no. of arguments --
|
||||
|
||||
Warning: ucwords() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
NULL
|
||||
unicode(10) "string_val"
|
||||
Done
|
290
ext/standard/tests/strings/ucwords_variation1.phpt
Normal file
290
ext/standard/tests/strings/ucwords_variation1.phpt
Normal file
@ -0,0 +1,290 @@
|
||||
--TEST--
|
||||
Test ucwords() function : usage variations - unexpected input values
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string ucwords ( string $str )
|
||||
* Description: Uppercase the first character of each word in a string
|
||||
* Source code: ext/standard/string.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test ucwords() by passing different values including scalar and non scalar values
|
||||
*/
|
||||
|
||||
echo "*** Testing ucwords() : usage variations ***\n";
|
||||
// initialize all required variables
|
||||
|
||||
// get an unset variable
|
||||
$unset_var = 'string_val';
|
||||
unset($unset_var);
|
||||
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
class my
|
||||
{
|
||||
function __toString() {
|
||||
return "myString";
|
||||
}
|
||||
}
|
||||
|
||||
// array with different values
|
||||
$values = array (
|
||||
|
||||
// integer values
|
||||
0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// hex values
|
||||
0x10,
|
||||
0X20,
|
||||
0xAA,
|
||||
-0XF5,
|
||||
|
||||
// octal values
|
||||
0123,
|
||||
-0342,
|
||||
|
||||
// float values
|
||||
10.5,
|
||||
-10.5,
|
||||
10.5e10,
|
||||
10.6E-10,
|
||||
.5,
|
||||
|
||||
// array values
|
||||
array(),
|
||||
array(0),
|
||||
array(1),
|
||||
array(1, 2),
|
||||
array('color' => 'red', 'item' => 'pen'),
|
||||
|
||||
// boolean values
|
||||
true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// objects
|
||||
new my(),
|
||||
|
||||
// empty string
|
||||
"",
|
||||
'',
|
||||
|
||||
//NULL
|
||||
NULL,
|
||||
null,
|
||||
|
||||
// hex in string
|
||||
"0x123",
|
||||
'0x123',
|
||||
"0xFF12",
|
||||
"-0xFF12",
|
||||
|
||||
// undefined variable
|
||||
@$undefined_var,
|
||||
|
||||
// unset variable
|
||||
@$unset_var,
|
||||
|
||||
// resource variable
|
||||
$fp
|
||||
);
|
||||
|
||||
// loop through each element of the array and check the working of ucwords()
|
||||
// when $str arugment is supplied with different values
|
||||
echo "\n--- Testing ucwords() by supplying different values for 'str' argument ---\n";
|
||||
$counter = 1;
|
||||
for($index = 0; $index < count($values); $index ++) {
|
||||
echo "-- Iteration $counter --\n";
|
||||
$str = $values [$index];
|
||||
|
||||
var_dump( ucwords($str) );
|
||||
|
||||
$counter ++;
|
||||
}
|
||||
|
||||
// close the file handle
|
||||
fclose($fp);
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing ucwords() : usage variations ***
|
||||
|
||||
--- Testing ucwords() by supplying different values for 'str' argument ---
|
||||
-- Iteration 1 --
|
||||
string(1) "0"
|
||||
-- Iteration 2 --
|
||||
string(1) "1"
|
||||
-- Iteration 3 --
|
||||
string(5) "12345"
|
||||
-- Iteration 4 --
|
||||
string(5) "-2345"
|
||||
-- Iteration 5 --
|
||||
string(2) "16"
|
||||
-- Iteration 6 --
|
||||
string(2) "32"
|
||||
-- Iteration 7 --
|
||||
string(3) "170"
|
||||
-- Iteration 8 --
|
||||
string(4) "-245"
|
||||
-- Iteration 9 --
|
||||
string(2) "83"
|
||||
-- Iteration 10 --
|
||||
string(4) "-226"
|
||||
-- Iteration 11 --
|
||||
string(4) "10.5"
|
||||
-- Iteration 12 --
|
||||
string(5) "-10.5"
|
||||
-- Iteration 13 --
|
||||
string(12) "105000000000"
|
||||
-- Iteration 14 --
|
||||
string(7) "1.06E-9"
|
||||
-- Iteration 15 --
|
||||
string(3) "0.5"
|
||||
-- Iteration 16 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 21 --
|
||||
string(1) "1"
|
||||
-- Iteration 22 --
|
||||
string(0) ""
|
||||
-- Iteration 23 --
|
||||
string(1) "1"
|
||||
-- Iteration 24 --
|
||||
string(0) ""
|
||||
-- Iteration 25 --
|
||||
string(8) "MyString"
|
||||
-- Iteration 26 --
|
||||
string(0) ""
|
||||
-- Iteration 27 --
|
||||
string(0) ""
|
||||
-- Iteration 28 --
|
||||
string(0) ""
|
||||
-- Iteration 29 --
|
||||
string(0) ""
|
||||
-- Iteration 30 --
|
||||
string(5) "0x123"
|
||||
-- Iteration 31 --
|
||||
string(5) "0x123"
|
||||
-- Iteration 32 --
|
||||
string(6) "0xFF12"
|
||||
-- Iteration 33 --
|
||||
string(7) "-0xFF12"
|
||||
-- Iteration 34 --
|
||||
string(0) ""
|
||||
-- Iteration 35 --
|
||||
string(0) ""
|
||||
-- Iteration 36 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d
|
||||
NULL
|
||||
Done
|
||||
--UEXPECTF--
|
||||
*** Testing ucwords() : usage variations ***
|
||||
|
||||
--- Testing ucwords() by supplying different values for 'str' argument ---
|
||||
-- Iteration 1 --
|
||||
unicode(1) "0"
|
||||
-- Iteration 2 --
|
||||
unicode(1) "1"
|
||||
-- Iteration 3 --
|
||||
unicode(5) "12345"
|
||||
-- Iteration 4 --
|
||||
unicode(5) "-2345"
|
||||
-- Iteration 5 --
|
||||
unicode(2) "16"
|
||||
-- Iteration 6 --
|
||||
unicode(2) "32"
|
||||
-- Iteration 7 --
|
||||
unicode(3) "170"
|
||||
-- Iteration 8 --
|
||||
unicode(4) "-245"
|
||||
-- Iteration 9 --
|
||||
unicode(2) "83"
|
||||
-- Iteration 10 --
|
||||
unicode(4) "-226"
|
||||
-- Iteration 11 --
|
||||
unicode(4) "10.5"
|
||||
-- Iteration 12 --
|
||||
unicode(5) "-10.5"
|
||||
-- Iteration 13 --
|
||||
unicode(12) "105000000000"
|
||||
-- Iteration 14 --
|
||||
unicode(7) "1.06E-9"
|
||||
-- Iteration 15 --
|
||||
unicode(3) "0.5"
|
||||
-- Iteration 16 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||
NULL
|
||||
-- Iteration 21 --
|
||||
unicode(1) "1"
|
||||
-- Iteration 22 --
|
||||
unicode(0) ""
|
||||
-- Iteration 23 --
|
||||
unicode(1) "1"
|
||||
-- Iteration 24 --
|
||||
unicode(0) ""
|
||||
-- Iteration 25 --
|
||||
unicode(8) "MyString"
|
||||
-- Iteration 26 --
|
||||
unicode(0) ""
|
||||
-- Iteration 27 --
|
||||
unicode(0) ""
|
||||
-- Iteration 28 --
|
||||
unicode(0) ""
|
||||
-- Iteration 29 --
|
||||
unicode(0) ""
|
||||
-- Iteration 30 --
|
||||
unicode(5) "0x123"
|
||||
-- Iteration 31 --
|
||||
unicode(5) "0x123"
|
||||
-- Iteration 32 --
|
||||
unicode(6) "0xFF12"
|
||||
-- Iteration 33 --
|
||||
unicode(7) "-0xFF12"
|
||||
-- Iteration 34 --
|
||||
unicode(0) ""
|
||||
-- Iteration 35 --
|
||||
unicode(0) ""
|
||||
-- Iteration 36 --
|
||||
|
||||
Warning: ucwords() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d
|
||||
NULL
|
||||
Done
|
125
ext/standard/tests/strings/ucwords_variation2.phpt
Normal file
125
ext/standard/tests/strings/ucwords_variation2.phpt
Normal file
@ -0,0 +1,125 @@
|
||||
--TEST--
|
||||
Test ucwords() function : usage variations - heredoc strings
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string ucwords ( string $str )
|
||||
* Description: Uppercase the first character of each word in a string
|
||||
* Source code: ext/standard/string.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* test ucwords() with different string prepared using heredoc
|
||||
*/
|
||||
|
||||
echo "*** Testing ucwords() : usage variations ***\n";
|
||||
|
||||
// Null here doc string
|
||||
$null_string = <<<EOT
|
||||
EOT;
|
||||
|
||||
// Heredoc string with blank line
|
||||
$blank_line = <<<EOT
|
||||
|
||||
EOT;
|
||||
|
||||
// here doc with multiline string
|
||||
$multiline_string = <<<EOT
|
||||
testing ucword() with
|
||||
multiline string using
|
||||
heredoc
|
||||
EOT;
|
||||
|
||||
// here doc with diferent whitespaces
|
||||
$diff_whitespaces = <<<EOT
|
||||
testing\rucword(str)\twith
|
||||
multiline string\t\tusing
|
||||
heredoc\nstring.with\vdifferent\fwhite\vspaces
|
||||
EOT;
|
||||
|
||||
// here doc with numeric values
|
||||
$numeric_string = <<<EOT
|
||||
12sting 123string 4567
|
||||
string\t123string\r12 test\n5test
|
||||
EOT;
|
||||
|
||||
// heredoc with quote chars & slash
|
||||
$quote_char_string = <<<EOT
|
||||
it's bright,but i cann't see it.
|
||||
"things in double quote"
|
||||
'things in single quote'
|
||||
this\line is /with\slashs
|
||||
EOT;
|
||||
|
||||
$heredoc_strings = array(
|
||||
$null_string,
|
||||
$blank_line,
|
||||
$multiline_string,
|
||||
$diff_whitespaces,
|
||||
$numeric_string,
|
||||
$quote_char_string
|
||||
);
|
||||
|
||||
// loop through $heredoc_strings element and check the working on ucwords()
|
||||
$count = 1;
|
||||
for($index =0; $index < count($heredoc_strings); $index ++) {
|
||||
echo "-- Iteration $count --\n";
|
||||
var_dump( ucwords($heredoc_strings[$index]) );
|
||||
$count ++;
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing ucwords() : usage variations ***
|
||||
-- Iteration 1 --
|
||||
string(0) ""
|
||||
-- Iteration 2 --
|
||||
string(0) ""
|
||||
-- Iteration 3 --
|
||||
string(52) "Testing Ucword() With
|
||||
Multiline String Using
|
||||
Heredoc"
|
||||
-- Iteration 4 --
|
||||
string(96) "Testing
|
||||
Ucword(str) With
|
||||
Multiline String Using
|
||||
Heredoc
|
||||
String.with\vdifferent\fwhite\vspaces"
|
||||
-- Iteration 5 --
|
||||
string(53) "12sting 123string 4567
|
||||
String 123string
|
||||
12 Test
|
||||
5test"
|
||||
-- Iteration 6 --
|
||||
string(108) "It's Bright,but I Cann't See It.
|
||||
"things In Double Quote"
|
||||
'things In Single Quote'
|
||||
This\line Is /with\slashs"
|
||||
Done
|
||||
--UEXPECTF--
|
||||
*** Testing ucwords() : usage variations ***
|
||||
-- Iteration 1 --
|
||||
unicode(0) ""
|
||||
-- Iteration 2 --
|
||||
unicode(0) ""
|
||||
-- Iteration 3 --
|
||||
unicode(52) "Testing Ucword() With
|
||||
Multiline String Using
|
||||
Heredoc"
|
||||
-- Iteration 4 --
|
||||
unicode(96) "Testing
|
||||
Ucword(str) With
|
||||
Multiline String Using
|
||||
Heredoc
|
||||
String.with\vdifferent\fwhite\vspaces"
|
||||
-- Iteration 5 --
|
||||
unicode(53) "12sting 123string 4567
|
||||
String 123string
|
||||
12 Test
|
||||
5test"
|
||||
-- Iteration 6 --
|
||||
unicode(108) "It's Bright,but I Cann't See It.
|
||||
"things In Double Quote"
|
||||
'things In Single Quote'
|
||||
This\line Is /with\slashs"
|
||||
Done
|
136
ext/standard/tests/strings/ucwords_variation3.phpt
Normal file
136
ext/standard/tests/strings/ucwords_variation3.phpt
Normal file
@ -0,0 +1,136 @@
|
||||
--TEST--
|
||||
Test ucwords() function : usage variations - single quoted string
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string ucwords ( string $str )
|
||||
* Description: Uppercase the first character of each word in a string
|
||||
* Source code: ext/standard/string.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* test ucwords() with different string prepared using single quote
|
||||
*/
|
||||
|
||||
echo "*** Testing ucwords() : usage variations ***\n";
|
||||
|
||||
// different strings containing regular chars and special chars
|
||||
$str_array = array(
|
||||
// multiple spaces
|
||||
'testing ucwords',
|
||||
't e s t i n g u c w o r d s ',
|
||||
|
||||
// brackets in sentence
|
||||
'testing function(ucwords)',
|
||||
'(testing ( function (ucwords) )a )test',
|
||||
'(t)',
|
||||
' ( t )t',
|
||||
|
||||
// using quote chars in sentence
|
||||
'"testing",ucwords,"test"',
|
||||
'"t""t",test, t',
|
||||
'\'t \'t\',test',
|
||||
|
||||
// using other white spaces
|
||||
'\ttesting\ttesting\tucwords',
|
||||
'testing\rucwords testing ucwords',
|
||||
'testing\fucwords \f testing \nucwords',
|
||||
'\ntesting\nucwords\n testing \n ucwords',
|
||||
'using\vvertical\vtab',
|
||||
|
||||
//using special chars in sentence
|
||||
't@@#$% %test ^test &test *test +test -test',
|
||||
'!test ~test `test` =test= @test@test.com',
|
||||
'/test/r\test\ ucwords\t\y\yu\3 \yy\ /uu/',
|
||||
|
||||
//only special chars
|
||||
'!@#$%^&*()_+=-`~'
|
||||
);
|
||||
|
||||
// loop through the $str_array array to test ucwords on each element
|
||||
$iteration = 1;
|
||||
for($index = 0; $index < count($str_array); $index++) {
|
||||
echo "-- Iteration $iteration --\n";
|
||||
var_dump( ucwords($str_array[$index]) );
|
||||
$iteration++;
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing ucwords() : usage variations ***
|
||||
-- Iteration 1 --
|
||||
string(18) "Testing Ucwords"
|
||||
-- Iteration 2 --
|
||||
string(30) "T E S T I N G U C W O R D S "
|
||||
-- Iteration 3 --
|
||||
string(25) "Testing Function(ucwords)"
|
||||
-- Iteration 4 --
|
||||
string(38) "(testing ( Function (ucwords) )a )test"
|
||||
-- Iteration 5 --
|
||||
string(3) "(t)"
|
||||
-- Iteration 6 --
|
||||
string(7) " ( T )t"
|
||||
-- Iteration 7 --
|
||||
string(24) ""testing",ucwords,"test""
|
||||
-- Iteration 8 --
|
||||
string(14) ""t""t",test, T"
|
||||
-- Iteration 9 --
|
||||
string(11) "'t 't',test"
|
||||
-- Iteration 10 --
|
||||
string(27) "\ttesting\ttesting\tucwords"
|
||||
-- Iteration 11 --
|
||||
string(32) "Testing\rucwords Testing Ucwords"
|
||||
-- Iteration 12 --
|
||||
string(37) "Testing\fucwords \f Testing \nucwords"
|
||||
-- Iteration 13 --
|
||||
string(39) "\ntesting\nucwords\n Testing \n Ucwords"
|
||||
-- Iteration 14 --
|
||||
string(20) "Using\vvertical\vtab"
|
||||
-- Iteration 15 --
|
||||
string(42) "T@@#$% %test ^test &test *test +test -test"
|
||||
-- Iteration 16 --
|
||||
string(40) "!test ~test `test` =test= @test@test.com"
|
||||
-- Iteration 17 --
|
||||
string(40) "/test/r\test\ Ucwords\t\y\yu\3 \yy\ /uu/"
|
||||
-- Iteration 18 --
|
||||
string(16) "!@#$%^&*()_+=-`~"
|
||||
Done
|
||||
--UEXPECTF--
|
||||
*** Testing ucwords() : usage variations ***
|
||||
-- Iteration 1 --
|
||||
unicode(18) "Testing Ucwords"
|
||||
-- Iteration 2 --
|
||||
unicode(30) "T E S T I N G U C W O R D S "
|
||||
-- Iteration 3 --
|
||||
unicode(25) "Testing Function(ucwords)"
|
||||
-- Iteration 4 --
|
||||
unicode(38) "(testing ( Function (ucwords) )a )test"
|
||||
-- Iteration 5 --
|
||||
unicode(3) "(t)"
|
||||
-- Iteration 6 --
|
||||
unicode(7) " ( T )t"
|
||||
-- Iteration 7 --
|
||||
unicode(24) ""testing",ucwords,"test""
|
||||
-- Iteration 8 --
|
||||
unicode(14) ""t""t",test, T"
|
||||
-- Iteration 9 --
|
||||
unicode(11) "'t 't',test"
|
||||
-- Iteration 10 --
|
||||
unicode(27) "\ttesting\ttesting\tucwords"
|
||||
-- Iteration 11 --
|
||||
unicode(32) "Testing\rucwords Testing Ucwords"
|
||||
-- Iteration 12 --
|
||||
unicode(37) "Testing\fucwords \f Testing \nucwords"
|
||||
-- Iteration 13 --
|
||||
unicode(39) "\ntesting\nucwords\n Testing \n Ucwords"
|
||||
-- Iteration 14 --
|
||||
unicode(20) "Using\vvertical\vtab"
|
||||
-- Iteration 15 --
|
||||
unicode(42) "T@@#$% %test ^test &test *test +test -test"
|
||||
-- Iteration 16 --
|
||||
unicode(40) "!test ~test `test` =test= @test@test.com"
|
||||
-- Iteration 17 --
|
||||
unicode(40) "/test/r\test\ Ucwords\t\y\yu\3 \yy\ /uu/"
|
||||
-- Iteration 18 --
|
||||
unicode(16) "!@#$%^&*()_+=-`~"
|
||||
Done
|
185
ext/standard/tests/strings/ucwords_variation4.phpt
Normal file
185
ext/standard/tests/strings/ucwords_variation4.phpt
Normal file
@ -0,0 +1,185 @@
|
||||
--TEST--
|
||||
Test ucwords() function : usage variations - double quoted string
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string ucwords ( string $str )
|
||||
* Description: Uppercase the first character of each word in a string
|
||||
* Source code: ext/standard/string.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* test ucwords() with different string prepared using double quote
|
||||
*/
|
||||
|
||||
echo "*** Testing ucwords() : usage variations ***\n";
|
||||
|
||||
// different strings containing regular chars and special chars
|
||||
$str_array = array(
|
||||
// multiple spaces
|
||||
"testing ucwords",
|
||||
"t e s t i n g u c w o r d s ",
|
||||
|
||||
// brackets in sentence
|
||||
"testing function(ucwords)",
|
||||
"(testing ( function (ucwords) )a )test",
|
||||
"(t)",
|
||||
" ( t )t",
|
||||
|
||||
// using quote chars in sentence
|
||||
"\"testing\",ucwords,\"test\"",
|
||||
"\"t\"\"t\",test, t",
|
||||
"\'t \'t\',test",
|
||||
"Jack's pen",
|
||||
"P't'y 't it's ",
|
||||
|
||||
// using other white spaces
|
||||
"\ttesting\ttesting\tucwords",
|
||||
"\\ttesting\\ttesting\tucwords",
|
||||
"testing\rucwords testing ucwords",
|
||||
"testing\\rucwords testing ucwords",
|
||||
"testing\fucwords \f testing \nucwords",
|
||||
"testing\\fucwords \\f testing \nucwords",
|
||||
"\ntesting\nucwords\n testing \n ucwords",
|
||||
"\\ntesting\\nucwords\\n testing \\n ucwords",
|
||||
"using\vvertical\vtab",
|
||||
"using\\vvertical\\vtab",
|
||||
|
||||
//using special chars in sentence
|
||||
"t@@#$% %test ^test &test *test +test -test",
|
||||
"!test ~test `test` =test= @test@test.com",
|
||||
"/test/r\test\ ucwords\t\y\y\3 \yy\ /uu/",
|
||||
|
||||
//only special chars
|
||||
"!@#$%^&*()_+=-`~"
|
||||
);
|
||||
|
||||
// loop through the $str_array array to test ucwords on each element
|
||||
$iteration = 1;
|
||||
for($index = 0; $index < count($str_array); $index++) {
|
||||
echo "-- Iteration $iteration --\n";
|
||||
var_dump( ucwords($str_array[$index]) );
|
||||
$iteration++;
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing ucwords() : usage variations ***
|
||||
-- Iteration 1 --
|
||||
string(18) "Testing Ucwords"
|
||||
-- Iteration 2 --
|
||||
string(30) "T E S T I N G U C W O R D S "
|
||||
-- Iteration 3 --
|
||||
string(25) "Testing Function(ucwords)"
|
||||
-- Iteration 4 --
|
||||
string(38) "(testing ( Function (ucwords) )a )test"
|
||||
-- Iteration 5 --
|
||||
string(3) "(t)"
|
||||
-- Iteration 6 --
|
||||
string(7) " ( T )t"
|
||||
-- Iteration 7 --
|
||||
string(24) ""testing",ucwords,"test""
|
||||
-- Iteration 8 --
|
||||
string(14) ""t""t",test, T"
|
||||
-- Iteration 9 --
|
||||
string(14) "\'t \'t\',test"
|
||||
-- Iteration 10 --
|
||||
string(10) "Jack's Pen"
|
||||
-- Iteration 11 --
|
||||
string(14) "P't'y 't It's "
|
||||
-- Iteration 12 --
|
||||
string(24) " Testing Testing Ucwords"
|
||||
-- Iteration 13 --
|
||||
string(26) "\ttesting\ttesting Ucwords"
|
||||
-- Iteration 14 --
|
||||
string(31) "Testing
|
||||
Ucwords Testing Ucwords"
|
||||
-- Iteration 15 --
|
||||
string(32) "Testing\rucwords Testing Ucwords"
|
||||
-- Iteration 16 --
|
||||
string(36) "Testing\fucwords \f Testing
|
||||
Ucwords"
|
||||
-- Iteration 17 --
|
||||
string(36) "Testing\fucwords \f Testing
|
||||
Ucwords"
|
||||
-- Iteration 18 --
|
||||
string(35) "
|
||||
Testing
|
||||
Ucwords
|
||||
Testing
|
||||
Ucwords"
|
||||
-- Iteration 19 --
|
||||
string(39) "\ntesting\nucwords\n Testing \n Ucwords"
|
||||
-- Iteration 20 --
|
||||
string(20) "Using\vvertical\vtab"
|
||||
-- Iteration 21 --
|
||||
string(20) "Using\vvertical\vtab"
|
||||
-- Iteration 22 --
|
||||
string(42) "T@@#$% %test ^test &test *test +test -test"
|
||||
-- Iteration 23 --
|
||||
string(40) "!test ~test `test` =test= @test@test.com"
|
||||
-- Iteration 24 --
|
||||
string(36) "/test/r Est\ Ucwords \y\y \yy\ /uu/"
|
||||
-- Iteration 25 --
|
||||
string(16) "!@#$%^&*()_+=-`~"
|
||||
Done
|
||||
--UEXPECTF--
|
||||
*** Testing ucwords() : usage variations ***
|
||||
-- Iteration 1 --
|
||||
unicode(18) "Testing Ucwords"
|
||||
-- Iteration 2 --
|
||||
unicode(30) "T E S T I N G U C W O R D S "
|
||||
-- Iteration 3 --
|
||||
unicode(25) "Testing Function(ucwords)"
|
||||
-- Iteration 4 --
|
||||
unicode(38) "(testing ( Function (ucwords) )a )test"
|
||||
-- Iteration 5 --
|
||||
unicode(3) "(t)"
|
||||
-- Iteration 6 --
|
||||
unicode(7) " ( T )t"
|
||||
-- Iteration 7 --
|
||||
unicode(24) ""testing",ucwords,"test""
|
||||
-- Iteration 8 --
|
||||
unicode(14) ""t""t",test, T"
|
||||
-- Iteration 9 --
|
||||
unicode(14) "\'t \'t\',test"
|
||||
-- Iteration 10 --
|
||||
unicode(10) "Jack's Pen"
|
||||
-- Iteration 11 --
|
||||
unicode(14) "P't'y 't It's "
|
||||
-- Iteration 12 --
|
||||
unicode(24) " Testing Testing Ucwords"
|
||||
-- Iteration 13 --
|
||||
unicode(26) "\ttesting\ttesting Ucwords"
|
||||
-- Iteration 14 --
|
||||
unicode(31) "Testing
|
||||
Ucwords Testing Ucwords"
|
||||
-- Iteration 15 --
|
||||
unicode(32) "Testing\rucwords Testing Ucwords"
|
||||
-- Iteration 16 --
|
||||
unicode(36) "Testing\fucwords \f Testing
|
||||
Ucwords"
|
||||
-- Iteration 17 --
|
||||
unicode(36) "Testing\fucwords \f Testing
|
||||
Ucwords"
|
||||
-- Iteration 18 --
|
||||
unicode(35) "
|
||||
Testing
|
||||
Ucwords
|
||||
Testing
|
||||
Ucwords"
|
||||
-- Iteration 19 --
|
||||
unicode(39) "\ntesting\nucwords\n Testing \n Ucwords"
|
||||
-- Iteration 20 --
|
||||
unicode(20) "Using\vvertical\vtab"
|
||||
-- Iteration 21 --
|
||||
unicode(20) "Using\vvertical\vtab"
|
||||
-- Iteration 22 --
|
||||
unicode(42) "T@@#$% %test ^test &test *test +test -test"
|
||||
-- Iteration 23 --
|
||||
unicode(40) "!test ~test `test` =test= @test@test.com"
|
||||
-- Iteration 24 --
|
||||
unicode(36) "/test/r Est\ Ucwords \y\y \yy\ /uu/"
|
||||
-- Iteration 25 --
|
||||
unicode(16) "!@#$%^&*()_+=-`~"
|
||||
Done
|
Loading…
Reference in New Issue
Block a user