forked from moodle/moodle
-
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.
MDL-70796 count_words: match the count from LibraOffice & MS Word
- Loading branch information
Showing
3 changed files
with
28 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3808,22 +3808,27 @@ public function test_count_words(int $expectedcount, string $string): void { | |
* @return array of test cases. | ||
*/ | ||
public function count_words_testcases(): array { | ||
// The counts here should match MS Word and Libre Office. | ||
return [ | ||
[0, ''], | ||
[4, 'one two three four'], | ||
[3, "one two three'four"], | ||
[3, 'one+two three’four'], | ||
[2, 'one"two three-four'], | ||
[4, 'one@two three_four'], | ||
[4, 'one\two three/four'], | ||
[1, "a'b"], | ||
[1, '1+1=2'], | ||
[1, ' one-sided '], | ||
[2, 'one two'], | ||
[1, '[email protected]'], | ||
[2, 'first\part second/part'], | ||
[4, '<p>one two<br></br>three four</p>'], | ||
[4, '<p>one two<br>three four</p>'], | ||
[4, '<p>one two<br />three four</p>'], // XHTML style. | ||
[4, ' one ... two three...four '], | ||
[4, 'one.2 3,four'], | ||
[3, ' one ... three '], | ||
[1, 'just...one'], | ||
[3, ' one & three '], | ||
[1, 'just&one'], | ||
[2, 'em—dash'], | ||
[2, 'en–dash'], | ||
[4, '1³ £2 €3.45 $6,789'], | ||
[4, 'one—two ブルース カンベッル'], | ||
[4, 'one…two ブルース … カンベッル'], | ||
[2, 'ブルース カンベッル'], // MS word counts this as 11, but we don't handle that yet. | ||
[4, '<p>one two</p><p>three four</p>'], | ||
[4, '<p>one two</p><p><br/></p><p>three four</p>'], | ||
[4, '<p>one</p><ul><li>two</li><li>three</li></ul><p>four.</p>'], | ||
|
@@ -3832,7 +3837,12 @@ public function count_words_testcases(): array { | |
[1, '<p>em<strong>phas</strong>is.</p>'], | ||
[1, '<p>em<em>phas</em>is.</p>'], | ||
[2, "one\ntwo"], | ||
[2, "one\rtwo"], | ||
[2, "one\ttwo"], | ||
[2, "one\vtwo"], | ||
[2, "one\ftwo"], | ||
[1, "SO<sub>4</sub><sup>2-</sup>"], | ||
[6, '4+4=8 i.e. O(1) a,b,c,d I’m black&blue_really'], | ||
]; | ||
} | ||
|
||
|
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