Lines Matching refs:arr
19 $arr = new RepeatedField(GPBType::INT32);
22 $arr[] = MAX_INT32;
23 $this->assertSame(MAX_INT32, $arr[0]);
24 $arr[] = MIN_INT32;
25 $this->assertSame(MIN_INT32, $arr[1]);
27 $arr[] = 1.1;
28 $this->assertSame(1, $arr[2]);
29 $arr[] = MAX_INT32_FLOAT;
30 $this->assertSame(MAX_INT32, $arr[3]);
31 $arr[] = MAX_INT32_FLOAT;
32 $this->assertSame(MAX_INT32, $arr[4]);
34 $arr[] = '2';
35 $this->assertSame(2, $arr[5]);
36 $arr[] = '3.1';
37 $this->assertSame(3, $arr[6]);
38 $arr[] = MAX_INT32_STRING;
39 $this->assertSame(MAX_INT32, $arr[7]);
41 $this->assertEquals(8, count($arr));
43 for ($i = 0; $i < count($arr); $i++) {
44 $arr[$i] = 0;
45 $this->assertSame(0, $arr[$i]);
49 $arr[0] = MAX_INT32;
50 $this->assertSame(MAX_INT32, $arr[0]);
51 $arr[1] = MIN_INT32;
52 $this->assertSame(MIN_INT32, $arr[1]);
54 $arr[2] = 1.1;
55 $this->assertSame(1, $arr[2]);
56 $arr[3] = MAX_INT32_FLOAT;
57 $this->assertSame(MAX_INT32, $arr[3]);
58 $arr[4] = MAX_INT32_FLOAT;
59 $this->assertSame(MAX_INT32, $arr[4]);
61 $arr[5] = '2';
62 $this->assertSame(2, $arr[5]);
63 $arr[6] = '3.1';
64 $this->assertSame(3, $arr[6]);
65 $arr[7] = MAX_INT32_STRING;
66 $this->assertSame(MAX_INT32, $arr[7]);
69 $arr = new RepeatedField(GPBType::INT32);
71 $arr[] = $i;
74 foreach ($arr as $val) {
86 $arr = new RepeatedField(GPBType::UINT32);
89 $arr[] = MAX_UINT32;
90 $this->assertSame(-1, $arr[0]);
91 $arr[] = -1;
92 $this->assertSame(-1, $arr[1]);
93 $arr[] = MIN_UINT32;
94 $this->assertSame(MIN_UINT32, $arr[2]);
96 $arr[] = 1.1;
97 $this->assertSame(1, $arr[3]);
98 $arr[] = MAX_UINT32_FLOAT;
99 $this->assertSame(-1, $arr[4]);
100 $arr[] = -1.0;
101 $this->assertSame(-1, $arr[5]);
102 $arr[] = MIN_UINT32_FLOAT;
103 $this->assertSame(MIN_UINT32, $arr[6]);
105 $arr[] = '2';
106 $this->assertSame(2, $arr[7]);
107 $arr[] = '3.1';
108 $this->assertSame(3, $arr[8]);
109 $arr[] = MAX_UINT32_STRING;
110 $this->assertSame(-1, $arr[9]);
111 $arr[] = '-1.0';
112 $this->assertSame(-1, $arr[10]);
113 $arr[] = MIN_UINT32_STRING;
114 $this->assertSame(MIN_UINT32, $arr[11]);
116 $this->assertEquals(12, count($arr));
118 for ($i = 0; $i < count($arr); $i++) {
119 $arr[$i] = 0;
120 $this->assertSame(0, $arr[$i]);
124 $arr[0] = MAX_UINT32;
125 $this->assertSame(-1, $arr[0]);
126 $arr[1] = -1;
127 $this->assertSame(-1, $arr[1]);
128 $arr[2] = MIN_UINT32;
129 $this->assertSame(MIN_UINT32, $arr[2]);
131 $arr[3] = 1.1;
132 $this->assertSame(1, $arr[3]);
133 $arr[4] = MAX_UINT32_FLOAT;
134 $this->assertSame(-1, $arr[4]);
135 $arr[5] = -1.0;
136 $this->assertSame(-1, $arr[5]);
137 $arr[6] = MIN_UINT32_FLOAT;
138 $this->assertSame(MIN_UINT32, $arr[6]);
140 $arr[7] = '2';
141 $this->assertSame(2, $arr[7]);
142 $arr[8] = '3.1';
143 $this->assertSame(3, $arr[8]);
144 $arr[9] = MAX_UINT32_STRING;
145 $this->assertSame(-1, $arr[9]);
146 $arr[10] = '-1.0';
147 $this->assertSame(-1, $arr[10]);
148 $arr[11] = MIN_UINT32_STRING;
149 $this->assertSame(MIN_UINT32, $arr[11]);
158 $arr = new RepeatedField(GPBType::INT64);
161 $arr[] = MAX_INT64;
162 $arr[] = MIN_INT64;
163 $arr[] = 1.1;
164 $arr[] = '2';
165 $arr[] = '3.1';
166 $arr[] = MAX_INT64_STRING;
167 $arr[] = MIN_INT64_STRING;
169 $this->assertSame(MAX_INT64, $arr[0]);
170 $this->assertSame(MIN_INT64, $arr[1]);
171 $this->assertSame('1', $arr[2]);
172 $this->assertSame('2', $arr[3]);
173 $this->assertSame('3', $arr[4]);
174 $this->assertSame(MAX_INT64_STRING, $arr[5]);
175 $this->assertSame(MIN_INT64_STRING, $arr[6]);
177 $this->assertSame(MAX_INT64, $arr[0]);
178 $this->assertSame(MIN_INT64, $arr[1]);
179 $this->assertSame(1, $arr[2]);
180 $this->assertSame(2, $arr[3]);
181 $this->assertSame(3, $arr[4]);
182 $this->assertSame(MAX_INT64, $arr[5]);
183 $this->assertSame(MIN_INT64, $arr[6]);
187 $this->assertEquals(7, count($arr));
189 for ($i = 0; $i < count($arr); $i++) {
190 $arr[$i] = 0;
192 $this->assertSame('0', $arr[$i]);
194 $this->assertSame(0, $arr[$i]);
199 $arr[0] = MAX_INT64;
200 $arr[1] = MIN_INT64;
201 $arr[2] = 1.1;
202 $arr[3] = '2';
203 $arr[4] = '3.1';
204 $arr[5] = MAX_INT64_STRING;
205 $arr[6] = MIN_INT64_STRING;
208 $this->assertSame(MAX_INT64_STRING, $arr[0]);
209 $this->assertSame(MIN_INT64_STRING, $arr[1]);
210 $this->assertSame('1', $arr[2]);
211 $this->assertSame('2', $arr[3]);
212 $this->assertSame('3', $arr[4]);
213 $this->assertSame(MAX_INT64_STRING, $arr[5]);
214 $this->assertEquals(MIN_INT64_STRING, $arr[6]);
216 $this->assertSame(MAX_INT64, $arr[0]);
217 $this->assertSame(MIN_INT64, $arr[1]);
218 $this->assertSame(1, $arr[2]);
219 $this->assertSame(2, $arr[3]);
220 $this->assertSame(3, $arr[4]);
221 $this->assertSame(MAX_INT64, $arr[5]);
222 $this->assertEquals(MIN_INT64, $arr[6]);
232 $arr = new RepeatedField(GPBType::UINT64);
235 $arr[] = MAX_UINT64;
236 $arr[] = 1.1;
237 $arr[] = '2';
238 $arr[] = '3.1';
239 $arr[] = MAX_UINT64_STRING;
242 $this->assertSame(MAX_UINT64_STRING, $arr[0]);
243 $this->assertSame('1', $arr[1]);
244 $this->assertSame('2', $arr[2]);
245 $this->assertSame('3', $arr[3]);
246 $this->assertSame(MAX_UINT64_STRING, $arr[4]);
248 $this->assertSame(MAX_UINT64, $arr[0]);
249 $this->assertSame(1, $arr[1]);
250 $this->assertSame(2, $arr[2]);
251 $this->assertSame(3, $arr[3]);
252 $this->assertSame(MAX_UINT64, $arr[4]);
253 $this->assertSame(5, count($arr));
256 $this->assertSame(5, count($arr));
258 for ($i = 0; $i < count($arr); $i++) {
259 $arr[$i] = 0;
261 $this->assertSame('0', $arr[$i]);
263 $this->assertSame(0, $arr[$i]);
268 $arr[0] = MAX_UINT64;
269 $arr[1] = 1.1;
270 $arr[2] = '2';
271 $arr[3] = '3.1';
272 $arr[4] = MAX_UINT64_STRING;
275 $this->assertSame(MAX_UINT64_STRING, $arr[0]);
276 $this->assertSame('1', $arr[1]);
277 $this->assertSame('2', $arr[2]);
278 $this->assertSame('3', $arr[3]);
279 $this->assertSame(MAX_UINT64_STRING, $arr[4]);
281 $this->assertSame(MAX_UINT64, $arr[0]);
282 $this->assertSame(1, $arr[1]);
283 $this->assertSame(2, $arr[2]);
284 $this->assertSame(3, $arr[3]);
285 $this->assertSame(MAX_UINT64, $arr[4]);
295 $arr = new RepeatedField(GPBType::FLOAT);
298 $arr[] = 1;
299 $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF);
301 $arr[] = 1.1;
302 $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF);
304 $arr[] = '2';
305 $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF);
306 $arr[] = '3.1';
307 $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF);
309 $this->assertEquals(4, count($arr));
311 for ($i = 0; $i < count($arr); $i++) {
312 $arr[$i] = 0;
313 $this->assertSame(0.0, $arr[$i]);
317 $arr[0] = 1;
318 $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF);
320 $arr[1] = 1.1;
321 $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF);
323 $arr[2] = '2';
324 $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF);
325 $arr[3] = '3.1';
326 $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF);
335 $arr = new RepeatedField(GPBType::DOUBLE);
338 $arr[] = 1;
339 $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF);
341 $arr[] = 1.1;
342 $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF);
344 $arr[] = '2';
345 $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF);
346 $arr[] = '3.1';
347 $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF);
349 $this->assertEquals(4, count($arr));
351 for ($i = 0; $i < count($arr); $i++) {
352 $arr[$i] = 0;
353 $this->assertSame(0.0, $arr[$i]);
357 $arr[0] = 1;
358 $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF);
360 $arr[1] = 1.1;
361 $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF);
363 $arr[2] = '2';
364 $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF);
365 $arr[3] = '3.1';
366 $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF);
375 $arr = new RepeatedField(GPBType::BOOL);
378 $arr[] = true;
379 $this->assertSame(true, $arr[0]);
381 $arr[] = -1;
382 $this->assertSame(true, $arr[1]);
384 $arr[] = 1.1;
385 $this->assertSame(true, $arr[2]);
387 $arr[] = '';
388 $this->assertSame(false, $arr[3]);
390 $this->assertEquals(4, count($arr));
392 for ($i = 0; $i < count($arr); $i++) {
393 $arr[$i] = 0;
394 $this->assertSame(false, $arr[$i]);
398 $arr[0] = true;
399 $this->assertSame(true, $arr[0]);
401 $arr[1] = -1;
402 $this->assertSame(true, $arr[1]);
404 $arr[2] = 1.1;
405 $this->assertSame(true, $arr[2]);
407 $arr[3] = '';
408 $this->assertSame(false, $arr[3]);
417 $arr = new RepeatedField(GPBType::STRING);
420 $arr[] = 'abc';
421 $this->assertSame('abc', $arr[0]);
423 $arr[] = 1;
424 $this->assertSame('1', $arr[1]);
426 $arr[] = 1.1;
427 $this->assertSame('1.1', $arr[2]);
429 $arr[] = true;
430 $this->assertSame('1', $arr[3]);
432 $this->assertEquals(4, count($arr));
434 for ($i = 0; $i < count($arr); $i++) {
435 $arr[$i] = '';
436 $this->assertSame('', $arr[$i]);
440 $arr[0] = 'abc';
441 $this->assertSame('abc', $arr[0]);
443 $arr[1] = 1;
444 $this->assertSame('1', $arr[1]);
446 $arr[2] = 1.1;
447 $this->assertSame('1.1', $arr[2]);
449 $arr[3] = true;
450 $this->assertSame('1', $arr[3]);
459 $arr = new RepeatedField(GPBType::MESSAGE, Sub::class);
464 $arr[] = $sub_m;
465 $this->assertSame(1, $arr[0]->getA());
467 $this->assertEquals(1, count($arr));
472 $arr[0] = $sub_m;
473 $this->assertSame(2, $arr[0]->getA());
476 $arr = new RepeatedField(GPBType::MESSAGE, Sub::class);
478 $arr[] = new Sub();
479 $arr[$i]->setA($i);
482 foreach ($arr as $val) {
494 $arr = new RepeatedField(GPBType::INT32);
495 $arr[] = 0;
497 $arr[0] = 1;
498 $this->assertSame(1, $arr[0]);
499 $this->assertSame(1, count($arr));
501 $arr['0'] = 2;
502 $this->assertSame(2, $arr['0']);
503 $this->assertSame(2, $arr[0]);
504 $this->assertSame(1, count($arr));
506 $arr[0.0] = 3;
507 $this->assertSame(3, $arr[0.0]);
508 $this->assertSame(1, count($arr));
513 $arr = new RepeatedField(GPBType::INT32);
515 $arr[] = 0;
516 $arr[] = 1;
517 $arr[] = 2;
518 $this->assertSame(3, count($arr));
520 unset($arr[2]);
521 $this->assertSame(2, count($arr));
522 $this->assertSame(0, $arr[0]);
523 $this->assertSame(1, $arr[1]);
525 $arr[] = 3;
526 $this->assertSame(3, count($arr));
527 $this->assertSame(0, $arr[0]);
528 $this->assertSame(1, $arr[1]);
529 $this->assertSame(3, $arr[2]);
578 $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class);
579 $arr[] = new TestMessage;
580 $arr[0]->SetRepeatedRecursive($arr);
585 unset($arr);