~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/standard/tests/strings/str_split_variation7_64bit.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Test str_split() function : usage variations - different integer values for 'split_length' with heredoc 'str'
 
3
--SKIPIF--
 
4
<?php
 
5
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
 
6
?>
 
7
--FILE--
 
8
<?php
 
9
/* Prototype  : array str_split(string $str [, int $split_length])
 
10
 * Description: Convert a string to an array. If split_length is 
 
11
                specified, break the string down into chunks each 
 
12
                split_length characters long. 
 
13
 * Source code: ext/standard/string.c
 
14
 * Alias to functions: none
 
15
*/
 
16
 
 
17
/*
 
18
* passing different integer values for 'split_length' and heredoc string as 'str' argument to str_split()
 
19
*/
 
20
 
 
21
echo "*** Testing str_split() : different intger values for 'split_length' with heredoc 'str' ***\n";
 
22
//Initialise variables
 
23
$str = <<<EOT
 
24
string with 123,escape char \t.
 
25
EOT;
 
26
 
 
27
//different values for 'split_length' 
 
28
$values = array (
 
29
  0,
 
30
  1,
 
31
  -123,  //negative integer
 
32
  0234,  //octal number
 
33
  0x1A,  //hexadecimal number
 
34
  2147483647,  //max positive integer number
 
35
  2147483648,  //max positive integer+1
 
36
  -2147483648,  //min negative integer
 
37
);
 
38
 
 
39
//loop through each element of $values for 'split_length'
 
40
for($count = 0; $count < count($values); $count++) {
 
41
  echo "-- Iteration ".($count + 1)." --\n";
 
42
  var_dump( str_split($str, $values[$count]) );
 
43
}
 
44
echo "Done"
 
45
?>
 
46
--EXPECTF--
 
47
*** Testing str_split() : different intger values for 'split_length' with heredoc 'str' ***
 
48
-- Iteration 1 --
 
49
 
 
50
Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
 
51
bool(false)
 
52
-- Iteration 2 --
 
53
array(30) {
 
54
  [0]=>
 
55
  string(1) "s"
 
56
  [1]=>
 
57
  string(1) "t"
 
58
  [2]=>
 
59
  string(1) "r"
 
60
  [3]=>
 
61
  string(1) "i"
 
62
  [4]=>
 
63
  string(1) "n"
 
64
  [5]=>
 
65
  string(1) "g"
 
66
  [6]=>
 
67
  string(1) " "
 
68
  [7]=>
 
69
  string(1) "w"
 
70
  [8]=>
 
71
  string(1) "i"
 
72
  [9]=>
 
73
  string(1) "t"
 
74
  [10]=>
 
75
  string(1) "h"
 
76
  [11]=>
 
77
  string(1) " "
 
78
  [12]=>
 
79
  string(1) "1"
 
80
  [13]=>
 
81
  string(1) "2"
 
82
  [14]=>
 
83
  string(1) "3"
 
84
  [15]=>
 
85
  string(1) ","
 
86
  [16]=>
 
87
  string(1) "e"
 
88
  [17]=>
 
89
  string(1) "s"
 
90
  [18]=>
 
91
  string(1) "c"
 
92
  [19]=>
 
93
  string(1) "a"
 
94
  [20]=>
 
95
  string(1) "p"
 
96
  [21]=>
 
97
  string(1) "e"
 
98
  [22]=>
 
99
  string(1) " "
 
100
  [23]=>
 
101
  string(1) "c"
 
102
  [24]=>
 
103
  string(1) "h"
 
104
  [25]=>
 
105
  string(1) "a"
 
106
  [26]=>
 
107
  string(1) "r"
 
108
  [27]=>
 
109
  string(1) " "
 
110
  [28]=>
 
111
  string(1) "   "
 
112
  [29]=>
 
113
  string(1) "."
 
114
}
 
115
-- Iteration 3 --
 
116
 
 
117
Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
 
118
bool(false)
 
119
-- Iteration 4 --
 
120
array(1) {
 
121
  [0]=>
 
122
  string(30) "string with 123,escape char       ."
 
123
}
 
124
-- Iteration 5 --
 
125
array(2) {
 
126
  [0]=>
 
127
  string(26) "string with 123,escape cha"
 
128
  [1]=>
 
129
  string(4) "r  ."
 
130
}
 
131
-- Iteration 6 --
 
132
array(1) {
 
133
  [0]=>
 
134
  string(30) "string with 123,escape char       ."
 
135
}
 
136
-- Iteration 7 --
 
137
array(1) {
 
138
  [0]=>
 
139
  string(30) "string with 123,escape char       ."
 
140
}
 
141
-- Iteration 8 --
 
142
 
 
143
Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
 
144
bool(false)
 
145
Done