Annotation of embedaddon/php/ext/standard/tests/strings/crc32_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test crc32() function : usage variations - double quoted strings
3: --SKIPIF--
4: <?php
5: if (PHP_INT_SIZE != 4)
6: die("skip this test is for 32bit platform only");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : string crc32(string $str)
11: * Description: Calculate the crc32 polynomial of a string
12: * Source code: ext/standard/crc32.c
13: * Alias to functions: none
14: */
15:
16: /*
17: * Testing crc32() : with different strings in double quotes passed to the function
18: */
19:
20: echo "*** Testing crc32() : with different strings in double quotes ***\n";
21:
22: // defining an array of strings
23: $string_array = array(
24: "",
25: " ",
26: "hello world",
27: "HELLO WORLD",
28: " helloworld ",
29:
30: "(hello world)",
31: "hello(world)",
32: "helloworld()",
33: "hello()(world",
34:
35: "'hello' world",
36: "hello 'world'",
37: "hello''world",
38:
39: "hello\tworld",
40: "hellowor\\tld",
41: "\thello world\t",
42: "helloworld",
43: "hellowor\\ld",
44: "hello\nworld",
45: "hellowor\\nld",
46: "\nhello world\n",
47: "\n\thelloworld",
48: "hel\tlo\n world",
49:
50: "!@#$%&",
51: "#hello@world.com",
52: "$hello$world",
53:
54: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb
55: cccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddd
56: eeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffff
57: gggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhh
58: 111111111111111111111122222222222222222222222222222222222222222222
59: 333333333333333333333333333333333334444444444444444444444444444444
60: 555555555555555555555555555555555555555555556666666666666666666666
61: 777777777777777777777777777777777777777777777777777777777777777777
62: /t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t
63: /n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n/n"
64: );
65:
66: // looping to check the behaviour of the function for each string in the array
67:
68: $count = 1;
69: foreach($string_array as $str) {
70: echo "\n-- Iteration $count --\n";
71: var_dump( crc32($str) );
72: $count++;
73: }
74:
75: echo "Done";
76: ?>
77: --EXPECTF--
78: *** Testing crc32() : with different strings in double quotes ***
79:
80: Notice: Undefined variable: hello in %s on line %d
81:
82: Notice: Undefined variable: world in %s on line %d
83:
84: -- Iteration 1 --
85: int(0)
86:
87: -- Iteration 2 --
88: int(-378745019)
89:
90: -- Iteration 3 --
91: int(222957957)
92:
93: -- Iteration 4 --
94: int(-2015000997)
95:
96: -- Iteration 5 --
97: int(1234261835)
98:
99: -- Iteration 6 --
100: int(-1867296214)
101:
102: -- Iteration 7 --
103: int(1048577080)
104:
105: -- Iteration 8 --
106: int(2129739710)
107:
108: -- Iteration 9 --
109: int(-1633247628)
110:
111: -- Iteration 10 --
112: int(1191242624)
113:
114: -- Iteration 11 --
115: int(603128807)
116:
117: -- Iteration 12 --
118: int(-525789576)
119:
120: -- Iteration 13 --
121: int(770262395)
122:
123: -- Iteration 14 --
124: int(243585859)
125:
126: -- Iteration 15 --
127: int(-986324846)
128:
129: -- Iteration 16 --
130: int(-102031187)
131:
132: -- Iteration 17 --
133: int(-588181215)
134:
135: -- Iteration 18 --
136: int(-1417857067)
137:
138: -- Iteration 19 --
139: int(523630053)
140:
141: -- Iteration 20 --
142: int(-503915034)
143:
144: -- Iteration 21 --
145: int(-254912432)
146:
147: -- Iteration 22 --
148: int(-1581578467)
149:
150: -- Iteration 23 --
151: int(-1828940657)
152:
153: -- Iteration 24 --
154: int(-1654468652)
155:
156: -- Iteration 25 --
157: int(0)
158:
159: -- Iteration 26 --
160: int(1431761713)
161: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>