Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation12.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test sprintf() function : usage variations - float formats with arrays
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
! 6: * Description: Return a formatted string
! 7: * Source code: ext/standard/formatted_print.c
! 8: */
! 9:
! 10: echo "*** Testing sprintf() : float formats with arrays ***\n";
! 11:
! 12: // array of array types
! 13: $array_values = array (
! 14: array(),
! 15: array(0),
! 16: array(1),
! 17: array(NULL),
! 18: array(null),
! 19: array("string"),
! 20: array(true),
! 21: array(TRUE),
! 22: array(false),
! 23: array(FALSE),
! 24: array(1,2,3,4),
! 25: array("123.456abc"),
! 26: array('123.456abc'),
! 27: array(1 => "One", "two" => 2)
! 28: );
! 29:
! 30: // various float formats
! 31: $float_formats = array(
! 32: "%f", "%hf", "%lf",
! 33: "%Lf", " %f", "%f ",
! 34: "\t%f", "\n%f", "%4f",
! 35: "%30f", "%[0-9]", "%*f"
! 36: );
! 37:
! 38: $count = 1;
! 39: foreach($array_values as $array_value) {
! 40: echo "\n-- Iteration $count --\n";
! 41:
! 42: foreach($float_formats as $format) {
! 43: // with two arguments
! 44: var_dump( sprintf($format, $array_value) );
! 45: }
! 46: $count++;
! 47: };
! 48:
! 49: echo "Done";
! 50: ?>
! 51: --EXPECTF--
! 52: *** Testing sprintf() : float formats with arrays ***
! 53:
! 54: -- Iteration 1 --
! 55: string(8) "0.000000"
! 56: string(1) "f"
! 57: string(8) "0.000000"
! 58: string(1) "f"
! 59: string(9) " 0.000000"
! 60: string(9) "0.000000 "
! 61: string(9) " 0.000000"
! 62: string(9) "
! 63: 0.000000"
! 64: string(8) "0.000000"
! 65: string(30) " 0.000000"
! 66: string(4) "0-9]"
! 67: string(1) "f"
! 68:
! 69: -- Iteration 2 --
! 70: string(8) "1.000000"
! 71: string(1) "f"
! 72: string(8) "1.000000"
! 73: string(1) "f"
! 74: string(9) " 1.000000"
! 75: string(9) "1.000000 "
! 76: string(9) " 1.000000"
! 77: string(9) "
! 78: 1.000000"
! 79: string(8) "1.000000"
! 80: string(30) " 1.000000"
! 81: string(4) "0-9]"
! 82: string(1) "f"
! 83:
! 84: -- Iteration 3 --
! 85: string(8) "1.000000"
! 86: string(1) "f"
! 87: string(8) "1.000000"
! 88: string(1) "f"
! 89: string(9) " 1.000000"
! 90: string(9) "1.000000 "
! 91: string(9) " 1.000000"
! 92: string(9) "
! 93: 1.000000"
! 94: string(8) "1.000000"
! 95: string(30) " 1.000000"
! 96: string(4) "0-9]"
! 97: string(1) "f"
! 98:
! 99: -- Iteration 4 --
! 100: string(8) "1.000000"
! 101: string(1) "f"
! 102: string(8) "1.000000"
! 103: string(1) "f"
! 104: string(9) " 1.000000"
! 105: string(9) "1.000000 "
! 106: string(9) " 1.000000"
! 107: string(9) "
! 108: 1.000000"
! 109: string(8) "1.000000"
! 110: string(30) " 1.000000"
! 111: string(4) "0-9]"
! 112: string(1) "f"
! 113:
! 114: -- Iteration 5 --
! 115: string(8) "1.000000"
! 116: string(1) "f"
! 117: string(8) "1.000000"
! 118: string(1) "f"
! 119: string(9) " 1.000000"
! 120: string(9) "1.000000 "
! 121: string(9) " 1.000000"
! 122: string(9) "
! 123: 1.000000"
! 124: string(8) "1.000000"
! 125: string(30) " 1.000000"
! 126: string(4) "0-9]"
! 127: string(1) "f"
! 128:
! 129: -- Iteration 6 --
! 130: string(8) "1.000000"
! 131: string(1) "f"
! 132: string(8) "1.000000"
! 133: string(1) "f"
! 134: string(9) " 1.000000"
! 135: string(9) "1.000000 "
! 136: string(9) " 1.000000"
! 137: string(9) "
! 138: 1.000000"
! 139: string(8) "1.000000"
! 140: string(30) " 1.000000"
! 141: string(4) "0-9]"
! 142: string(1) "f"
! 143:
! 144: -- Iteration 7 --
! 145: string(8) "1.000000"
! 146: string(1) "f"
! 147: string(8) "1.000000"
! 148: string(1) "f"
! 149: string(9) " 1.000000"
! 150: string(9) "1.000000 "
! 151: string(9) " 1.000000"
! 152: string(9) "
! 153: 1.000000"
! 154: string(8) "1.000000"
! 155: string(30) " 1.000000"
! 156: string(4) "0-9]"
! 157: string(1) "f"
! 158:
! 159: -- Iteration 8 --
! 160: string(8) "1.000000"
! 161: string(1) "f"
! 162: string(8) "1.000000"
! 163: string(1) "f"
! 164: string(9) " 1.000000"
! 165: string(9) "1.000000 "
! 166: string(9) " 1.000000"
! 167: string(9) "
! 168: 1.000000"
! 169: string(8) "1.000000"
! 170: string(30) " 1.000000"
! 171: string(4) "0-9]"
! 172: string(1) "f"
! 173:
! 174: -- Iteration 9 --
! 175: string(8) "1.000000"
! 176: string(1) "f"
! 177: string(8) "1.000000"
! 178: string(1) "f"
! 179: string(9) " 1.000000"
! 180: string(9) "1.000000 "
! 181: string(9) " 1.000000"
! 182: string(9) "
! 183: 1.000000"
! 184: string(8) "1.000000"
! 185: string(30) " 1.000000"
! 186: string(4) "0-9]"
! 187: string(1) "f"
! 188:
! 189: -- Iteration 10 --
! 190: string(8) "1.000000"
! 191: string(1) "f"
! 192: string(8) "1.000000"
! 193: string(1) "f"
! 194: string(9) " 1.000000"
! 195: string(9) "1.000000 "
! 196: string(9) " 1.000000"
! 197: string(9) "
! 198: 1.000000"
! 199: string(8) "1.000000"
! 200: string(30) " 1.000000"
! 201: string(4) "0-9]"
! 202: string(1) "f"
! 203:
! 204: -- Iteration 11 --
! 205: string(8) "1.000000"
! 206: string(1) "f"
! 207: string(8) "1.000000"
! 208: string(1) "f"
! 209: string(9) " 1.000000"
! 210: string(9) "1.000000 "
! 211: string(9) " 1.000000"
! 212: string(9) "
! 213: 1.000000"
! 214: string(8) "1.000000"
! 215: string(30) " 1.000000"
! 216: string(4) "0-9]"
! 217: string(1) "f"
! 218:
! 219: -- Iteration 12 --
! 220: string(8) "1.000000"
! 221: string(1) "f"
! 222: string(8) "1.000000"
! 223: string(1) "f"
! 224: string(9) " 1.000000"
! 225: string(9) "1.000000 "
! 226: string(9) " 1.000000"
! 227: string(9) "
! 228: 1.000000"
! 229: string(8) "1.000000"
! 230: string(30) " 1.000000"
! 231: string(4) "0-9]"
! 232: string(1) "f"
! 233:
! 234: -- Iteration 13 --
! 235: string(8) "1.000000"
! 236: string(1) "f"
! 237: string(8) "1.000000"
! 238: string(1) "f"
! 239: string(9) " 1.000000"
! 240: string(9) "1.000000 "
! 241: string(9) " 1.000000"
! 242: string(9) "
! 243: 1.000000"
! 244: string(8) "1.000000"
! 245: string(30) " 1.000000"
! 246: string(4) "0-9]"
! 247: string(1) "f"
! 248:
! 249: -- Iteration 14 --
! 250: string(8) "1.000000"
! 251: string(1) "f"
! 252: string(8) "1.000000"
! 253: string(1) "f"
! 254: string(9) " 1.000000"
! 255: string(9) "1.000000 "
! 256: string(9) " 1.000000"
! 257: string(9) "
! 258: 1.000000"
! 259: string(8) "1.000000"
! 260: string(30) " 1.000000"
! 261: string(4) "0-9]"
! 262: string(1) "f"
! 263: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>