Skip to content

Commit 777ce7d

Browse files
authored
test fprintf (#1599)
1 parent 02f6a1d commit 777ce7d

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
@ok
2+
This test is copy of ext/standard/tests/strings/fprintf_variation_009.phpt of php-src repo
3+
--TEST--
4+
Test fprintf() function (variation - 9)
5+
--FILE--
6+
<?php
7+
8+
$string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" );
9+
$strings = array( NULL, "abc", 'aaa' );
10+
11+
if (!($fp = fopen('php://stdout', 'w')))
12+
return;
13+
14+
$counter = 1;
15+
/* string type variations */
16+
fprintf($fp, "\n*** Testing fprintf() for string types ***\n");
17+
foreach( $string_variation as $string_var ) {
18+
fprintf( $fp, "\n-- Iteration %d --\n",$counter);
19+
foreach( $strings as $str ) {
20+
fprintf( $fp, "\n");
21+
fprintf( $fp, $string_var, $str );
22+
}
23+
$counter++;
24+
}
25+
26+
fclose($fp);
27+
28+
echo "\nDone";
29+
30+
?>
31+
--EXPECT--
32+
*** Testing fprintf() for string types ***
33+
34+
-- Iteration 1 --
35+
36+
37+
abc
38+
aaa
39+
-- Iteration 2 --
40+
41+
42+
abc
43+
aaa
44+
-- Iteration 3 --
45+
46+
00000
47+
00abc
48+
00aaa
49+
-- Iteration 4 --
50+
51+
#####
52+
##abc
53+
##aaa
54+
Done

0 commit comments

Comments
 (0)