You've already forked MyDSL
StringReader部分
This commit is contained in:
54
tests/Reader/StringReaderTest.php
Normal file
54
tests/Reader/StringReaderTest.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename StringReaderTest.php
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2020/12/18 12:19
|
||||
*/
|
||||
|
||||
namespace JerryYan\DSL\Test\Reader;
|
||||
|
||||
use JerryYan\DSL\Reader\StringReader;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StringReaderTest extends TestCase
|
||||
{
|
||||
protected $readerWithCn;
|
||||
protected $reader;
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->reader = new StringReader(" Ahhh This Is 一个 新的 TOken");
|
||||
$this->readerWithCn = new StringReader(" 中文 这是 Is 一个 新的 TOken");
|
||||
}
|
||||
|
||||
public function testGetNextChar()
|
||||
{
|
||||
$this->reader->reset();
|
||||
$this->assertEquals('A', $this->reader->getNextChar(), "不匹配");
|
||||
$this->readerWithCn->reset();
|
||||
$this->assertEquals('中', $this->readerWithCn->getNextChar(), "不匹配");
|
||||
}
|
||||
|
||||
public function testGetCurrentToken()
|
||||
{
|
||||
$this->reader->reset();
|
||||
$this->assertEquals('Ahhh', $this->reader->getCurrentToken(), "不匹配");
|
||||
$this->readerWithCn->reset();
|
||||
$this->assertEquals('中文', $this->readerWithCn->getCurrentToken(), "不匹配");
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2020/12/18 14:16
|
||||
* @depends testGetNextChar
|
||||
* @depends testGetCurrentToken
|
||||
*/
|
||||
public function testMoveToNextToken()
|
||||
{
|
||||
$this->reader->reset();
|
||||
$this->reader->moveToNextToken();
|
||||
$this->assertEquals('This', $this->reader->getCurrentToken(), "不匹配");
|
||||
$this->readerWithCn->reset();
|
||||
$this->readerWithCn->moveToNextToken();
|
||||
$this->assertEquals('这是', $this->readerWithCn->getCurrentToken(), "不匹配");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user