1--TEST--
2Test crc32() function : usage variations - single 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 single quotes passed to the function
18*/
19
20echo "*** Testing crc32() : with different strings in single 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  'hello\nworld',
43  'hellowor\\nld',
44  '\nhello world\n',
45  '\n\thelloworld',
46  'hel\tlo\n world',
47
48  '!@#$%&',
49  '#hello@world.com',
50  '$hello$world',
51
52  'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb
53   cccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddd
54   eeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffff
55   gggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhh
56   111111111111111111111122222222222222222222222222222222222222222222
57   333333333333333333333333333333333334444444444444444444444444444444
58   555555555555555555555555555555555555555555556666666666666666666666
59   777777777777777777777777777777777777777777777777777777777777777777
60   /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
61   /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'
62);
63
64// looping to check the behaviour of the function for each string in the array
65
66$count = 1;
67foreach($string_array as $str) {
68  echo "\n-- Iteration $count --\n";
69  var_dump( crc32($str) );
70  $count++;
71}
72
73echo "Done";
74?>
75--EXPECTF--
76*** Testing crc32() : with different strings in single quotes ***
77
78-- Iteration 1 --
79int(0)
80
81-- Iteration 2 --
82int(-378745019)
83
84-- Iteration 3 --
85int(222957957)
86
87-- Iteration 4 --
88int(-2015000997)
89
90-- Iteration 5 --
91int(1234261835)
92
93-- Iteration 6 --
94int(-1867296214)
95
96-- Iteration 7 --
97int(1048577080)
98
99-- Iteration 8 --
100int(2129739710)
101
102-- Iteration 9 --
103int(-1633247628)
104
105-- Iteration 10 --
106int(135755572)
107
108-- Iteration 11 --
109int(27384015)
110
111-- Iteration 12 --
112int(-497244052)
113
114-- Iteration 13 --
115int(-2065897232)
116
117-- Iteration 14 --
118int(243585859)
119
120-- Iteration 15 --
121int(-856440615)
122
123-- Iteration 16 --
124int(647088397)
125
126-- Iteration 17 --
127int(523630053)
128
129-- Iteration 18 --
130int(-2062229676)
131
132-- Iteration 19 --
133int(1169918910)
134
135-- Iteration 20 --
136int(-618551732)
137
138-- Iteration 21 --
139int(-1828940657)
140
141-- Iteration 22 --
142int(-1654468652)
143
144-- Iteration 23 --
145int(-1648442217)
146
147-- Iteration 24 --
148int(1431761713)
149Done
150