您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit断言-assertNan
发布时间:2021-10-05 13:19:52编辑:雪饮阅读()
assertNan断言用于断言一个NAN值,NAN这种值以前是在JavaScript中很常见,php中也是有,就是个人这里目前好像是还没有遇到过。
NanTest.php:
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class NanTest extends TestCase
{
public function testFailure(): void
{
$this->assertNan(1);
}
public function testSuccess(): void
{
$this->assertNan(NAN);
}
}
use PHPUnit\Framework\TestCase;
final class NanTest extends TestCase
{
public function testFailure(): void
{
$this->assertNan(1);
}
public function testSuccess(): void
{
$this->assertNan(NAN);
}
}
运行结果:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\php.exe C:\Users\Administrator\PhpstormProjects\untitled\vendor\phpunit\phpunit\phpunit -c C:\Users\Administrator\PhpstormProjects\untitled\organizing\phpunit.xml C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\NanTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
F. 2 / 2 (100%)
Time: 00:00.030, Memory: 6.00 MB
There was 1 failure:
1) NanTest::testFailure
Failed asserting that 1 is nan.
C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\NanTest.php:8
FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
关键字词:phpunit,assertNan
相关文章
- phpunit断言-assertLessThanOrEqual
- phpunit断言-assertLessThan
- phpunit断言-assertJsonStringEqualsJsonString
- phpunit断言-assertJsonStringEqualsJsonFile
- phpunit断言-assertJsonFileEqualsJsonFile
- phpunit断言-assertIsWritable
- phpunit断言-assertIsReadable
- phpunit断言-assertIsString
- phpunit断言-assertIsScalar
- phpunit断言-assertIsResource