Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: javatests/org/chromium/distiller/StringUtilTest.java

Issue 1725243002: Fix some warnings in Eclipse (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.distiller; 5 package org.chromium.distiller;
6 6
7 import com.google.gwt.regexp.shared.RegExp; 7 import com.google.gwt.regexp.shared.RegExp;
8
9 import org.chromium.distiller.StringUtil.WordCounter;
10
8 import java.util.ArrayList; 11 import java.util.ArrayList;
9 import java.util.List; 12 import java.util.List;
10 13
11 public class StringUtilTest extends JsTestCase { 14 public class StringUtilTest extends JsTestCase {
12 public void testFastWordCounter() { 15 public void testFastWordCounter() {
13 List<StringUtil.WordCounter> counters = new ArrayList(); 16 List<StringUtil.WordCounter> counters = new ArrayList<WordCounter>();
14 counters.add(new StringUtil.FastWordCounter()); 17 counters.add(new StringUtil.FastWordCounter());
15 counters.add(new StringUtil.LetterWordCounter()); 18 counters.add(new StringUtil.LetterWordCounter());
16 counters.add(new StringUtil.FullWordCounter()); 19 counters.add(new StringUtil.FullWordCounter());
17 20
18 for(StringUtil.WordCounter counter: counters) { 21 for(StringUtil.WordCounter counter: counters) {
19 assertEquals(0, counter.count("")); 22 assertEquals(0, counter.count(""));
20 assertEquals(0, counter.count(" -@# ';]")); 23 assertEquals(0, counter.count(" -@# ';]"));
21 assertEquals(1, counter.count("word")); 24 assertEquals(1, counter.count("word"));
22 assertEquals(1, counter.count("b'fore")); 25 assertEquals(1, counter.count("b'fore"));
23 assertEquals(1, counter.count(" _word.under_score_ ")); 26 assertEquals(1, counter.count(" _word.under_score_ "));
24 assertEquals(2, counter.count(" \ttwo\nwords")); 27 assertEquals(2, counter.count(" \ttwo\nwords"));
25 assertEquals(2, counter.count(" \ttwo @^@^&(@#$([][;;\nwords")); 28 assertEquals(2, counter.count(" \ttwo @^@^&(@#$([][;;\nwords"));
26 // Norwegian 29 // Norwegian
27 assertEquals(5, counter.count("dør når på svært dårlig")); 30 assertEquals(5, counter.count("dør når på svært dårlig"));
28 assertEquals(5, counter.count("svært få dør av blåbærsyltetøy")); 31 assertEquals(5, counter.count("svært få dør av blåbærsyltetøy"));
29 // Greek 32 // Greek
30 assertEquals(11, counter.count( 33 assertEquals(11, counter.count(
31 "Παρέμβαση των ΗΠΑ για τα τεχνητά νησιά που κατασκευάζει η Κ ίνα")); 34 "Παρέμβαση των ΗΠΑ για τα τεχνητά νησιά που κατασκευάζει η Κ ίνα"));
32 // Arabic 35 // Arabic
33 assertEquals(6, counter.count("زلزال بقوة 8.5 درجات يضرب اليابان")); 36 assertEquals(6, counter.count("زلزال بقوة 8.5 درجات يضرب اليابان"));
34 // Tibetan 37 // Tibetan
35 assertEquals(1, counter.count("༧གོང་ས་མཆོག་གི་ནང་གི་ངོ་སྤྲོད་ཀྱི་གསུ ང་ཆོས་ལེགས་གྲུབ།")); 38 assertEquals(1, counter.count("༧གོང་ས་མཆོག་གི་ནང་གི་ངོ་སྤྲོད་ཀྱི་གསུ ང་ཆོས་ལེགས་གྲུབ།"));
36 // Thai 39 // Thai
37 assertEquals(3, counter.count("โซลาร์ อิมพัลส์ทู เหินฟ้าข้ามมหาสมุทร ")); 40 assertEquals(3, counter.count("โซลาร์ อิมพัลส์ทู เหินฟ้าข้ามมหาสมุทร "));
38 } 41 }
39 } 42 }
40 43
41 public void testLetterWordCounter() { 44 public void testLetterWordCounter() {
42 List<StringUtil.WordCounter> counters = new ArrayList(); 45 List<StringUtil.WordCounter> counters = new ArrayList<WordCounter>();
43 counters.add(new StringUtil.LetterWordCounter()); 46 counters.add(new StringUtil.LetterWordCounter());
44 counters.add(new StringUtil.FullWordCounter()); 47 counters.add(new StringUtil.FullWordCounter());
45 48
46 for(StringUtil.WordCounter counter: counters) { 49 for(StringUtil.WordCounter counter: counters) {
47 // Hangul uses space as word delimiter like English. 50 // Hangul uses space as word delimiter like English.
48 assertEquals(1, counter.count("어")); 51 assertEquals(1, counter.count("어"));
49 assertEquals(2, counter.count("한국어 단어")); 52 assertEquals(2, counter.count("한국어 단어"));
50 assertEquals(5, counter.count("한 국 어 단 어")); 53 assertEquals(5, counter.count("한 국 어 단 어"));
51 assertEquals(8, counter.count( 54 assertEquals(8, counter.count(
52 "예비군 훈련장 총기 난사범 최모씨의 군복에서 발견된 유서.")); 55 "예비군 훈련장 총기 난사범 최모씨의 군복에서 발견된 유서."));
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 assertEquals("", StringUtil.join(new String[]{}, "")); 227 assertEquals("", StringUtil.join(new String[]{}, ""));
225 assertEquals("abc", StringUtil.join(new String[]{"abc"}, "def")); 228 assertEquals("abc", StringUtil.join(new String[]{"abc"}, "def"));
226 assertEquals("", StringUtil.join(new String[]{}, "def")); 229 assertEquals("", StringUtil.join(new String[]{}, "def"));
227 assertEquals("1, 2, 3", StringUtil.join(new String[]{"1", "2", "3"}, ", ")); 230 assertEquals("1, 2, 3", StringUtil.join(new String[]{"1", "2", "3"}, ", "));
228 assertEquals("1, 2, ", StringUtil.join(new String[]{"1", "2", ""}, ", ") ); 231 assertEquals("1, 2, ", StringUtil.join(new String[]{"1", "2", ""}, ", ") );
229 assertEquals(" , , ", StringUtil.join(new String[]{" ", "", " "}, ", ") ); 232 assertEquals(" , , ", StringUtil.join(new String[]{" ", "", " "}, ", ") );
230 assertEquals("123", StringUtil.join(new String[]{"1", "2", "3"}, "")); 233 assertEquals("123", StringUtil.join(new String[]{"1", "2", "3"}, ""));
231 assertEquals("abc123def", StringUtil.join(new String[]{"abc", "def"}, "1 23")); 234 assertEquals("abc123def", StringUtil.join(new String[]{"abc", "def"}, "1 23"));
232 } 235 }
233 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698