File: BreakIteratorTest.java

package info (click to toggle)
openjdk-11 11.0.4%2B11-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 757,028 kB
  • sloc: java: 5,016,041; xml: 1,191,974; cpp: 934,731; ansic: 555,697; sh: 24,299; objc: 12,703; python: 3,602; asm: 3,415; makefile: 2,772; awk: 351; sed: 172; perl: 114; jsp: 24; csh: 3
file content (1438 lines) | stat: -rw-r--r-- 60,851 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
/*
 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

/*
 * @test
 * @bug 4035266 4052418 4068133 4068137 4068139 4086052 4095322 4097779
 *      4097920 4098467 4111338 4113835 4117554 4143071 4146175 4152117
 *      4152416 4153072 4158381 4214367 4217703 4638433
 * @library /java/text/testlib
 * @run main/timeout=2000 BreakIteratorTest
 * @summary test BreakIterator
 */

/*
 *
 *
 * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
 * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
 *
 * Portions copyright (c) 2007 Sun Microsystems, Inc.
 * All Rights Reserved.
 *
 * The original version of this source code and documentation
 * is copyrighted and owned by Taligent, Inc., a wholly-owned
 * subsidiary of IBM. These materials are provided under terms
 * of a License Agreement between Taligent and Sun. This technology
 * is protected by multiple US and International patents.
 *
 * This notice and attribution to Taligent may not be removed.
 * Taligent is a registered trademark of Taligent, Inc.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies. Please refer to the file "copyright.html"
 * for further important copyright and licensing information.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 *
 */

import java.text.BreakIterator;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Locale;
import java.util.Vector;
import java.util.Enumeration;
import java.io.*;

public class BreakIteratorTest extends IntlTest
{
    private BreakIterator characterBreak;
    private BreakIterator wordBreak;
    private BreakIterator lineBreak;
    private BreakIterator sentenceBreak;

    public static void main(String[] args) throws Exception {
        new BreakIteratorTest().run(args);
    }

    public BreakIteratorTest()
    {
        characterBreak = BreakIterator.getCharacterInstance();
        wordBreak = BreakIterator.getWordInstance();
        lineBreak = BreakIterator.getLineInstance();
        sentenceBreak = BreakIterator.getSentenceInstance();
    }

    //=========================================================================
    // general test subroutines
    //=========================================================================

    private void generalIteratorTest(BreakIterator bi, Vector expectedResult) {
        StringBuffer buffer = new StringBuffer();
        String text;
        for (int i = 0; i < expectedResult.size(); i++) {
            text = (String)expectedResult.elementAt(i);
            buffer.append(text);
        }
        text = buffer.toString();

        bi.setText(text);

        Vector nextResults = testFirstAndNext(bi, text);
        Vector previousResults = testLastAndPrevious(bi, text);

        logln("comparing forward and backward...");
        int errs = getErrorCount();
        compareFragmentLists("forward iteration", "backward iteration", nextResults,
                        previousResults);
        if (getErrorCount() == errs) {
            logln("comparing expected and actual...");
            compareFragmentLists("expected result", "actual result", expectedResult,
                            nextResults);
        }

        int[] boundaries = new int[expectedResult.size() + 3];
        boundaries[0] = BreakIterator.DONE;
        boundaries[1] = 0;
        for (int i = 0; i < expectedResult.size(); i++)
            boundaries[i + 2] = boundaries[i + 1] + ((String)expectedResult.elementAt(i)).
                            length();
        boundaries[boundaries.length - 1] = BreakIterator.DONE;

        testFollowing(bi, text, boundaries);
        testPreceding(bi, text, boundaries);
        testIsBoundary(bi, text, boundaries);

        doMultipleSelectionTest(bi, text);
    }

    private Vector testFirstAndNext(BreakIterator bi, String text) {
        int p = bi.first();
        int lastP = p;
        Vector<String> result = new Vector<String>();

        if (p != 0)
            errln("first() returned " + p + " instead of 0");
        while (p != BreakIterator.DONE) {
            p = bi.next();
            if (p != BreakIterator.DONE) {
                if (p <= lastP)
                    errln("next() failed to move forward: next() on position "
                                    + lastP + " yielded " + p);

                result.addElement(text.substring(lastP, p));
            }
            else {
                if (lastP != text.length())
                    errln("next() returned DONE prematurely: offset was "
                                    + lastP + " instead of " + text.length());
            }
            lastP = p;
        }
        return result;
    }

    private Vector testLastAndPrevious(BreakIterator bi, String text) {
        int p = bi.last();
        int lastP = p;
        Vector<String> result = new Vector<String>();

        if (p != text.length())
            errln("last() returned " + p + " instead of " + text.length());
        while (p != BreakIterator.DONE) {
            p = bi.previous();
            if (p != BreakIterator.DONE) {
                if (p >= lastP)
                    errln("previous() failed to move backward: previous() on position "
                                    + lastP + " yielded " + p);

                result.insertElementAt(text.substring(p, lastP), 0);
            }
            else {
                if (lastP != 0)
                    errln("previous() returned DONE prematurely: offset was "
                                    + lastP + " instead of 0");
            }
            lastP = p;
        }
        return result;
    }

    private void compareFragmentLists(String f1Name, String f2Name, Vector f1, Vector f2) {
        int p1 = 0;
        int p2 = 0;
        String s1;
        String s2;
        int t1 = 0;
        int t2 = 0;

        while (p1 < f1.size() && p2 < f2.size()) {
            s1 = (String)f1.elementAt(p1);
            s2 = (String)f2.elementAt(p2);
            t1 += s1.length();
            t2 += s2.length();

            if (s1.equals(s2)) {
                debugLogln("   >" + s1 + "<");
                ++p1;
                ++p2;
            }
            else {
                int tempT1 = t1;
                int tempT2 = t2;
                int tempP1 = p1;
                int tempP2 = p2;

                while (tempT1 != tempT2 && tempP1 < f1.size() && tempP2 < f2.size()) {
                    while (tempT1 < tempT2 && tempP1 < f1.size()) {
                        tempT1 += ((String)f1.elementAt(tempP1)).length();
                        ++tempP1;
                    }
                    while (tempT2 < tempT1 && tempP2 < f2.size()) {
                        tempT2 += ((String)f2.elementAt(tempP2)).length();
                        ++tempP2;
                    }
                }
                logln("*** " + f1Name + " has:");
                while (p1 <= tempP1 && p1 < f1.size()) {
                    s1 = (String)f1.elementAt(p1);
                    t1 += s1.length();
                    debugLogln(" *** >" + s1 + "<");
                    ++p1;
                }
                logln("***** " + f2Name + " has:");
                while (p2 <= tempP2 && p2 < f2.size()) {
                    s2 = (String)f2.elementAt(p2);
                    t2 += s2.length();
                    debugLogln(" ***** >" + s2 + "<");
                    ++p2;
                }
                errln("Discrepancy between " + f1Name + " and " + f2Name + "\n---\n" + f1 +"\n---\n" + f2);
            }
        }
    }

