1--TEST--
2Test crc32() function : usage variations - heredoc 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 heredoc strings passed to the str argument
18*/
19
20echo "*** Testing crc32() : with different heredoc strings ***\n";
21
22// defining different heredoc strings
23$empty_heredoc = <<<EOT
24EOT;
25
26$heredoc_with_newline = <<<EOT
27\n
28
29EOT;
30
31$heredoc_with_characters = <<<EOT
32first line of heredoc string
33second line of heredoc string
34third line of heredocstring
35EOT;
36
37$heredoc_with_newline_and_tabs = <<<EOT
38hello\tworld\nhello\nworld\n
39EOT;
40
41$heredoc_with_alphanumerics = <<<EOT
42hello123world456
431234hello\t1234
44EOT;
45
46$heredoc_with_embedded_nulls = <<<EOT
47hello\0world\0hello
48\0hello\0
49EOT;
50
51$heredoc_with_hexa_octal = <<<EOT
52hello\0\100\xaaworld\0hello
53\0hello\0
54EOT;
55
56$heredoc_with_long_string = <<<EOT
57aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb
58cccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddd
59eeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffff
60gggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhh
61111111111111111111111122222222222222222222222222222222222222222222
62333333333333333333333333333333333334444444444444444444444444444444
63555555555555555555555555555555555555555555556666666666666666666666
64777777777777777777777777777777777777777777777777777777777777777777
65/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
66/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/n
67EOT;
68
69$heredoc_strings = array(
70                   $empty_heredoc,
71                   $heredoc_with_newline,
72                   $heredoc_with_characters,
73                   $heredoc_with_newline_and_tabs,
74                   $heredoc_with_alphanumerics,
75                   $heredoc_with_embedded_nulls,
76                   $heredoc_with_hexa_octal,
77  		   $heredoc_with_long_string
78                   );
79
80// loop to test the function with each heredoc string in the array
81
82$count = 1;
83foreach($heredoc_strings as $str) {
84  echo "\n-- Iteration $count --\n";
85  var_dump( crc32($str) );
86  $count++;
87}
88
89echo "Done";
90?>
91--EXPECTF--
92*** Testing crc32() : with different heredoc strings ***
93
94-- Iteration 1 --
95int(0)
96
97-- Iteration 2 --
98int(1541608299)
99
100-- Iteration 3 --
101int(1588851550)
102
103-- Iteration 4 --
104int(-1726108239)
105
106-- Iteration 5 --
107int(-1847303891)
108
109-- Iteration 6 --
110int(-1260053120)
111
112-- Iteration 7 --
113int(-1718044186)
114
115-- Iteration 8 --
116int(1646793751)
117Done
118