From f9596816cc6b1ef0280615fd38081ee0520788d8 Mon Sep 17 00:00:00 2001 From: Zoe Slattery Date: Wed, 28 Mar 2007 09:41:55 +0000 Subject: [PATCH] new test for printf --- ext/standard/tests/strings/printf.phpt | 689 +++++++++++++++++++++++++ 1 file changed, 689 insertions(+) create mode 100755 ext/standard/tests/strings/printf.phpt diff --git a/ext/standard/tests/strings/printf.phpt b/ext/standard/tests/strings/printf.phpt new file mode 100755 index 0000000000..a885fc32bb --- /dev/null +++ b/ext/standard/tests/strings/printf.phpt @@ -0,0 +1,689 @@ +--TEST-- +Test printf() function +--FILE-- + +--EXPECTF-- +*** Output for zero argument *** + +Warning: Wrong parameter count for printf() in %s on line %d + +*** Output for insufficient number of arguments *** + +Warning: printf(): Too few arguments in %s on line %d + +*** Output for scalar argument *** +3 +*** Output for NULL as argument *** + + +*** Output for float type *** + + Input Float numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 0.32 + [4] => -0.32 + [5] => 3.4-3.4 + [6] => 2.54 + [7] => -2.54 + [8] => 1.2345678E+99 + [9] => -1.2345678E+99 +) + + +Float Iteration 1 +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567%d.000000 +-1234567%d.000000 + +Float Iteration 2 +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567%d.000000 +-1234567%d.000000 + +Float Iteration 3 ++0.000000 ++1.000000 +-1.000000 ++0.320000 +-0.320000 ++3.400000 ++2.540000 +-2.540000 ++1234567%d.000000 +-1234567%d.000000 + +Float Iteration 4 + 0.00 + 1.00 + -1.00 + 0.32 + -0.32 + 3.40 + 2.54 + -2.54 +1234567%d.00 +-1234567%d.00 + +Float Iteration 5 +0.00 +1.00 +-1.00 +0.32 +-0.32 +3.40 +2.54 +-2.54 +1234567%d.00 +-1234567%d.00 + +Float Iteration 6 +0000.00 +0001.00 +-001.00 +0000.32 +-000.32 +0003.40 +0002.54 +-002.54 +1234567%d.00 +-1234567%d.00 + +Float Iteration 7 +0.00000 +1.00000 +-1.0000 +0.32000 +-0.3200 +3.40000 +2.54000 +-2.5400 +1234567%d.00 +-1234567%d.00 + +Float Iteration 8 +###0.00 +###1.00 +##-1.00 +###0.32 +##-0.32 +###3.40 +###2.54 +##-2.54 +1234567%d.00 +-1234567%d.00 + +*** Output for integer type *** + + Input Integer numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + + +Integer Iteration 1 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 2 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 3 ++0 ++1 +-1 ++2 +-2 ++23333333 +-23333333 ++1234 + +Integer Iteration 4 + 0 + 1 + -1 + 2 + -2 +23333333 +-23333333 + 1234 + +Integer Iteration 5 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 6 +0000000 +0000001 +-000001 +0000002 +-000002 +23333333 +-23333333 +0001234 + +Integer Iteration 7 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 8 +######0 +######1 +#####-1 +######2 +#####-2 +23333333 +-23333333 +###1234 + +*** Output for binary type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +11111111111111111111111111111111 +10 +11111111111111111111111111111110 +1011001000000100111010101 +11111110100110111111011000101011 +10011010010 + +*** Output for char type *** + + Input Characters variation array is: +Array +( + [0] => a + [1] => a + [2] => 67 + [3] => -67 + [4] => 99 +) + + + +C +½ +c + +*** Output for scientific type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0.000000e+0 +1.000000e+0 +-1.000000e+0 +2.700000e+0 +-2.700000e+0 +2.333333e+7 +-2.333333e+7 +1.234000e+3 + +*** Output for unsigned integer type *** + + Input Integer numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +4294967295 +2 +4294967294 +23333333 +4271633963 +1234 + +*** Output for octal type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +37777777777 +2 +37777777776 +131004725 +37646773053 +2322 + +*** Output for hexadecimal type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +ffffffff +2 +fffffffe +16409d5 +fe9bf62b +4d2 + +*** Output for string type *** + + Input Strings format variation array is: +Array +( + [0] => %5s + [1] => %-5s + [2] => %05s + [3] => %'#5s +) + + Input strings variation array is: +Array +( + [0] => + [1] => abc + [2] => aaa +) + + + abc + aaa + +abc +aaa +00000 +00abc +00aaa +##### +##abc +##aaa + +*** Output for '%g' type *** + + Input format variation array is: +Array +( + [0] => %g + [1] => %.0g + [2] => %+g + [3] => %-g + [4] => %-1.2g + [5] => %+1.2g + [6] => %G + [7] => %.0G + [8] => %+G + [9] => %-G + [10] => %-1.2G + [11] => %+1.2G +) + +123456 +-123456 +1.0e+5 +-1.0e+5 ++123456 +-123456 +123456 +-123456 +120000 +-120000 ++120000 +-120000 +123456 +-123456 +1.0E+5 +-1.0E+5 ++123456 +-123456 +123456 +-123456 +120000 +-120000 ++120000 +-120000 + +*** Output for '%%%.2f' as the format parameter *** +%12345678900.00 + +*** Output for '%%' as the format parameter *** +% + +*** Output for precision value more than maximum *** +12345678900.0000000000000000000000000000000000000000 + +*** Output for invalid width(-15) specifier *** +15s + +*** Output for '%F' as the format parameter *** +12345678900.000000 + +*** Output for '%X' as the format parameter *** +C + +*** Output with no format parameter *** +12345 + +*** Output for multiple format parameters *** +12345 abcdefghjklmnpqrstuvwxyz 12345 + + +*** Output for excess of mixed type arguments *** +abcdefghjklmnpqrstuvwxyz + +*** Output for string format parameter and integer type argument *** +12345 + +*** Output for integer format parameter and string type argument *** +0 -- 2.40.0