MCPcopy Create free account
hub / github.com/apple/coremltools / testDouble

Method testDouble

deps/protobuf/php/tests/ArrayTest.php:334–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

332 #########################################################
333
334 public function testDouble()
335 {
336 $arr = new RepeatedField(GPBType::DOUBLE);
337
338 // Test append.
339 $arr[] = 1;
340 $this->assertFloatEquals(1.0, $arr[0], MAX_FLOAT_DIFF);
341
342 $arr[] = 1.1;
343 $this->assertFloatEquals(1.1, $arr[1], MAX_FLOAT_DIFF);
344
345 $arr[] = '2';
346 $this->assertFloatEquals(2.0, $arr[2], MAX_FLOAT_DIFF);
347 $arr[] = '3.1';
348 $this->assertFloatEquals(3.1, $arr[3], MAX_FLOAT_DIFF);
349
350 $this->assertEquals(4, count($arr));
351
352 for ($i = 0; $i < count($arr); $i++) {
353 $arr[$i] = 0;
354 $this->assertSame(0.0, $arr[$i]);
355 }
356
357 // Test set.
358 $arr[0] = 1;
359 $this->assertFloatEquals(1.0, $arr[0], MAX_FLOAT_DIFF);
360
361 $arr[1] = 1.1;
362 $this->assertFloatEquals(1.1, $arr[1], MAX_FLOAT_DIFF);
363
364 $arr[2] = '2';
365 $this->assertFloatEquals(2.0, $arr[2], MAX_FLOAT_DIFF);
366 $arr[3] = '3.1';
367 $this->assertFloatEquals(3.1, $arr[3], MAX_FLOAT_DIFF);
368 }
369
370 #########################################################
371 # Test bool field.

Callers

nothing calls this directly

Calls 2

countFunction · 0.85
assertFloatEqualsMethod · 0.80

Tested by

no test coverage detected