    private void testFollowing(BreakIterator bi, String text, int[] boundaries) {
        logln("testFollowing():");
        int p = 2;
        int i = 0;
        try {
            for (i = 0; i <= text.length(); i++) {  // change to <= when new BI code goes in
                if (i == boundaries[p])
                    ++p;

                int b = bi.following(i);
                logln("bi.following(" + i + ") -> " + b);
                if (b != boundaries[p])
                    errln("Wrong result from following() for " + i + ": expected " + boundaries[p]
                          + ", got " + b);
            }
        } catch (IllegalArgumentException illargExp) {
            errln("IllegalArgumentException caught from following() for offset: " + i);
        }
    }

    private void testPreceding(BreakIterator bi, String text, int[] boundaries) {
        logln("testPreceding():");
        int p = 0;
        int i = 0;
        try {
            for (i = 0; i <= text.length(); i++) {  // change to <= when new BI code goes in
                int b = bi.preceding(i);
                logln("bi.preceding(" + i + ") -> " + b);
                if (b != boundaries[p])
                    errln("Wrong result from preceding() for " + i + ": expected " + boundaries[p]
                          + ", got " + b);

                if (i == boundaries[p + 1])
                    ++p;
            }
        } catch (IllegalArgumentException illargExp) {
            errln("IllegalArgumentException caught from preceding() for offset: " + i);
        }
    }

    private void testIsBoundary(BreakIterator bi, String text, int[] boundaries) {
        logln("testIsBoundary():");
        int p = 1;
        boolean isB;
        for (int i = 0; i <= text.length(); i++) {  // change to <= when new BI code goes in
            isB = bi.isBoundary(i);
            logln("bi.isBoundary(" + i + ") -> " + isB);

            if (i == boundaries[p]) {
                if (!isB)
                    errln("Wrong result from isBoundary() for " + i + ": expected true, got false");
                ++p;
            }
            else {
                if (isB)
                    errln("Wrong result from isBoundary() for " + i + ": expected false, got true");
            }
        }
    }

    private void doMultipleSelectionTest(BreakIterator iterator, String testText)
    {
        logln("Multiple selection test...");
        BreakIterator testIterator = (BreakIterator)iterator.clone();
        int offset = iterator.first();
        int testOffset;
        int count = 0;

        do {
            testOffset = testIterator.first();
            testOffset = testIterator.next(count);
            logln("next(" + count + ") -> " + testOffset);
            if (offset != testOffset)
                errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset);

            if (offset != BreakIterator.DONE) {
                count++;
                offset = iterator.next();
            }
        } while (offset != BreakIterator.DONE);

        // now do it backwards...
        offset = iterator.last();
        count = 0;

        do {
            testOffset = testIterator.last();
            testOffset = testIterator.next(count);
            logln("next(" + count + ") -> " + testOffset);
            if (offset != testOffset)
                errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset);

