Source Code Cross Referenced for BreakIteratorTest.java in  » Internationalization-Localization » icu4j » com » ibm » icu » tests » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 2006, International Business Machines Corporation and         *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:
008:        package com.ibm.icu.tests;
009:
010:        import java.text.CharacterIterator;
011:        import java.text.StringCharacterIterator;
012:        import java.util.Locale;
013:
014:        import com.ibm.icu.text.BreakIterator;
015:        import com.ibm.icu.util.ULocale;
016:
017:        public class BreakIteratorTest extends ICUTestCase {
018:            // ICU behaves a bit differently with this text, but the tested values aren't
019:            // affected.  If Java changes behavior they might need to change.
020:            private static final String text = "Mr. and Mrs. Mumblety-Peg paid $35.97 for a new 12\" cockatoo. "
021:                    + "When they got home they both cooed \"Isn't it lovely?\" and sighed softly. "
022:                    + "\"Let's name it u\u0308\u5098!\" they said with glee.";
023:            private static int pos = text.indexOf("sn't");
024:            private static BreakIterator cbr;
025:            private static BreakIterator wbr;
026:            private static BreakIterator lbr;
027:            private static BreakIterator sbr;
028:
029:            static {
030:                cbr = BreakIterator.getCharacterInstance();
031:                cbr.setText(text);
032:                wbr = BreakIterator.getWordInstance();
033:                wbr.setText(text);
034:                lbr = BreakIterator.getLineInstance();
035:                lbr.setText(text);
036:                sbr = BreakIterator.getSentenceInstance();
037:                sbr.setText(text);
038:
039:                // diagnostic
040:                //              dump(cbr);
041:                //              dump(wbr);
042:                //              dump(lbr);
043:                //              dump(sbr);
044:            }
045:
046:            //      private static void dump(BreakIterator bi) {
047:            //              for (int ix = bi.first(), lim = text.length(); ix != lim;) {
048:            //                      int nx = bi.next();
049:            //                      if (nx < 0) nx = lim;
050:            //                      System.out.println(Integer.toString(ix) + ": " + text.substring(ix, nx));
051:            //                      ix = nx;
052:            //              }
053:            //      }
054:
055:            /*
056:             * Test method for 'com.ibm.icu.text.BreakIterator.hashCode()'
057:             */
058:            public void testHashCode() {
059:                BreakIterator br = BreakIterator.getWordInstance();
060:                br.setText(text);
061:                BreakIterator brne = BreakIterator.getWordInstance();
062:                brne.setText(text + "X");
063:                wbr.first();
064:                testEHCS(br, wbr, brne);
065:            }
066:
067:            /*
068:             * Test method for 'com.ibm.icu.text.BreakIterator.BreakIterator(BreakIterator)'
069:             */
070:            public void testBreakIterator() {
071:                // implicitly tested everywhere
072:            }
073:
074:            /*
075:             * Test method for 'com.ibm.icu.text.BreakIterator.first()'
076:             */
077:            public void testFirst() {
078:                assertEquals(0, cbr.first());
079:                assertEquals(0, wbr.first());
080:                assertEquals(0, lbr.first());
081:                assertEquals(0, sbr.first());
082:            }
083:
084:            /*
085:             * Test method for 'com.ibm.icu.text.BreakIterator.last()'
086:             */
087:            public void testLast() {
088:                assertEquals(text.length(), cbr.last());
089:                assertEquals(text.length(), wbr.last());
090:                assertEquals(text.length(), lbr.last());
091:                assertEquals(text.length(), sbr.last());
092:            }
093:
094:            /*
095:             * Test method for 'com.ibm.icu.text.BreakIterator.next(int)'
096:             */
097:            public void testNextInt() {
098:                cbr.first();
099:                wbr.first();
100:                lbr.first();
101:                sbr.first();
102:                assertEquals(2, cbr.next(2));
103:                assertEquals(3, wbr.next(2));
104:                assertEquals(8, lbr.next(2));
105:                assertEquals(62, sbr.next(2));
106:
107:                cbr.last();
108:                wbr.last();
109:                lbr.last();
110:                sbr.last();
111:                assertEquals(174, cbr.next(-2));
112:                assertEquals(171, wbr.next(-2));
113:                assertEquals(166, lbr.next(-2));
114:                assertEquals(135, sbr.next(-2));
115:            }
116:
117:            /*
118:             * Test method for 'com.ibm.icu.text.BreakIterator.next()'
119:             */
120:            public void testNext() {
121:                cbr.first();
122:                wbr.first();
123:                lbr.first();
124:                sbr.first();
125:                assertEquals(1, cbr.next());
126:                assertEquals(2, wbr.next());
127:                assertEquals(4, lbr.next());
128:                assertEquals(13, sbr.next());
129:            }
130:
131:            /*
132:             * Test method for 'com.ibm.icu.text.BreakIterator.previous()'
133:             */
134:            public void testPrevious() {
135:                cbr.last();
136:                wbr.last();
137:                lbr.last();
138:                sbr.last();
139:                assertEquals(175, cbr.previous());
140:                assertEquals(175, wbr.previous());
141:                assertEquals(171, lbr.previous());
142:                assertEquals(156, sbr.previous());
143:            }
144:
145:            /*
146:             * Test method for 'com.ibm.icu.text.BreakIterator.following(int)'
147:             */
148:            public void testFollowing() {
149:                assertEquals(100, cbr.following(pos));
150:                assertEquals(103, wbr.following(pos));
151:                assertEquals(104, lbr.following(pos));
152:                assertEquals(116, sbr.following(pos));
153:            }
154:
155:            /*
156:             * Test method for 'com.ibm.icu.text.BreakIterator.preceding(int)'
157:             */
158:            public void testPreceding() {
159:                assertEquals(98, cbr.preceding(pos));
160:                assertEquals(98, wbr.preceding(pos));
161:                assertEquals(97, lbr.preceding(pos));
162:                assertEquals(62, sbr.preceding(pos));
163:            }
164:
165:            /*
166:             * Test method for 'com.ibm.icu.text.BreakIterator.isBoundary(int)'
167:             */
168:            public void testIsBoundary() {
169:                assertTrue(cbr.isBoundary(pos));
170:                assertFalse(wbr.isBoundary(pos));
171:                assertFalse(lbr.isBoundary(pos));
172:                assertFalse(sbr.isBoundary(pos));
173:
174:            }
175:
176:            /*
177:             * Test method for 'com.ibm.icu.text.BreakIterator.current()'
178:             */
179:            public void testCurrent() {
180:                cbr.following(pos);
181:                wbr.following(pos);
182:                lbr.following(pos);
183:                sbr.following(pos);
184:                assertEquals(100, cbr.current());
185:                assertEquals(103, wbr.current());
186:                assertEquals(104, lbr.current());
187:                assertEquals(116, sbr.current());
188:            }
189:
190:            /*
191:             * Test method for 'com.ibm.icu.text.BreakIterator.getText()'
192:             */
193:            public void testGetText() {
194:                CharacterIterator ci = cbr.getText();
195:                StringBuffer buf = new StringBuffer(ci.getEndIndex()
196:                        - ci.getBeginIndex());
197:                for (char c = ci.first(); c != CharacterIterator.DONE; c = ci
198:                        .next()) {
199:                    buf.append(c);
200:                }
201:                String result = buf.toString();
202:                assertEquals(text, result);
203:            }
204:
205:            /*
206:             * Test method for 'com.ibm.icu.text.BreakIterator.setText(String)'
207:             */
208:            public void testSetTextString() {
209:                // implicitly tested
210:            }
211:
212:            /*
213:             * Test method for 'com.ibm.icu.text.BreakIterator.setText(CharacterIterator)'
214:             */
215:            public void testSetTextCharacterIterator() {
216:                CharacterIterator ci = new StringCharacterIterator(text, pos);
217:                BreakIterator bi = BreakIterator.getWordInstance();
218:                bi.setText(ci);
219:                assertEquals(2, bi.next());
220:            }
221:
222:            /*
223:             * Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance()'
224:             */
225:            public void testGetWordInstance() {
226:                // implicitly tested
227:            }
228:
229:            /*
230:             * Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance(Locale)'
231:             */
232:            public void testGetWordInstanceLocale() {
233:                assertNotNull(BreakIterator.getWordInstance(Locale.JAPAN));
234:            }
235:
236:            /*
237:             * Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance(ULocale)'
238:             */
239:            public void testGetWordInstanceULocale() {
240:                assertNotNull(BreakIterator.getWordInstance(ULocale.JAPAN));
241:            }
242:
243:            /*
244:             * Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance()'
245:             */
246:            public void testGetLineInstance() {
247:                // implicitly tested
248:            }
249:
250:            /*
251:             * Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance(Locale)'
252:             */
253:            public void testGetLineInstanceLocale() {
254:                assertNotNull(BreakIterator.getLineInstance(Locale.JAPAN));
255:            }
256:
257:            /*
258:             * Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance(ULocale)'
259:             */
260:            public void testGetLineInstanceULocale() {
261:                assertNotNull(BreakIterator.getLineInstance(ULocale.JAPAN));
262:            }
263:
264:            /*
265:             * Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance()'
266:             */
267:            public void testGetCharacterInstance() {
268:                // implicitly tested
269:            }
270:
271:            /*
272:             * Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance(Locale)'
273:             */
274:            public void testGetCharacterInstanceLocale() {
275:                assertNotNull(BreakIterator.getCharacterInstance(Locale.JAPAN));
276:            }
277:
278:            /*
279:             * Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance(ULocale)'
280:             */
281:            public void testGetCharacterInstanceULocale() {
282:                assertNotNull(BreakIterator.getCharacterInstance(ULocale.JAPAN));
283:            }
284:
285:            /*
286:             * Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance()'
287:             */
288:            public void testGetSentenceInstance() {
289:                // implicitly tested
290:            }
291:
292:            /*
293:             * Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance(Locale)'
294:             */
295:            public void testGetSentenceInstanceLocale() {
296:                assertNotNull(BreakIterator.getSentenceInstance(Locale.JAPAN));
297:            }
298:
299:            /*
300:             * Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance(ULocale)'
301:             */
302:            public void testGetSentenceInstanceULocale() {
303:                assertNotNull(BreakIterator.getSentenceInstance(ULocale.JAPAN));
304:            }
305:
306:            /*
307:             * Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance()'
308:             */
309:            public void testGetTitleInstance() {
310:                // not implemented
311:            }
312:
313:            /*
314:             * Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance(Locale)'
315:             */
316:            public void testGetTitleInstanceLocale() {
317:                // not implemented
318:            }
319:
320:            /*
321:             * Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance(ULocale)'
322:             */
323:            public void testGetTitleInstanceULocale() {
324:                // not implemented
325:            }
326:
327:            /*
328:             * Test method for 'com.ibm.icu.text.BreakIterator.getAvailableLocales()'
329:             */
330:            public void testGetAvailableLocales() {
331:                assertNotNull(BreakIterator.getAvailableLocales());
332:            }
333:
334:            /*
335:             * Test method for 'com.ibm.icu.text.BreakIterator.getAvailableULocales()'
336:             */
337:            public void testGetAvailableULocales() {
338:                assertNotNull(BreakIterator.getAvailableULocales());
339:            }
340:
341:            /*
342:             * Test method for 'com.ibm.icu.text.BreakIterator.toString()'
343:             */
344:            public void testToString() {
345:                assertNotNull(cbr.toString());
346:            }
347:
348:            /*
349:             * Test method for 'com.ibm.icu.text.BreakIterator.clone()'
350:             */
351:            public void testClone() {
352:                // see testHashCode
353:            }
354:
355:            /*
356:             * Test method for 'com.ibm.icu.text.BreakIterator.equals(Object)'
357:             */
358:            public void testEqualsObject() {
359:                // see testHashCode
360:            }
361:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.