mirror of
https://github.com/php-win-ext/phpy.git
synced 2026-03-24 17:02:15 +01:00
26 lines
615 B
PHP
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));
|
|
}
|
|
}
|