Files
phpy/tests/phpunit/StrTest.php
2023-12-18 16:57:09 +08:00

26 lines
615 B
PHP

<?php
use PHPUnit\Framework\TestCase;
class StrTest extends TestCase
{
public function testStr()
{
$str = new PyStr("hello world, hello swoole");
$this->assertTrue($str->endswith('swoole'));
$this->assertTrue($str->startswith('hello'));
$this->assertFalse($str->endswith('golang'));
$s2 = $str->replace('swoole', 'java');
$this->assertTrue($s2->endswith('java'));
}
public function testBytes()
{
$os = PyCore::import('os');
$bytes = PyCore::scalar($os->urandom(128));
$this->assertEquals(128, strlen($bytes));
}
}