Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation16.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test sprintf() function : usage variations - string formats with float values
! 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() : string formats with float values ***\n";
! 11:
! 12: // array of float values
! 13: $float_values = array(
! 14: -2147483649,
! 15: 2147483648,
! 16: -0x80000001, // float value, beyond max negative int
! 17: 0x800000001, // float value, beyond max positive int
! 18: 020000000001, // float value, beyond max positive int
! 19: -020000000001, // float value, beyond max negative int
! 20: 0.0,
! 21: -0.1,
! 22: 1.0,
! 23: 1e3,
! 24: -1e2,
! 25: 1.23456E8,
! 26: -1.234567E9,
! 27: 10.0000000000000000005,
! 28: 10.123e+5
! 29: );
! 30:
! 31: // array of string formats
! 32: $string_formats = array(
! 33: "%s", "%hs", "%ls",
! 34: "%Ls"," %s", "%s ",
! 35: "\t%s", "\n%s", "%4s",
! 36: "%30s", "%[a-zA-Z0-9]", "%*s"
! 37: );
! 38:
! 39: $count = 1;
! 40: foreach($float_values as $float_value) {
! 41: echo "\n-- Iteration $count --\n";
! 42:
! 43: foreach($string_formats as $format) {
! 44: var_dump( sprintf($format, $float_value) );
! 45: }
! 46: $count++;
! 47: };
! 48:
! 49: echo "Done";
! 50: ?>
! 51: --EXPECTF--
! 52: *** Testing sprintf() : string formats with float values ***
! 53:
! 54: -- Iteration 1 --
! 55: string(11) "-2147483649"
! 56: string(1) "s"
! 57: string(11) "-2147483649"
! 58: string(1) "s"
! 59: string(12) " -2147483649"
! 60: string(12) "-2147483649 "
! 61: string(12) " -2147483649"
! 62: string(12) "
! 63: -2147483649"
! 64: string(11) "-2147483649"
! 65: string(30) " -2147483649"
! 66: string(10) "a-zA-Z0-9]"
! 67: string(1) "s"
! 68:
! 69: -- Iteration 2 --
! 70: string(10) "2147483648"
! 71: string(1) "s"
! 72: string(10) "2147483648"
! 73: string(1) "s"
! 74: string(11) " 2147483648"
! 75: string(11) "2147483648 "
! 76: string(11) " 2147483648"
! 77: string(11) "
! 78: 2147483648"
! 79: string(10) "2147483648"
! 80: string(30) " 2147483648"
! 81: string(10) "a-zA-Z0-9]"
! 82: string(1) "s"
! 83:
! 84: -- Iteration 3 --
! 85: string(11) "-2147483649"
! 86: string(1) "s"
! 87: string(11) "-2147483649"
! 88: string(1) "s"
! 89: string(12) " -2147483649"
! 90: string(12) "-2147483649 "
! 91: string(12) " -2147483649"
! 92: string(12) "
! 93: -2147483649"
! 94: string(11) "-2147483649"
! 95: string(30) " -2147483649"
! 96: string(10) "a-zA-Z0-9]"
! 97: string(1) "s"
! 98:
! 99: -- Iteration 4 --
! 100: string(11) "34359738369"
! 101: string(1) "s"
! 102: string(11) "34359738369"
! 103: string(1) "s"
! 104: string(12) " 34359738369"
! 105: string(12) "34359738369 "
! 106: string(12) " 34359738369"
! 107: string(12) "
! 108: 34359738369"
! 109: string(11) "34359738369"
! 110: string(30) " 34359738369"
! 111: string(10) "a-zA-Z0-9]"
! 112: string(1) "s"
! 113:
! 114: -- Iteration 5 --
! 115: string(10) "2147483649"
! 116: string(1) "s"
! 117: string(10) "2147483649"
! 118: string(1) "s"
! 119: string(11) " 2147483649"
! 120: string(11) "2147483649 "
! 121: string(11) " 2147483649"
! 122: string(11) "
! 123: 2147483649"
! 124: string(10) "2147483649"
! 125: string(30) " 2147483649"
! 126: string(10) "a-zA-Z0-9]"
! 127: string(1) "s"
! 128:
! 129: -- Iteration 6 --
! 130: string(11) "-2147483649"
! 131: string(1) "s"
! 132: string(11) "-2147483649"
! 133: string(1) "s"
! 134: string(12) " -2147483649"
! 135: string(12) "-2147483649 "
! 136: string(12) " -2147483649"
! 137: string(12) "
! 138: -2147483649"
! 139: string(11) "-2147483649"
! 140: string(30) " -2147483649"
! 141: string(10) "a-zA-Z0-9]"
! 142: string(1) "s"
! 143:
! 144: -- Iteration 7 --
! 145: string(1) "0"
! 146: string(1) "s"
! 147: string(1) "0"
! 148: string(1) "s"
! 149: string(2) " 0"
! 150: string(2) "0 "
! 151: string(2) " 0"
! 152: string(2) "
! 153: 0"
! 154: string(4) " 0"
! 155: string(30) " 0"
! 156: string(10) "a-zA-Z0-9]"
! 157: string(1) "s"
! 158:
! 159: -- Iteration 8 --
! 160: string(4) "-0.1"
! 161: string(1) "s"
! 162: string(4) "-0.1"
! 163: string(1) "s"
! 164: string(5) " -0.1"
! 165: string(5) "-0.1 "
! 166: string(5) " -0.1"
! 167: string(5) "
! 168: -0.1"
! 169: string(4) "-0.1"
! 170: string(30) " -0.1"
! 171: string(10) "a-zA-Z0-9]"
! 172: string(1) "s"
! 173:
! 174: -- Iteration 9 --
! 175: string(1) "1"
! 176: string(1) "s"
! 177: string(1) "1"
! 178: string(1) "s"
! 179: string(2) " 1"
! 180: string(2) "1 "
! 181: string(2) " 1"
! 182: string(2) "
! 183: 1"
! 184: string(4) " 1"
! 185: string(30) " 1"
! 186: string(10) "a-zA-Z0-9]"
! 187: string(1) "s"
! 188:
! 189: -- Iteration 10 --
! 190: string(4) "1000"
! 191: string(1) "s"
! 192: string(4) "1000"
! 193: string(1) "s"
! 194: string(5) " 1000"
! 195: string(5) "1000 "
! 196: string(5) " 1000"
! 197: string(5) "
! 198: 1000"
! 199: string(4) "1000"
! 200: string(30) " 1000"
! 201: string(10) "a-zA-Z0-9]"
! 202: string(1) "s"
! 203:
! 204: -- Iteration 11 --
! 205: string(4) "-100"
! 206: string(1) "s"
! 207: string(4) "-100"
! 208: string(1) "s"
! 209: string(5) " -100"
! 210: string(5) "-100 "
! 211: string(5) " -100"
! 212: string(5) "
! 213: -100"
! 214: string(4) "-100"
! 215: string(30) " -100"
! 216: string(10) "a-zA-Z0-9]"
! 217: string(1) "s"
! 218:
! 219: -- Iteration 12 --
! 220: string(9) "123456000"
! 221: string(1) "s"
! 222: string(9) "123456000"
! 223: string(1) "s"
! 224: string(10) " 123456000"
! 225: string(10) "123456000 "
! 226: string(10) " 123456000"
! 227: string(10) "
! 228: 123456000"
! 229: string(9) "123456000"
! 230: string(30) " 123456000"
! 231: string(10) "a-zA-Z0-9]"
! 232: string(1) "s"
! 233:
! 234: -- Iteration 13 --
! 235: string(11) "-1234567000"
! 236: string(1) "s"
! 237: string(11) "-1234567000"
! 238: string(1) "s"
! 239: string(12) " -1234567000"
! 240: string(12) "-1234567000 "
! 241: string(12) " -1234567000"
! 242: string(12) "
! 243: -1234567000"
! 244: string(11) "-1234567000"
! 245: string(30) " -1234567000"
! 246: string(10) "a-zA-Z0-9]"
! 247: string(1) "s"
! 248:
! 249: -- Iteration 14 --
! 250: string(2) "10"
! 251: string(1) "s"
! 252: string(2) "10"
! 253: string(1) "s"
! 254: string(3) " 10"
! 255: string(3) "10 "
! 256: string(3) " 10"
! 257: string(3) "
! 258: 10"
! 259: string(4) " 10"
! 260: string(30) " 10"
! 261: string(10) "a-zA-Z0-9]"
! 262: string(1) "s"
! 263:
! 264: -- Iteration 15 --
! 265: string(7) "1012300"
! 266: string(1) "s"
! 267: string(7) "1012300"
! 268: string(1) "s"
! 269: string(8) " 1012300"
! 270: string(8) "1012300 "
! 271: string(8) " 1012300"
! 272: string(8) "
! 273: 1012300"
! 274: string(7) "1012300"
! 275: string(30) " 1012300"
! 276: string(10) "a-zA-Z0-9]"
! 277: string(1) "s"
! 278: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>