1--TEST--
2Test crc32() function : usage variations - double quoted strings
3--SKIPIF--
4<?php
5if (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
20echo "*** 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;
69foreach($string_array as $str) {
70  echo "\n-- Iteration $count --\n";
71  var_dump( crc32($str) );
72  $count++;
73}
74
75echo "Done";
76?>
77--EXPECTF--
78*** Testing crc32() : with different strings in double quotes ***
79
80Notice: Undefined variable: hello in %s on line %d
81
82Notice: Undefined variable: world in %s on line %d
83
84-- Iteration 1 --
85int(0)
86
87-- Iteration 2 --
88int(-378745019)
89
90-- Iteration 3 --
91int(222957957)
92
93-- Iteration 4 --
94int(-2015000997)
95
96-- Iteration 5 --
97int(1234261835)
98
99-- Iteration 6 --
100int(-1867296214)
101
102-- Iteration 7 --
103int(1048577080)
104
105-- Iteration 8 --
106int(2129739710)
107
108-- Iteration 9 --
109int(-1633247628)
110
111-- Iteration 10 --
112int(1191242624)
113
114-- Iteration 11 --
115int(603128807)
116
117-- Iteration 12 --
118int(-525789576)
119
120-- Iteration 13 --
121int(770262395)
122
123-- Iteration 14 --
124int(243585859)
125
126-- Iteration 15 --
127int(-986324846)
128
129-- Iteration 16 --
130int(-102031187)
131
132-- Iteration 17 --
133int(-588181215)
134
135-- Iteration 18 --
136int(-1417857067)
137
138-- Iteration 19 --
139int(523630053)
140
141-- Iteration 20 --
142int(-503915034)
143
144-- Iteration 21 --
145int(-254912432)
146
147-- Iteration 22 --
148int(-1581578467)
149
150-- Iteration 23 --
151int(-1828940657)
152
153-- Iteration 24 --
154int(-1654468652)
155
156-- Iteration 25 --
157int(0)
158
159-- Iteration 26 --
160int(1431761713)
161Done
162