You've already forked MyDSL
抽象
This commit is contained in:
@ -24,19 +24,24 @@ class StringReaderTest extends TestCase
|
||||
{
|
||||
$this->reader->reset();
|
||||
$this->assertEquals('A', $this->reader->getNextChar(), "不匹配");
|
||||
$this->assertEquals(1, $this->reader->getCurrentPosition(), "CurPos与预计不符");
|
||||
$this->readerWithCn->reset();
|
||||
$this->assertEquals('中', $this->readerWithCn->getNextChar(), "不匹配");
|
||||
$this->assertEquals(1, $this->readerWithCn->getCurrentPosition(), "CurPos与预计不符");
|
||||
}
|
||||
|
||||
public function testGetCurrentToken()
|
||||
{
|
||||
$this->reader->reset();
|
||||
$this->assertEquals('Ahhh', $this->reader->getCurrentToken(), "不匹配");
|
||||
$this->assertEquals(6, $this->reader->getNextPosition(), "NextPos与预计不符");
|
||||
$this->readerWithCn->reset();
|
||||
$this->assertEquals('中文', $this->readerWithCn->getCurrentToken(), "不匹配");
|
||||
$this->assertEquals(4, $this->readerWithCn->getNextPosition(), "NextPos与预计不符");
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动至下一个Token
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2020/12/18 14:16
|
||||
* @depends testGetNextChar
|
||||
@ -47,8 +52,25 @@ class StringReaderTest extends TestCase
|
||||
$this->reader->reset();
|
||||
$this->reader->moveToNextToken();
|
||||
$this->assertEquals('This', $this->reader->getCurrentToken(), "不匹配");
|
||||
$this->assertEquals(7, $this->reader->getCurrentPosition(), "CurPos与预计不符");
|
||||
$this->readerWithCn->reset();
|
||||
$this->readerWithCn->moveToNextToken();
|
||||
$this->assertEquals('这是', $this->readerWithCn->getCurrentToken(), "不匹配");
|
||||
$this->assertEquals(5, $this->readerWithCn->getCurrentPosition(), "CurPos与预计不符");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个Token,重复调用均为同一结果
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2020/12/18 18:49
|
||||
*/
|
||||
public function testGetNextToken()
|
||||
{
|
||||
$this->reader->reset();
|
||||
$curPos = $this->readerWithCn->getCurrentPosition();
|
||||
$string = $this->reader->getNextToken();
|
||||
$this->assertEquals($string, $this->reader->getNextToken(), "不匹配");
|
||||
$this->assertEquals($this->reader->getNextToken(), $this->reader->getNextToken(), "不匹配");
|
||||
$this->assertEquals($curPos, $this->reader->getCurrentPosition(), "CurPos不可以发生变化");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user