            if (offset != BreakIterator.DONE) {
                count--;
                offset = iterator.previous();
            }
        } while (offset != BreakIterator.DONE);
    }

    private void doBreakInvariantTest(BreakIterator tb, String testChars)
    {
        StringBuffer work = new StringBuffer("aaa");
        int errorCount = 0;

        // a break should always occur after CR (unless followed by LF), LF, PS, and LS
        String breaks = /*"\r\n\u2029\u2028"*/"\n\u2029\u2028";
                            // change this back when new BI code is added

        for (int i = 0; i < breaks.length(); i++) {
            work.setCharAt(1, breaks.charAt(i));
            for (int j = 0; j < testChars.length(); j++) {
                work.setCharAt(0, testChars.charAt(j));
                for (int k = 0; k < testChars.length(); k++) {
                    char c = testChars.charAt(k);

                    // if a cr is followed by lf, don't do the check (they stay together)
                    if (work.charAt(1) == '\r' && (c == '\n'))
                        continue;

                    // CONTROL (Cc) and FORMAT (Cf) Characters are to be ignored
                    // for breaking purposes as per UTR14
                    int type1 = Character.getType(work.charAt(1));
                    int type2 = Character.getType(c);
                    if (type1 == Character.CONTROL || type1 == Character.FORMAT ||
                        type2 == Character.CONTROL || type2 == Character.FORMAT) {
                        continue;
                    }

                    work.setCharAt(2, c);
                    tb.setText(work.toString());
                    boolean seen2 = false;
                    for (int l = tb.first(); l != BreakIterator.DONE; l = tb.next()) {
                        if (l == 2)
                            seen2 = true;
                    }
                    if (!seen2) {
                        errln("No break between U+" + Integer.toHexString((int)(work.charAt(1)))
                                    + " and U+" + Integer.toHexString((int)(work.charAt(2))));
                        errorCount++;
                        if (errorCount >= 75)
                            return;
                    }
                }
            }
        }
    }

    private void doOtherInvariantTest(BreakIterator tb, String testChars)
    {
        StringBuffer work = new StringBuffer("a\r\na");
        int errorCount = 0;

        // a break should never occur between CR and LF
        for (int i = 0; i < testChars.length(); i++) {
            work.setCharAt(0, testChars.charAt(i));
            for (int j = 0; j < testChars.length(); j++) {
                work.setCharAt(3, testChars.charAt(j));
                tb.setText(work.toString());
                for (int k = tb.first(); k != BreakIterator.DONE; k = tb.next())
                    if (k == 2) {
                        errln("Break between CR and LF in string U+" + Integer.toHexString(
                                (int)(work.charAt(0))) + ", U+d U+a U+" + Integer.toHexString(
                                (int)(work.charAt(3))));
                        errorCount++;
                        if (errorCount >= 75)
                            return;
                    }
            }
        }

        // a break should never occur before a non-spacing mark, unless it's preceded
        // by a line terminator
        work.setLength(0);
        work.append("aaaa");
        for (int i = 0; i < testChars.length(); i++) {
            char c = testChars.charAt(i);
            if (c == '\n' || c == '\r' || c == '\u2029' || c == '\u2028' || c == '\u0003')
                continue;
            work.setCharAt(1, c);
            for (int j = 0; j < testChars.length(); j++) {
                c = testChars.charAt(j);
                if (Character.getType(c) != Character.NON_SPACING_MARK && Character.getType(c)
                        != Character.ENCLOSING_MARK)
                    continue;
                work.setCharAt(2, c);

                // CONTROL (Cc) and FORMAT (Cf) Characters are to be ignored
                // for breaking purposes as per UTR14
                int type1 = Character.getType(work.charAt(1));
                int type2 = Character.getType(work.charAt(2));
                if (type1 == Character.CONTROL || type1 == Character.FORMAT ||
                    type2 == Character.CONTROL || type2 == Character.FORMAT) {
                    continue;
                }

                tb.setText(work.toString());
                for (int k = tb.first(); k != BreakIterator.DONE; k = tb.next())
                    if (k == 2) {
                        errln("Break between U+" + Integer.toHexString((int)(work.charAt(1)))
                                + " and U+" + Integer.toHexString((int)(work.charAt(2))));
                        errorCount++;
                        if (errorCount >= 75)
                            return;
                    }
            }
        }
    }

    public void debugLogln(String s) {
        final String zeros = "0000";
        String temp;
        StringBuffer out = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c >= ' ' && c < '\u007f')
                out.append(c);
            else {
                out.append("\\u");
                temp = Integer.toHexString((int)c);
                out.append(zeros.substring(0, 4 - temp.length()));
                out.append(temp);
            }
        }
        logln(out.toString());
    }

    //=========================================================================
    // tests
    //=========================================================================

    public void TestWordBreak() {

        Vector<String> wordSelectionData = new Vector<String>();

        wordSelectionData.addElement("12,34");

        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("\u00A2"); //cent sign
        wordSelectionData.addElement("\u00A3"); //pound sign
        wordSelectionData.addElement("\u00A4"); //currency sign
        wordSelectionData.addElement("\u00A5"); //yen sign
        wordSelectionData.addElement("alpha-beta-gamma");
        wordSelectionData.addElement(".");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("Badges");
        wordSelectionData.addElement("?");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("BADGES");
        wordSelectionData.addElement("!");
        wordSelectionData.addElement("?");
        wordSelectionData.addElement("!");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("We");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("don't");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("need");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("no");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("STINKING");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("BADGES");
        wordSelectionData.addElement("!");
        wordSelectionData.addElement("!");
        wordSelectionData.addElement("!");

        wordSelectionData.addElement("012.566,5");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("123.3434,900");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("1000,233,456.000");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("1,23.322%");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("123.1222");

        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("\u0024123,000.20");

        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("179.01\u0025");

        wordSelectionData.addElement("Hello");
        wordSelectionData.addElement(",");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("how");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("are");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("you");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("X");
        wordSelectionData.addElement(" ");

        wordSelectionData.addElement("Now");
        wordSelectionData.addElement("\r");
        wordSelectionData.addElement("is");
        wordSelectionData.addElement("\n");
        wordSelectionData.addElement("the");
        wordSelectionData.addElement("\r\n");
        wordSelectionData.addElement("time");
        wordSelectionData.addElement("\n");
        wordSelectionData.addElement("\r");
        wordSelectionData.addElement("for");
        wordSelectionData.addElement("\r");
        wordSelectionData.addElement("\r");
        wordSelectionData.addElement("all");
        wordSelectionData.addElement(" ");

        generalIteratorTest(wordBreak, wordSelectionData);
    }

    public void TestBug4097779() {
        Vector<String> wordSelectionData = new Vector<String>();

        wordSelectionData.addElement("aa\u0300a");
        wordSelectionData.addElement(" ");

        generalIteratorTest(wordBreak, wordSelectionData);
    }

    public void TestBug4098467Words() {
        Vector<String> wordSelectionData = new Vector<String>();

        // What follows is a string of Korean characters (I found it in the Yellow Pages
        // ad for the Korean Presbyterian Church of San Francisco, and I hope I transcribed
        // it correctly), first as precomposed syllables, and then as conjoining jamo.
        // Both sequences should be semantically identical and break the same way.
        // precomposed syllables...
        wordSelectionData.addElement("\uc0c1\ud56d");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("\ud55c\uc778");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("\uc5f0\ud569");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("\uc7a5\ub85c\uad50\ud68c");
        wordSelectionData.addElement(" ");
        // conjoining jamo...
        wordSelectionData.addElement("\u1109\u1161\u11bc\u1112\u1161\u11bc");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("\u1112\u1161\u11ab\u110b\u1175\u11ab");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("\u110b\u1167\u11ab\u1112\u1161\u11b8");
        wordSelectionData.addElement(" ");
        wordSelectionData.addElement("\u110c\u1161\u11bc\u1105\u1169\u1100\u116d\u1112\u116c");
        wordSelectionData.addElement(" ");

        generalIteratorTest(wordBreak, wordSelectionData);
    }

    public void TestBug4117554Words() {
        Vector<String> wordSelectionData = new Vector<String>();

        // this is a test for bug #4117554: the ideographic iteration mark (U+3005) should
        // count as a Kanji character for the purposes of word breaking
        wordSelectionData.addElement("abc");
        wordSelectionData.addElement("\u4e01\u4e02\u3005\u4e03\u4e03");
        wordSelectionData.addElement("abc");

        generalIteratorTest(wordBreak, wordSelectionData);
    }

    public void TestSentenceBreak() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        sentenceSelectionData.addElement("This is a simple sample sentence. ");
        sentenceSelectionData.addElement("(This is it.) ");
        sentenceSelectionData.addElement("This is a simple sample sentence. ");
        sentenceSelectionData.addElement("\"This isn\'t it.\" ");
        sentenceSelectionData.addElement("Hi! ");
        sentenceSelectionData.addElement("This is a simple sample sentence. ");
        sentenceSelectionData.addElement("It does not have to make any sense as you can see. ");
        sentenceSelectionData.addElement("Nel mezzo del cammin di nostra vita, mi ritrovai in una selva oscura. ");
        sentenceSelectionData.addElement("Che la dritta via aveo smarrita. ");
        sentenceSelectionData.addElement("He said, that I said, that you said!! ");

        sentenceSelectionData.addElement("Don't rock the boat.\u2029");

        sentenceSelectionData.addElement("Because I am the daddy, that is why. ");
        sentenceSelectionData.addElement("Not on my time (el timo.)! ");

        sentenceSelectionData.addElement("So what!!\u2029");

        sentenceSelectionData.addElement("\"But now,\" he said, \"I know!\" ");
        sentenceSelectionData.addElement("Harris thumbed down several, including \"Away We Go\" (which became the huge success Oklahoma!). ");
        sentenceSelectionData.addElement("One species, B. anthracis, is highly virulent.\n");
        sentenceSelectionData.addElement("Wolf said about Sounder:\"Beautifully thought-out and directed.\" ");
        sentenceSelectionData.addElement("Have you ever said, \"This is where \tI shall live\"? ");
        sentenceSelectionData.addElement("He answered, \"You may not!\" ");
        sentenceSelectionData.addElement("Another popular saying is: \"How do you do?\". ");
        sentenceSelectionData.addElement("Yet another popular saying is: \'I\'m fine thanks.\' ");
        sentenceSelectionData.addElement("What is the proper use of the abbreviation pp.? ");
        sentenceSelectionData.addElement("Yes, I am definatelly 12\" tall!!");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestBug4113835() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        // test for bug #4113835: \n and \r count as spaces, not as paragraph breaks
        sentenceSelectionData.addElement("Now\ris\nthe\r\ntime\n\rfor\r\rall\u2029");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestBug4111338() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        // test for bug #4111338: Don't break sentences at the boundary between CJK
        // and other letters
        sentenceSelectionData.addElement("\u5487\u67ff\ue591\u5017\u61b3\u60a1\u9510\u8165:\"JAVA\u821c"
                + "\u8165\u7fc8\u51ce\u306d,\u2494\u56d8\u4ec0\u60b1\u8560\u51ba"
                + "\u611d\u57b6\u2510\u5d46\".\u2029");
        sentenceSelectionData.addElement("\u5487\u67ff\ue591\u5017\u61b3\u60a1\u9510\u8165\u9de8"
                + "\u97e4JAVA\u821c\u8165\u7fc8\u51ce\u306d\ue30b\u2494\u56d8\u4ec0"
                + "\u60b1\u8560\u51ba\u611d\u57b6\u2510\u5d46\u97e5\u7751\u2029");
        sentenceSelectionData.addElement("\u5487\u67ff\ue591\u5017\u61b3\u60a1\u9510\u8165\u9de8\u97e4"
                + "\u6470\u8790JAVA\u821c\u8165\u7fc8\u51ce\u306d\ue30b\u2494\u56d8"
                + "\u4ec0\u60b1\u8560\u51ba\u611d\u57b6\u2510\u5d46\u97e5\u7751\u2029");
        sentenceSelectionData.addElement("He said, \"I can go there.\"\u2029");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestBug4117554Sentences() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        // Treat fullwidth variants of .!? the same as their
        // normal counterparts
        sentenceSelectionData.addElement("I know I'm right\uff0e ");
        sentenceSelectionData.addElement("Right\uff1f ");
        sentenceSelectionData.addElement("Right\uff01 ");

        // Don't break sentences at boundary between CJK and digits
        sentenceSelectionData.addElement("\u5487\u67ff\ue591\u5017\u61b3\u60a1\u9510\u8165\u9de8"
                + "\u97e48888\u821c\u8165\u7fc8\u51ce\u306d\ue30b\u2494\u56d8\u4ec0"
                + "\u60b1\u8560\u51ba\u611d\u57b6\u2510\u5d46\u97e5\u7751\u2029");

        // Break sentence between a sentence terminator and
        // opening punctuation
        sentenceSelectionData.addElement("no?");
        sentenceSelectionData.addElement("(yes)");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestBug4158381() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        // Don't break sentence after period if it isn't followed by a space
        sentenceSelectionData.addElement("Test <code>Flags.Flag</code> class.  ");
        sentenceSelectionData.addElement("Another test.\u2029");

        // No breaks when there are no terminators around
        sentenceSelectionData.addElement("<P>Provides a set of "
                + "&quot;lightweight&quot; (all-java<FONT SIZE=\"-2\"><SUP>TM"
                + "</SUP></FONT> language) components that, "
                + "to the maximum degree possible, work the same on all platforms.  ");
        sentenceSelectionData.addElement("Another test.\u2029");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestBug4143071() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        // Make sure sentences that end with digits work right
        sentenceSelectionData.addElement("Today is the 27th of May, 1998.  ");
        sentenceSelectionData.addElement("Tomorrow with be 28 May 1998.  ");
        sentenceSelectionData.addElement("The day after will be the 30th.\u2029");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestBug4152416() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        // Make sure sentences ending with a capital letter are treated correctly
        sentenceSelectionData.addElement("The type of all primitive "
                + "<code>boolean</code> values accessed in the target VM.  ");
        sentenceSelectionData.addElement("Calls to xxx will return an "
                + "implementor of this interface.\u2029");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestBug4152117() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        // Make sure sentence breaking is handling punctuation correctly
        // [COULD NOT REPRODUCE THIS BUG, BUT TEST IS HERE TO MAKE SURE
        // IT DOESN'T CROP UP]
        sentenceSelectionData.addElement("Constructs a randomly generated "
                + "BigInteger, uniformly distributed over the range <tt>0</tt> "
                + "to <tt>(2<sup>numBits</sup> - 1)</tt>, inclusive.  ");
        sentenceSelectionData.addElement("The uniformity of the distribution "
                + "assumes that a fair source of random bits is provided in "
                + "<tt>rnd</tt>.  ");
        sentenceSelectionData.addElement("Note that this constructor always "
                + "constructs a non-negative BigInteger.\u2029");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestLineBreak() {
        Vector<String> lineSelectionData = new Vector<String>();

        lineSelectionData.addElement("Multi-");
        lineSelectionData.addElement("Level ");
        lineSelectionData.addElement("example ");
        lineSelectionData.addElement("of ");
        lineSelectionData.addElement("a ");
        lineSelectionData.addElement("semi-");
        lineSelectionData.addElement("idiotic ");
        lineSelectionData.addElement("non-");
        lineSelectionData.addElement("sensical ");
        lineSelectionData.addElement("(non-");
        lineSelectionData.addElement("important) ");
        lineSelectionData.addElement("sentence. ");

        lineSelectionData.addElement("Hi  ");
        lineSelectionData.addElement("Hello ");
        lineSelectionData.addElement("How\n");
        lineSelectionData.addElement("are\r");
        lineSelectionData.addElement("you\u2028");
        lineSelectionData.addElement("fine.\t");
        lineSelectionData.addElement("good.  ");

        lineSelectionData.addElement("Now\r");
        lineSelectionData.addElement("is\n");
        lineSelectionData.addElement("the\r\n");
        lineSelectionData.addElement("time\n");
        lineSelectionData.addElement("\r");
        lineSelectionData.addElement("for\r");
        lineSelectionData.addElement("\r");
        lineSelectionData.addElement("all");

        generalIteratorTest(lineBreak, lineSelectionData);
    }

    public void TestBug4068133() {
        Vector<String> lineSelectionData = new Vector<String>();

        lineSelectionData.addElement("\u96f6");
        lineSelectionData.addElement("\u4e00\u3002");
        lineSelectionData.addElement("\u4e8c\u3001");
        lineSelectionData.addElement("\u4e09\u3002\u3001");
        lineSelectionData.addElement("\u56db\u3001\u3002\u3001");
        lineSelectionData.addElement("\u4e94,");
        lineSelectionData.addElement("\u516d.");
        lineSelectionData.addElement("\u4e03.\u3001,\u3002");
        lineSelectionData.addElement("\u516b");

        generalIteratorTest(lineBreak, lineSelectionData);
    }

    public void TestBug4086052() {
        Vector<String> lineSelectionData = new Vector<String>();

        lineSelectionData.addElement("foo\u00a0bar ");
//        lineSelectionData.addElement("foo\ufeffbar");

        generalIteratorTest(lineBreak, lineSelectionData);
    }

    public void TestBug4097920() {
        Vector<String> lineSelectionData = new Vector<String>();

        lineSelectionData.addElement("dog,");
        lineSelectionData.addElement("cat,");
        lineSelectionData.addElement("mouse ");
        lineSelectionData.addElement("(one)");
        lineSelectionData.addElement("(two)\n");

        generalIteratorTest(lineBreak, lineSelectionData);
    }
    /*
    public void TestBug4035266() {
        Vector<String> lineSelectionData = new Vector<String>();

        lineSelectionData.addElement("The ");
        lineSelectionData.addElement("balance ");
        lineSelectionData.addElement("is ");
        lineSelectionData.addElement("$-23,456.78, ");
        lineSelectionData.addElement("not ");
        lineSelectionData.addElement("-$32,456.78!\n");

        generalIteratorTest(lineBreak, lineSelectionData);
    }
    */
    public void TestBug4098467Lines() {
        Vector<String> lineSelectionData = new Vector<String>();

        // What follows is a string of Korean characters (I found it in the Yellow Pages
        // ad for the Korean Presbyterian Church of San Francisco, and I hope I transcribed
        // it correctly), first as precomposed syllables, and then as conjoining jamo.
        // Both sequences should be semantically identical and break the same way.
        // precomposed syllables...
        lineSelectionData.addElement("\uc0c1");
        lineSelectionData.addElement("\ud56d ");
        lineSelectionData.addElement("\ud55c");
        lineSelectionData.addElement("\uc778 ");
        lineSelectionData.addElement("\uc5f0");
        lineSelectionData.addElement("\ud569 ");
        lineSelectionData.addElement("\uc7a5");
        lineSelectionData.addElement("\ub85c");
        lineSelectionData.addElement("\uad50");
        lineSelectionData.addElement("\ud68c ");
        // conjoining jamo...
        lineSelectionData.addElement("\u1109\u1161\u11bc\u1112\u1161\u11bc ");
        lineSelectionData.addElement("\u1112\u1161\u11ab\u110b\u1175\u11ab ");
        lineSelectionData.addElement("\u110b\u1167\u11ab\u1112\u1161\u11b8 ");
        lineSelectionData.addElement("\u110c\u1161\u11bc\u1105\u1169\u1100\u116d\u1112\u116c");

        if (Locale.getDefault().getLanguage().equals("th")) {
            logln("This test is skipped in th locale.");
            return;
        }

        generalIteratorTest(lineBreak, lineSelectionData);
    }

    public void TestBug4117554Lines() {
        Vector<String> lineSelectionData = new Vector<String>();

        // Fullwidth .!? should be treated as postJwrd
        lineSelectionData.addElement("\u4e01\uff0e");
        lineSelectionData.addElement("\u4e02\uff01");
        lineSelectionData.addElement("\u4e03\uff1f");

        generalIteratorTest(lineBreak, lineSelectionData);
    }

    public void TestBug4217703() {
        if (Locale.getDefault().getLanguage().equals("th")) {
            logln("This test is skipped in th locale.");
            return;
        }

        Vector<String> lineSelectionData = new Vector<String>();

        // There shouldn't be a line break between sentence-ending punctuation
        // and a closing quote
        lineSelectionData.addElement("He ");
        lineSelectionData.addElement("said ");
        lineSelectionData.addElement("\"Go!\"  ");
        lineSelectionData.addElement("I ");
        lineSelectionData.addElement("went.  ");

        lineSelectionData.addElement("Hashtable$Enumeration ");
        lineSelectionData.addElement("getText().");
        lineSelectionData.addElement("getIndex()");

        generalIteratorTest(lineBreak, lineSelectionData);
    }

    private static final String graveS = "S\u0300";
    private static final String acuteBelowI = "i\u0317";
    private static final String acuteE = "e\u0301";
    private static final String circumflexA = "a\u0302";
    private static final String tildeE = "e\u0303";

    public void TestCharacterBreak() {
        Vector<String> characterSelectionData = new Vector<String>();

        characterSelectionData.addElement(graveS);
        characterSelectionData.addElement(acuteBelowI);
        characterSelectionData.addElement("m");
        characterSelectionData.addElement("p");
        characterSelectionData.addElement("l");
        characterSelectionData.addElement(acuteE);
        characterSelectionData.addElement(" ");
        characterSelectionData.addElement("s");
        characterSelectionData.addElement(circumflexA);
        characterSelectionData.addElement("m");
        characterSelectionData.addElement("p");
        characterSelectionData.addElement("l");
        characterSelectionData.addElement(tildeE);
        characterSelectionData.addElement(".");
        characterSelectionData.addElement("w");
        characterSelectionData.addElement(circumflexA);
        characterSelectionData.addElement("w");
        characterSelectionData.addElement("a");
        characterSelectionData.addElement("f");
        characterSelectionData.addElement("q");
        characterSelectionData.addElement("\n");
        characterSelectionData.addElement("\r");
        characterSelectionData.addElement("\r\n");
        characterSelectionData.addElement("\n");

        generalIteratorTest(characterBreak, characterSelectionData);
    }

    public void TestBug4098467Characters() {
        Vector<String> characterSelectionData = new Vector<String>();

        // What follows is a string of Korean characters (I found it in the Yellow Pages
        // ad for the Korean Presbyterian Church of San Francisco, and I hope I transcribed
        // it correctly), first as precomposed syllables, and then as conjoining jamo.
        // Both sequences should be semantically identical and break the same way.
        // precomposed syllables...
        characterSelectionData.addElement("\uc0c1");
        characterSelectionData.addElement("\ud56d");
        characterSelectionData.addElement(" ");
        characterSelectionData.addElement("\ud55c");
        characterSelectionData.addElement("\uc778");
        characterSelectionData.addElement(" ");
        characterSelectionData.addElement("\uc5f0");
        characterSelectionData.addElement("\ud569");
        characterSelectionData.addElement(" ");
        characterSelectionData.addElement("\uc7a5");
        characterSelectionData.addElement("\ub85c");
        characterSelectionData.addElement("\uad50");
        characterSelectionData.addElement("\ud68c");
        characterSelectionData.addElement(" ");
        // conjoining jamo...
        characterSelectionData.addElement("\u1109\u1161\u11bc");
        characterSelectionData.addElement("\u1112\u1161\u11bc");
        characterSelectionData.addElement(" ");
        characterSelectionData.addElement("\u1112\u1161\u11ab");
        characterSelectionData.addElement("\u110b\u1175\u11ab");
        characterSelectionData.addElement(" ");
        characterSelectionData.addElement("\u110b\u1167\u11ab");
        characterSelectionData.addElement("\u1112\u1161\u11b8");
        characterSelectionData.addElement(" ");
        characterSelectionData.addElement("\u110c\u1161\u11bc");
        characterSelectionData.addElement("\u1105\u1169");
        characterSelectionData.addElement("\u1100\u116d");
        characterSelectionData.addElement("\u1112\u116c");

        generalIteratorTest(characterBreak, characterSelectionData);
    }

    public void TestBug4153072() {
        BreakIterator iter = BreakIterator.getWordInstance();
        String str = "...Hello, World!...";
        int begin = 3;
        int end = str.length() - 3;
        boolean gotException = false;
        boolean dummy;

        iter.setText(new StringCharacterIterator(str, begin, end, begin));
        for (int index = -1; index < begin + 1; ++index) {
            try {
                dummy = iter.isBoundary(index);
                if (index < begin)
                    errln("Didn't get exception with offset = " + index +
                                    " and begin index = " + begin);
            }
            catch (IllegalArgumentException e) {
                if (index >= begin)
                    errln("Got exception with offset = " + index +
                                    " and begin index = " + begin);
            }
        }
    }

    public void TestBug4146175Sentences() {
        Vector<String> sentenceSelectionData = new Vector<String>();

        // break between periods and opening punctuation even when there's no
        // intervening space
        sentenceSelectionData.addElement("end.");
        sentenceSelectionData.addElement("(This is\u2029");

        // treat the fullwidth period as an unambiguous sentence terminator
        sentenceSelectionData.addElement("\u7d42\u308f\u308a\uff0e");
        sentenceSelectionData.addElement("\u300c\u3053\u308c\u306f");

        generalIteratorTest(sentenceBreak, sentenceSelectionData);
    }

    public void TestBug4146175Lines() {
        if (Locale.getDefault().getLanguage().equals("th")) {
            logln("This test is skipped in th locale.");
            return;
        }

        Vector<String> lineSelectionData = new Vector<String>();

        // the fullwidth comma should stick to the preceding Japanese character
        lineSelectionData.addElement("\u7d42\uff0c");
        lineSelectionData.addElement("\u308f");

        generalIteratorTest(lineBreak, lineSelectionData);
    }

    public void TestBug4214367() {
        if (Locale.getDefault().getLanguage().equals("th")) {
            logln("This test is skipped in th locale.");
            return;
        }

        Vector<String> wordSelectionData = new Vector<String>();

        // the hiragana and katakana iteration marks and the long vowel mark
        // are not being treated correctly by the word-break iterator
        wordSelectionData.addElement("\u3042\u3044\u309d\u3042\u309e\u3042\u30fc\u3042");
        wordSelectionData.addElement("\u30a2\u30a4\u30fd\u30a2\u30fe\u30a2\u30fc\u30a2");

        generalIteratorTest(wordBreak, wordSelectionData);
    }

    private static final String cannedTestChars // characters fo the class Cc are ignorable for breaking
        = /*"\u0000\u0001\u0002\u0003\u0004*/" !\"#$%&()+-01234<=>ABCDE[]^_`abcde{}|\u00a0\u00a2"
        + "\u00a3\u00a4\u00a5\u00a6\u00a7\u00a8\u00a9\u00ab\u00ad\u00ae\u00af\u00b0\u00b2\u00b3"
        + "\u00b4\u00b9\u00bb\u00bc\u00bd\u02b0\u02b1\u02b2\u02b3\u02b4\u0300\u0301\u0302\u0303"
        + "\u0304\u05d0\u05d1\u05d2\u05d3\u05d4\u0903\u093e\u093f\u0940\u0949\u0f3a\u0f3b\u2000"
        + "\u2001\u2002\u200c\u200d\u200e\u200f\u2010\u2011\u2012\u2028\u2029\u202a\u203e\u203f"
        + "\u2040\u20dd\u20de\u20df\u20e0\u2160\u2161\u2162\u2163\u2164";

    public void TestSentenceInvariants()
    {
        BreakIterator e = BreakIterator.getSentenceInstance();
        doOtherInvariantTest(e, cannedTestChars + ".,\u3001\u3002\u3041\u3042\u3043\ufeff");
    }

    public void TestWordInvariants()
    {
        if (Locale.getDefault().getLanguage().equals("th")) {
            logln("This test is skipped in th locale.");
            return;
        }

        BreakIterator e = BreakIterator.getWordInstance();
        doBreakInvariantTest(e, cannedTestChars + "\',.\u3041\u3042\u3043\u309b\u309c\u30a1\u30a2"
            + "\u30a3\u4e00\u4e01\u4e02");
        doOtherInvariantTest(e, cannedTestChars + "\',.\u3041\u3042\u3043\u309b\u309c\u30a1\u30a2"
            + "\u30a3\u4e00\u4e01\u4e02");
    }

    public void TestLineInvariants()
    {
        if (Locale.getDefault().getLanguage().equals("th")) {
            logln("This test is skipped in th locale.");
            return;
        }

        BreakIterator e = BreakIterator.getLineInstance();
        String testChars = cannedTestChars + ".,;:\u3001\u3002\u3041\u3042\u3043\u3044\u3045"
            + "\u30a3\u4e00\u4e01\u4e02";
        doBreakInvariantTest(e, testChars);
        doOtherInvariantTest(e, testChars);

        int errorCount = 0;

        // in addition to the other invariants, a line-break iterator should make sure that:
        // it doesn't break around the non-breaking characters
        String noBreak = "\u00a0\u2007\u2011\ufeff";
        StringBuffer work = new StringBuffer("aaa");
        for (int i = 0; i < testChars.length(); i++) {
            char c = testChars.charAt(i);
            if (c == '\r' || c == '\n' || c == '\u2029' || c == '\u2028' || c == '\u0003')
                continue;
            work.setCharAt(0, c);
            for (int j = 0; j < noBreak.length(); j++) {
                work.setCharAt(1, noBreak.charAt(j));
                for (int k = 0; k < testChars.length(); k++) {
                    work.setCharAt(2, testChars.charAt(k));
                    // CONTROL (Cc) and FORMAT (Cf) Characters are to be ignored
                    // for breaking purposes as per UTR14
                    int type1 = Character.getType(work.charAt(1));
                    int type2 = Character.getType(work.charAt(2));
                    if (type1 == Character.CONTROL || type1 == Character.FORMAT ||
                        type2 == Character.CONTROL || type2 == Character.FORMAT) {
                        continue;
                    }
                    e.setText(work.toString());
                    for (int l = e.first(); l != BreakIterator.DONE; l = e.next()) {
                        if (l == 1 || l == 2) {
                            //errln("Got break between U+" + Integer.toHexString((int)
                            //        (work.charAt(l - 1))) + " and U+" + Integer.toHexString(
                            //        (int)(work.charAt(l))) + "\ntype1 = " + type1 + "\ntype2 = " + type2);
                            // as per UTR14 spaces followed by a GLUE character should allow
                            // line breaking
                            if (work.charAt(l-1) == '\u0020' && (work.charAt(l) == '\u00a0' ||
                                                                 work.charAt(l) == '\u0f0c' ||
                                                                 work.charAt(l) == '\u2007' ||
                                                                 work.charAt(l) == '\u2011' ||
                                                                 work.charAt(l) == '\u202f' ||
                                                                 work.charAt(l) == '\ufeff')) {
                                continue;
                            }
                            errln("Got break between U+" + Integer.toHexString((int)
                                    (work.charAt(l - 1))) + " and U+" + Integer.toHexString(
                                    (int)(work.charAt(l))));
                            errorCount++;
                            if (errorCount >= 75)
                                return;
                        }
                    }
                }
            }
        }

        // The following test has so many exceptions that it would be better to write a new set of data
        // that tested exactly what should be tested
        // Until that point it will be commented out
        /*

        // it does break after dashes (unless they're followed by a digit, a non-spacing mark,
        // a currency symbol, a space, a format-control character, a regular control character,
        // a line or paragraph separator, or another dash)
        String dashes = "-\u00ad\u2010\u2012\u2013\u2014";
        for (int i = 0; i < testChars.length(); i++) {
            work.setCharAt(0, testChars.charAt(i));
            for (int j = 0; j < dashes.length(); j++) {
                work.setCharAt(1, dashes.charAt(j));
                for (int k = 0; k < testChars.length(); k++) {
                    char c = testChars.charAt(k);
                    if (Character.getType(c) == Character.DECIMAL_DIGIT_NUMBER ||
                        Character.getType(c) == Character.OTHER_NUMBER ||
                        Character.getType(c) == Character.NON_SPACING_MARK ||
                        Character.getType(c) == Character.ENCLOSING_MARK ||
                        Character.getType(c) == Character.CURRENCY_SYMBOL ||
                        Character.getType(c) == Character.DASH_PUNCTUATION ||
                        Character.getType(c) == Character.SPACE_SEPARATOR ||
                        Character.getType(c) == Character.FORMAT ||
                        Character.getType(c) == Character.CONTROL ||
                        Character.getType(c) == Character.END_PUNCTUATION ||
                        Character.getType(c) == Character.FINAL_QUOTE_PUNCTUATION ||
                        Character.getType(c) == Character.OTHER_PUNCTUATION ||
                        c == '\'' || c == '\"' ||
                        // category EX as per UTR14
                        c == '!' || c == '?' || c == '\ufe56' || c == '\ufe57' || c == '\uff01' || c == '\uff1f' ||
                        c == '\n' || c == '\r' || c == '\u2028' || c == '\u2029' ||
                        c == '\u0003' || c == '\u2007' || c == '\u2011' ||
                        c == '\ufeff')
                        continue;
                    work.setCharAt(2, c);
                    e.setText(work.toString());
                    boolean saw2 = false;
                    for (int l = e.first(); l != BreakIterator.DONE; l = e.next())
                        if (l == 2)
                            saw2 = true;
                    if (!saw2) {
                        errln("Didn't get break between U+" + Integer.toHexString((int)
                                    (work.charAt(1))) + " and U+" + Integer.toHexString(
                                    (int)(work.charAt(2))));
                        errorCount++;
                        if (errorCount >= 75)
                            return;
                    }
                }
            }
        }
        */
    }

    public void TestCharacterInvariants()
    {
        BreakIterator e = BreakIterator.getCharacterInstance();
        doBreakInvariantTest(e, cannedTestChars + "\u1100\u1101\u1102\u1160\u1161\u1162\u11a8"
            + "\u11a9\u11aa");
        doOtherInvariantTest(e, cannedTestChars + "\u1100\u1101\u1102\u1160\u1161\u1162\u11a8"
            + "\u11a9\u11aa");
    }

    public void TestEmptyString()
    {
        String text = "";
        Vector<String> x = new Vector<String>();
        x.addElement(text);

        generalIteratorTest(lineBreak, x);
    }

    public void TestGetAvailableLocales()
    {
        Locale[] locList = BreakIterator.getAvailableLocales();

        if (locList.length == 0)
            errln("getAvailableLocales() returned an empty list!");
        // I have no idea how to test this function...
    }


    /**
     * Bug 4095322
     */
    public void TestJapaneseLineBreak()
    {
        StringBuffer testString = new StringBuffer("\u4e00x\u4e8c");
        // Breaking on <Kanji>$<Kanji> is inconsistent

        /* Characters in precedingChars and followingChars have been updated
         * from Unicode 2.0.14-based to 3.0.0-based when 4638433 was fixed.
         * In concrete terms,
         *   0x301F : Its category was changed from Ps to Pe since Unicode 2.1.
         *   0x169B & 0x169C : added since Unicode 3.0.0.
         */
        String precedingChars =
            /* Puctuation, Open */
          "([{\u201a\u201e\u2045\u207d\u208d\u2329\u3008\u300a\u300c\u300e\u3010\u3014\u3016\u3018\u301a\u301d\ufe35\ufe37\ufe39\ufe3b\ufe3d\ufe3f\ufe41\ufe43\ufe59\ufe5b\ufe5d\uff08\uff3b\uff5b\uff62\u169b"
            /* Punctuation, Initial quote */
          + "\u00ab\u2018\u201b\u201c\u201f\u2039"
            /* Symbol, Currency */
          + "\u00a5\u00a3\u00a4\u20a0";

        String followingChars =
            /* Puctuation, Close */
          ")]}\u2046\u207e\u208e\u232a\u3009\u300b\u300d\u300f\u3011\u3015\u3017\u3019\u301b\u301e\u301f\ufd3e\ufe36\ufe38\ufe3a\ufe3c\ufe3e\ufe40\ufe42\ufe44\ufe5a\ufe5c\ufe5e\uff09\uff3d\uff5d\uff63\u169c"
            /* Punctuation, Final quote */
          + "\u00bb\u2019\u201d\u203a"
            /* Punctuation, Other */
          + "!%,.:;\u3001\u3002\u2030\u2031\u2032\u2033\u2034"
            /* Punctuation, Dash */
          + "\u2103\u2109"
            /* Symbol, Currency */
          + "\u00a2"
            /* Letter, Modifier */
          + "\u3005\u309d\u309e"
            /* Letter, Other */
          + "\u3063\u3083\u3085\u3087\u30c3\u30e3\u30e5\u30e7\u30fc\u30fd\u30fe"
           /* Mark, Non-Spacing */
          + "\u0300\u0301\u0302"
            /* Symbol, Modifier */
          + "\u309b\u309c"
            /* Symbol, Other */
          + "\u00b0";

        BreakIterator iter = BreakIterator.getLineInstance(Locale.JAPAN);

        for (int i = 0; i < precedingChars.length(); i++) {
            testString.setCharAt(1, precedingChars.charAt(i));
            iter.setText(testString.toString());
            int j = iter.first();
            if (j != 0) {
                errln("ja line break failure: failed to start at 0 and bounced at " + j);
            }
            j = iter.next();
            if (j != 1) {
                errln("ja line break failure: failed to stop before '"
                        + precedingChars.charAt(i) + "' (\\u"
                        + Integer.toString(precedingChars.charAt(i), 16)
                        + ") at 1 and bounded at " + j);
            }
            j = iter.next();
            if (j != 3) {
                errln("ja line break failure: failed to skip position after '"
                        + precedingChars.charAt(i) + "' (\\u"
                        + Integer.toString(precedingChars.charAt(i), 16)
                        + ") at 3 and bounded at " + j);
            }
        }

        for (int i = 0; i < followingChars.length(); i++) {
            testString.setCharAt(1, followingChars.charAt(i));
            iter.setText(testString.toString());
            int j = iter.first();
            if (j != 0) {
                errln("ja line break failure: failed to start at 0 and bounded at " + j);
            }
            j = iter.next();
            if (j != 2) {
                errln("ja line break failure: failed to skip position before '"
                        + followingChars.charAt(i) + "' (\\u"
                        + Integer.toString(followingChars.charAt(i), 16)
                        + ") at 2 and bounded at " + j);
            }
            j = iter.next();
            if (j != 3) {
                errln("ja line break failure: failed to stop after '"
                        + followingChars.charAt(i) + "' (\\u"
                        + Integer.toString(followingChars.charAt(i), 16)
                        + ") at 3 and bounded at " + j);
            }
        }
    }

    /**
     * Bug 4638433
     */
    public void TestLineBreakBasedOnUnicode3_0_0()
    {
        BreakIterator iter;
        int i;

        /* Latin Extend-B characters
         * 0x0218-0x0233 which have been added since Unicode 3.0.0.
         */
        iter = BreakIterator.getWordInstance(Locale.US);
        iter.setText("\u0216\u0217\u0218\u0219\u021A");
        i = iter.first();
        i = iter.next();
        if (i != 5) {
            errln("Word break failure: failed to stop at 5 and bounded at " + i);
        }


        iter = BreakIterator.getLineInstance(Locale.US);

        /* <Three(Nd)><Two(Nd)><Low Double Prime Quotation Mark(Pe)><One(Nd)>
         * \u301f has changed its category from Ps to Pe since Unicode 2.1.
         */
        iter.setText("32\u301f1");
        i = iter.first();
        i = iter.next();
        if (i != 3) {
            errln("Line break failure: failed to skip before \\u301F(Pe) at 3 and bounded at " + i);
        }

        /* Mongolian <Letter A(Lo)><Todo Soft Hyphen(Pd)><Letter E(Lo)>
         * which have been added since Unicode 3.0.0.
         */
        iter.setText("\u1820\u1806\u1821");
        i = iter.first();
        i = iter.next();
        if (i != 2) {
            errln("Mongolian line break failure: failed to skip position before \\u1806(Pd) at 2 and bounded at " + i);
        }

        /* Khmer <ZERO(Nd)><Currency Symbol(Sc)><ONE(Nd)> which have
         * been added since Unicode 3.0.0.
         */
        iter.setText("\u17E0\u17DB\u17E1");
        i = iter.first();
        i = iter.next();
        if (i != 1) {
            errln("Khmer line break failure: failed to stop before \\u17DB(Sc) at 1 and bounded at " + i);
        }
        i = iter.next();
        if (i != 3) {
            errln("Khmer line break failure: failed to skip position after \\u17DB(Sc) at 3 and bounded at " + i);
        }

        /* Ogham <Letter UR(Lo)><Space Mark(Zs)><Letter OR(Lo)> which have
         * been added since Unicode 3.0.0.
         */
        iter.setText("\u1692\u1680\u1696");
        i = iter.first();
        i = iter.next();
        if (i != 2) {
            errln("Ogham line break failure: failed to skip postion before \\u1680(Zs) at 2 and bounded at " + i);
        }


        // Confirm changes in BreakIteratorRules_th.java have been reflected.
        iter = BreakIterator.getLineInstance(new Locale("th", ""));

        /* Thai <Seven(Nd)>
         *      <Left Double Quotation Mark(Pi)>
         *      <Five(Nd)>
         *      <Right Double Quotation Mark(Pf)>
         *      <Three(Nd)>
         */
        iter.setText("\u0E57\u201C\u0E55\u201D\u0E53");
        i = iter.first();
        i = iter.next();
        if (i != 1) {
            errln("Thai line break failure: failed to stop before \\u201C(Pi) at 1 and bounded at " + i);
        }
        i = iter.next();
        if (i != 4) {
            errln("Thai line break failure: failed to stop after \\u201D(Pf) at 4 and bounded at " + i);
        }
    }

    /**
     * Bug 4068137
     */
    public void TestEndBehavior()
    {
        String testString = "boo.";
        BreakIterator wb = BreakIterator.getWordInstance();
        wb.setText(testString);

        if (wb.first() != 0)
            errln("Didn't get break at beginning of string.");
        if (wb.next() != 3)
            errln("Didn't get break before period in \"boo.\"");
        if (wb.current() != 4 && wb.next() != 4)
            errln("Didn't get break at end of string.");
    }

    // [serialization test has been removed pursuant to bug #4152965]

    /**
     * Bug 4450804
     */
    public void TestLineBreakContractions() {
        Vector<String> expected = new Vector<String>();

        expected.add("These ");
        expected.add("are ");
        expected.add("'foobles'. ");
        expected.add("Don't ");
        expected.add("you ");
        expected.add("like ");
        expected.add("them?");
        generalIteratorTest(lineBreak, expected);
    }

}