-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from chineseboost/hg/better-quote-handling
Improve quote handling
- Loading branch information
Showing
7 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/Unit/Hanzi/HanziSentence/HanziSentenceQuoteMarksTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Pinyin\Tests\Unit\Hanzi\HanziSentence; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Pinyin\Hanzi\HanziSentence; | ||
|
||
class HanziSentenceQuoteMarksTest extends TestCase | ||
{ | ||
/** | ||
* @param string $sentence | ||
* @param string $expectedPinyin | ||
* | ||
* @dataProvider quoteMarkSpacingProvider | ||
*/ | ||
public function testQuoteMarkSpacing(string $sentence, string $expectedPinyin): void | ||
{ | ||
// Given a hanzi sentence; | ||
$hanziSentence = new HanziSentence($sentence); | ||
|
||
// When we convert it to pinyin; | ||
$pinyin = $hanziSentence->asPinyin(); | ||
|
||
// Then the spacing should be correct. | ||
self::assertEquals($expectedPinyin, (string) $pinyin); | ||
} | ||
|
||
/** | ||
* @return array[] | ||
*/ | ||
public static function quoteMarkSpacingProvider(): array | ||
{ | ||
return [ | ||
[ | ||
'“还要咖啡吗?”“不了,谢谢。”', | ||
'“Hai2yao4 ka1fei1 ma5?” “Bu4le5, xie4xie5.”', | ||
], | ||
[ | ||
'"还要咖啡吗?""不了,谢谢。"', | ||
'"Hai2yao4 ka1fei1 ma5?" "Bu4le5, xie4xie5."', | ||
], | ||
]; | ||
} | ||
} |