Home | History | Annotate | Download | only in rbbi
      1 /* GENERATED SOURCE. DO NOT MODIFY. */
      2 //  2016 and later: Unicode, Inc. and others.
      3 // License & terms of use: http://www.unicode.org/copyright.html#License
      4 /*
      5  *******************************************************************************
      6  * Copyright (C) 1996-2016, International Business Machines Corporation and    *
      7  * others. All Rights Reserved.                                                *
      8  *******************************************************************************
      9  */
     10 package android.icu.dev.test.rbbi;
     11 
     12 import java.text.StringCharacterIterator;
     13 import java.util.ArrayList;
     14 import java.util.List;
     15 import java.util.Locale;
     16 
     17 import org.junit.Before;
     18 import org.junit.Test;
     19 import org.junit.runner.RunWith;
     20 import org.junit.runners.JUnit4;
     21 
     22 import android.icu.dev.test.TestFmwk;
     23 import android.icu.text.BreakIterator;
     24 import android.icu.text.FilteredBreakIteratorBuilder;
     25 import android.icu.util.ULocale;
     26 import android.icu.testsharding.MainTestShard;
     27 
     28 @MainTestShard
     29 @SuppressWarnings("unused")
     30 @RunWith(JUnit4.class)
     31 public class BreakIteratorTest extends TestFmwk
     32 {
     33     private BreakIterator characterBreak;
     34     private BreakIterator wordBreak;
     35     private BreakIterator lineBreak;
     36     private BreakIterator sentenceBreak;
     37     private BreakIterator titleBreak;
     38 
     39     public BreakIteratorTest()
     40     {
     41 
     42     }
     43 
     44     @Before
     45     public void init(){
     46         characterBreak = BreakIterator.getCharacterInstance();
     47         wordBreak = BreakIterator.getWordInstance();
     48         lineBreak = BreakIterator.getLineInstance();
     49         //logln("Creating sentence iterator...");
     50         sentenceBreak = BreakIterator.getSentenceInstance();
     51         //logln("Finished creating sentence iterator...");
     52         titleBreak = BreakIterator.getTitleInstance();
     53     }
     54     //=========================================================================
     55     // general test subroutines
     56     //=========================================================================
     57 
     58     private List<String> _testFirstAndNext(BreakIterator bi, String text) {
     59         int p = bi.first();
     60         int lastP = p;
     61         List<String> result = new ArrayList<String>();
     62 
     63         if (p != 0)
     64             errln("first() returned " + p + " instead of 0");
     65         while (p != BreakIterator.DONE) {
     66             p = bi.next();
     67             if (p != BreakIterator.DONE) {
     68                 if (p <= lastP)
     69                     errln("next() failed to move forward: next() on position "
     70                                     + lastP + " yielded " + p);
     71 
     72                 result.add(text.substring(lastP, p));
     73             }
     74             else {
     75                 if (lastP != text.length())
     76                     errln("next() returned DONE prematurely: offset was "
     77                                     + lastP + " instead of " + text.length());
     78             }
     79             lastP = p;
     80         }
     81         return result;
     82     }
     83 
     84     private List<String> _testLastAndPrevious(BreakIterator bi, String text) {
     85         int p = bi.last();
     86         int lastP = p;
     87         List<String> result = new ArrayList<String>();
     88 
     89         if (p != text.length())
     90             errln("last() returned " + p + " instead of " + text.length());
     91         while (p != BreakIterator.DONE) {
     92             p = bi.previous();
     93             if (p != BreakIterator.DONE) {
     94                 if (p >= lastP)
     95                     errln("previous() failed to move backward: previous() on position "
     96                                     + lastP + " yielded " + p);
     97 
     98                 result.add(0, text.substring(p, lastP));
     99             }
    100             else {
    101                 if (lastP != 0)
    102                     errln("previous() returned DONE prematurely: offset was "
    103                                     + lastP + " instead of 0");
    104             }
    105             lastP = p;
    106         }
    107         return result;
    108     }
    109 
    110     private void compareFragmentLists(String f1Name, String f2Name, List<String> f1, List<String> f2) {
    111         int p1 = 0;
    112         int p2 = 0;
    113         String s1;
    114         String s2;
    115         int t1 = 0;
    116         int t2 = 0;
    117 
    118         while (p1 < f1.size() && p2 < f2.size()) {
    119             s1 = f1.get(p1);
    120             s2 = f2.get(p2);
    121             t1 += s1.length();
    122             t2 += s2.length();
    123 
    124             if (s1.equals(s2)) {
    125                 debugLogln("   >" + s1 + "<");
    126                 ++p1;
    127                 ++p2;
    128             }
    129             else {
    130                 int tempT1 = t1;
    131                 int tempT2 = t2;
    132                 int tempP1 = p1;
    133                 int tempP2 = p2;
    134 
    135                 while (tempT1 != tempT2 && tempP1 < f1.size() && tempP2 < f2.size()) {
    136                     while (tempT1 < tempT2 && tempP1 < f1.size()) {
    137                         tempT1 += (f1.get(tempP1)).length();
    138                         ++tempP1;
    139                     }
    140                     while (tempT2 < tempT1 && tempP2 < f2.size()) {
    141                         tempT2 += (f2.get(tempP2)).length();
    142                         ++tempP2;
    143                     }
    144                 }
    145                 logln("*** " + f1Name + " has:");
    146                 while (p1 <= tempP1 && p1 < f1.size()) {
    147                     s1 = f1.get(p1);
    148                     t1 += s1.length();
    149                     debugLogln(" *** >" + s1 + "<");
    150                     ++p1;
    151                 }
    152                 logln("***** " + f2Name + " has:");
    153                 while (p2 <= tempP2 && p2 < f2.size()) {
    154                     s2 = f2.get(p2);
    155                     t2 += s2.length();
    156                     debugLogln(" ***** >" + s2 + "<");
    157                     ++p2;
    158                 }
    159                 errln("Discrepancy between " + f1Name + " and " + f2Name);
    160             }
    161         }
    162     }
    163 
    164     private void _testFollowing(BreakIterator bi, String text, int[] boundaries) {
    165         logln("testFollowing():");
    166         int p = 2;
    167         for (int i = 0; i <= text.length(); i++) {
    168             if (i == boundaries[p])
    169                 ++p;
    170 
    171             int b = bi.following(i);
    172             logln("bi.following(" + i + ") -> " + b);
    173             if (b != boundaries[p])
    174                 errln("Wrong result from following() for " + i + ": expected " + boundaries[p]
    175                                 + ", got " + b);
    176         }
    177     }
    178 
    179     private void _testPreceding(BreakIterator bi, String text, int[] boundaries) {
    180         logln("testPreceding():");
    181         int p = 0;
    182         for (int i = 0; i <= text.length(); i++) {
    183             int b = bi.preceding(i);
    184             logln("bi.preceding(" + i + ") -> " + b);
    185             if (b != boundaries[p])
    186                 errln("Wrong result from preceding() for " + i + ": expected " + boundaries[p]
    187                                 + ", got " + b);
    188 
    189             if (i == boundaries[p + 1])
    190                 ++p;
    191         }
    192     }
    193 
    194     private void _testIsBoundary(BreakIterator bi, String text, int[] boundaries) {
    195         logln("testIsBoundary():");
    196         int p = 1;
    197         boolean isB;
    198         for (int i = 0; i <= text.length(); i++) {
    199             isB = bi.isBoundary(i);
    200             logln("bi.isBoundary(" + i + ") -> " + isB);
    201 
    202             if (i == boundaries[p]) {
    203                 if (!isB)
    204                     errln("Wrong result from isBoundary() for " + i + ": expected true, got false");
    205                 ++p;
    206             }
    207             else {
    208                 if (isB)
    209                     errln("Wrong result from isBoundary() for " + i + ": expected false, got true");
    210             }
    211         }
    212     }
    213 
    214     private void doOtherInvariantTest(BreakIterator tb, String testChars)
    215     {
    216         StringBuffer work = new StringBuffer("a\r\na");
    217         int errorCount = 0;
    218 
    219         // a break should never occur between CR and LF
    220         for (int i = 0; i < testChars.length(); i++) {
    221             work.setCharAt(0, testChars.charAt(i));
    222             for (int j = 0; j < testChars.length(); j++) {
    223                 work.setCharAt(3, testChars.charAt(j));
    224                 tb.setText(work.toString());
    225                 for (int k = tb.first(); k != BreakIterator.DONE; k = tb.next())
    226                     if (k == 2) {
    227                         errln("Break between CR and LF in string U+" + Integer.toHexString(
    228                                 (work.charAt(0))) + ", U+d U+a U+" + Integer.toHexString(
    229                                 (work.charAt(3))));
    230                         errorCount++;
    231                         if (errorCount >= 75)
    232                             return;
    233                     }
    234             }
    235         }
    236 
    237         // a break should never occur before a non-spacing mark, unless it's preceded
    238         // by a line terminator
    239         work.setLength(0);
    240         work.append("aaaa");
    241         for (int i = 0; i < testChars.length(); i++) {
    242             char c = testChars.charAt(i);
    243             if (c == '\n' || c == '\r' || c == '\u2029' || c == '\u2028' || c == '\u0003')
    244                 continue;
    245             work.setCharAt(1, c);
    246             for (int j = 0; j < testChars.length(); j++) {
    247                 c = testChars.charAt(j);
    248                 if (Character.getType(c) != Character.NON_SPACING_MARK && Character.getType(c)
    249                         != Character.ENCLOSING_MARK)
    250                     continue;
    251                 work.setCharAt(2, c);
    252                 tb.setText(work.toString());
    253                 for (int k = tb.first(); k != BreakIterator.DONE; k = tb.next())
    254                     if (k == 2) {
    255                         errln("Break between U+" + Integer.toHexString((work.charAt(1)))
    256                                 + " and U+" + Integer.toHexString((work.charAt(2))));
    257                         errorCount++;
    258                         if (errorCount >= 75)
    259                             return;
    260                     }
    261             }
    262         }
    263     }
    264 
    265     public void debugLogln(String s) {
    266         final String zeros = "0000";
    267         String temp;
    268         StringBuffer out = new StringBuffer();
    269         for (int i = 0; i < s.length(); i++) {
    270             char c = s.charAt(i);
    271             if (c >= ' ' && c < '\u007f')
    272                 out.append(c);
    273             else {
    274                 out.append("\\u");
    275                 temp = Integer.toHexString(c);
    276                 out.append(zeros.substring(0, 4 - temp.length()));
    277                 out.append(temp);
    278             }
    279         }
    280         logln(out.toString());
    281     }
    282 
    283     //=========================================================================
    284     // tests
    285     //=========================================================================
    286 
    287 
    288     /*
    289      * @bug 4153072
    290      */
    291     @Test
    292     public void TestBug4153072() {
    293         BreakIterator iter = BreakIterator.getWordInstance();
    294         String str = "...Hello, World!...";
    295         int begin = 3;
    296         int end = str.length() - 3;
    297         // not used boolean gotException = false;
    298 
    299 
    300         iter.setText(new StringCharacterIterator(str, begin, end, begin));
    301         for (int index = -1; index < begin + 1; ++index) {
    302             try {
    303                 iter.isBoundary(index);
    304                 if (index < begin)
    305                     errln("Didn't get exception with offset = " + index +
    306                                     " and begin index = " + begin);
    307             }
    308             catch (IllegalArgumentException e) {
    309                 if (index >= begin)
    310                     errln("Got exception with offset = " + index +
    311                                     " and begin index = " + begin);
    312             }
    313         }
    314     }
    315 
    316 
    317     private static final String cannedTestChars
    318         = "\u0000\u0001\u0002\u0003\u0004 !\"#$%&()+-01234<=>ABCDE[]^_`abcde{}|\u00a0\u00a2"
    319         + "\u00a3\u00a4\u00a5\u00a6\u00a7\u00a8\u00a9\u00ab\u00ad\u00ae\u00af\u00b0\u00b2\u00b3"
    320         + "\u00b4\u00b9\u00bb\u00bc\u00bd\u02b0\u02b1\u02b2\u02b3\u02b4\u0300\u0301\u0302\u0303"
    321         + "\u0304\u05d0\u05d1\u05d2\u05d3\u05d4\u0903\u093e\u093f\u0940\u0949\u0f3a\u0f3b\u2000"
    322         + "\u2001\u2002\u200c\u200d\u200e\u200f\u2010\u2011\u2012\u2028\u2029\u202a\u203e\u203f"
    323         + "\u2040\u20dd\u20de\u20df\u20e0\u2160\u2161\u2162\u2163\u2164";
    324 
    325     @Test
    326     public void TestSentenceInvariants()
    327     {
    328         BreakIterator e = BreakIterator.getSentenceInstance();
    329         doOtherInvariantTest(e, cannedTestChars + ".,\u3001\u3002\u3041\u3042\u3043\ufeff");
    330     }
    331 
    332     @Test
    333     public void TestGetAvailableLocales()
    334     {
    335         Locale[] locList = BreakIterator.getAvailableLocales();
    336 
    337         if (locList.length == 0)
    338             errln("getAvailableLocales() returned an empty list!");
    339         // I have no idea how to test this function...
    340 
    341         android.icu.util.ULocale[] ulocList = BreakIterator.getAvailableULocales();
    342         if (ulocList.length == 0) {
    343             errln("getAvailableULocales() returned an empty list!");
    344         } else {
    345             logln("getAvailableULocales() returned " + ulocList.length + " locales");
    346         }
    347     }
    348 
    349 
    350     /**
    351      * @bug 4068137
    352      */
    353     @Test
    354     public void TestEndBehavior()
    355     {
    356         String testString = "boo.";
    357         BreakIterator wb = BreakIterator.getWordInstance();
    358         wb.setText(testString);
    359 
    360         if (wb.first() != 0)
    361             errln("Didn't get break at beginning of string.");
    362         if (wb.next() != 3)
    363             errln("Didn't get break before period in \"boo.\"");
    364         if (wb.current() != 4 && wb.next() != 4)
    365             errln("Didn't get break at end of string.");
    366     }
    367 
    368     // The Following two tests are ported from ICU4C 1.8.1 [Richard/GCL]
    369     /**
    370      * Port From:   ICU4C v1.8.1 : textbounds : IntlTestTextBoundary
    371      * Source File: $ICU4CRoot/source/test/intltest/ittxtbd.cpp
    372      **/
    373     /**
    374      * test methods preceding, following and isBoundary
    375      **/
    376     @Test
    377     public void TestPreceding() {
    378         String words3 = "aaa bbb ccc";
    379         BreakIterator e = BreakIterator.getWordInstance(Locale.getDefault());
    380         e.setText( words3 );
    381         e.first();
    382         int p1 = e.next();
    383         int p2 = e.next();
    384         int p3 = e.next();
    385         int p4 = e.next();
    386 
    387         int f = e.following(p2+1);
    388         int p = e.preceding(p2+1);
    389         if (f!=p3)
    390             errln("IntlTestTextBoundary::TestPreceding: f!=p3");
    391         if (p!=p2)
    392             errln("IntlTestTextBoundary::TestPreceding: p!=p2");
    393 
    394         if (p1+1!=p2)
    395             errln("IntlTestTextBoundary::TestPreceding: p1+1!=p2");
    396 
    397         if (p3+1!=p4)
    398             errln("IntlTestTextBoundary::TestPreceding: p3+1!=p4");
    399 
    400         if (!e.isBoundary(p2) || e.isBoundary(p2+1) || !e.isBoundary(p3))
    401         {
    402             errln("IntlTestTextBoundary::TestPreceding: isBoundary err");
    403         }
    404     }
    405 
    406     /**
    407      * Ticket#5615
    408      */
    409     @Test
    410     public void TestT5615() {
    411         android.icu.util.ULocale[] ulocales = BreakIterator.getAvailableULocales();
    412         int type = 0;
    413         android.icu.util.ULocale loc = null;
    414         try {
    415             for (int i = 0; i < ulocales.length; i++) {
    416                 loc = ulocales[i];
    417                 for (type = 0; type < 5 /* 5 = BreakIterator.KIND_COUNT */; ++type) {
    418                     BreakIterator brk = BreakIterator.getBreakInstance(loc, type);
    419                     if (brk == null) {
    420                         errln("ERR: Failed to create an instance type: " + type + " / locale: " + loc);
    421                     }
    422                 }
    423             }
    424         } catch (Exception e) {
    425             errln("ERR: Failed to create an instance type: " + type + " / locale: " + loc + " / exception: " + e.getMessage());
    426         }
    427     }
    428 
    429     /**
    430      * At present, Japanese doesn't have exceptions.
    431      * However, this still should not fail.
    432      */
    433     @Test
    434     public void TestFilteredJapanese() {
    435         ULocale loc = ULocale.JAPANESE;
    436         BreakIterator brk = FilteredBreakIteratorBuilder
    437                 .getInstance(loc)
    438                 .wrapIteratorWithFilter(BreakIterator.getSentenceInstance(loc));
    439         brk.setText("");
    440         assertEquals("Starting point", 0, brk.current());
    441         assertEquals("Next point", 5, brk.next());
    442         assertEquals("Last point", BreakIterator.DONE, brk.next());
    443     }
    444 
    445     /*
    446      * Test case for Ticket#10721. BreakIterator factory method should throw NPE
    447      * when specified locale is null.
    448      */
    449     @Test
    450     public void TestNullLocale() {
    451         Locale loc = null;
    452         ULocale uloc = null;
    453 
    454         @SuppressWarnings("unused")
    455         BreakIterator brk;
    456 
    457         // Character
    458         try {
    459             brk = BreakIterator.getCharacterInstance(loc);
    460             errln("getCharacterInstance((Locale)null) did not throw NPE.");
    461         } catch (NullPointerException e) { /* OK */ }
    462         try {
    463             brk = BreakIterator.getCharacterInstance(uloc);
    464             errln("getCharacterInstance((ULocale)null) did not throw NPE.");
    465         } catch (NullPointerException e) { /* OK */ }
    466 
    467         // Line
    468         try {
    469             brk = BreakIterator.getLineInstance(loc);
    470             errln("getLineInstance((Locale)null) did not throw NPE.");
    471         } catch (NullPointerException e) { /* OK */ }
    472         try {
    473             brk = BreakIterator.getLineInstance(uloc);
    474             errln("getLineInstance((ULocale)null) did not throw NPE.");
    475         } catch (NullPointerException e) { /* OK */ }
    476 
    477         // Sentence
    478         try {
    479             brk = BreakIterator.getSentenceInstance(loc);
    480             errln("getSentenceInstance((Locale)null) did not throw NPE.");
    481         } catch (NullPointerException e) { /* OK */ }
    482         try {
    483             brk = BreakIterator.getSentenceInstance(uloc);
    484             errln("getSentenceInstance((ULocale)null) did not throw NPE.");
    485         } catch (NullPointerException e) { /* OK */ }
    486 
    487         // Title
    488         try {
    489             brk = BreakIterator.getTitleInstance(loc);
    490             errln("getTitleInstance((Locale)null) did not throw NPE.");
    491         } catch (NullPointerException e) { /* OK */ }
    492         try {
    493             brk = BreakIterator.getTitleInstance(uloc);
    494             errln("getTitleInstance((ULocale)null) did not throw NPE.");
    495         } catch (NullPointerException e) { /* OK */ }
    496 
    497         // Word
    498         try {
    499             brk = BreakIterator.getWordInstance(loc);
    500             errln("getWordInstance((Locale)null) did not throw NPE.");
    501         } catch (NullPointerException e) { /* OK */ }
    502         try {
    503             brk = BreakIterator.getWordInstance(uloc);
    504             errln("getWordInstance((ULocale)null) did not throw NPE.");
    505         } catch (NullPointerException e) { /* OK */ }
    506     }
    507 
    508     /**
    509      * Test FilteredBreakIteratorBuilder newly introduced
    510      */
    511     @Test
    512     public void TestFilteredBreakIteratorBuilder() {
    513         FilteredBreakIteratorBuilder builder;
    514         BreakIterator baseBI;
    515         BreakIterator filteredBI;
    516 
    517         String text = "In the meantime Mr. Weston arrived with his small ship, which he had now recovered. Capt. Gorges, who informed the Sgt. here that one purpose of his going east was to meet with Mr. Weston, took this opportunity to call him to account for some abuses he had to lay to his charge."; // (William Bradford, public domain. http://catalog.hathitrust.org/Record/008651224 ) - edited.
    518         String ABBR_MR = "Mr.";
    519         String ABBR_CAPT = "Capt.";
    520 
    521         {
    522             logln("Constructing empty builder\n");
    523             builder = FilteredBreakIteratorBuilder.getEmptyInstance();
    524 
    525             logln("Constructing base BI\n");
    526             baseBI = BreakIterator.getSentenceInstance(Locale.ENGLISH);
    527 
    528             logln("Building new BI\n");
    529             filteredBI = builder.wrapIteratorWithFilter(baseBI);
    530 
    531             assertDefaultBreakBehavior(filteredBI, text);
    532         }
    533 
    534         {
    535             logln("Constructing empty builder\n");
    536             builder = FilteredBreakIteratorBuilder.getEmptyInstance();
    537 
    538             logln("Adding Mr. as an exception\n");
    539 
    540             assertEquals("2.1 suppressBreakAfter", true, builder.suppressBreakAfter(ABBR_MR));
    541             assertEquals("2.2 suppressBreakAfter", false, builder.suppressBreakAfter(ABBR_MR));
    542             assertEquals("2.3 unsuppressBreakAfter", true, builder.unsuppressBreakAfter(ABBR_MR));
    543             assertEquals("2.4 unsuppressBreakAfter", false, builder.unsuppressBreakAfter(ABBR_MR));
    544             assertEquals("2.5 suppressBreakAfter", true, builder.suppressBreakAfter(ABBR_MR));
    545 
    546             logln("Constructing base BI\n");
    547             baseBI = BreakIterator.getSentenceInstance(Locale.ENGLISH);
    548 
    549             logln("Building new BI\n");
    550             filteredBI = builder.wrapIteratorWithFilter(baseBI);
    551 
    552             logln("Testing:");
    553             filteredBI.setText(text);
    554             assertEquals("2nd next", 84, filteredBI.next());
    555             assertEquals("2nd next", 90, filteredBI.next());
    556             assertEquals("2nd next", 278, filteredBI.next());
    557             filteredBI.first();
    558         }
    559 
    560 
    561         {
    562           logln("Constructing empty builder\n");
    563           builder = FilteredBreakIteratorBuilder.getEmptyInstance();
    564 
    565           logln("Adding Mr. and Capt as an exception\n");
    566           assertEquals("3.1 suppressBreakAfter", true, builder.suppressBreakAfter(ABBR_MR));
    567           assertEquals("3.2 suppressBreakAfter", true, builder.suppressBreakAfter(ABBR_CAPT));
    568 
    569           logln("Constructing base BI\n");
    570           baseBI = BreakIterator.getSentenceInstance(Locale.ENGLISH);
    571 
    572           logln("Building new BI\n");
    573           filteredBI = builder.wrapIteratorWithFilter(baseBI);
    574 
    575           logln("Testing:");
    576           filteredBI.setText(text);
    577           assertEquals("3rd next", 84, filteredBI.next());
    578           assertEquals("3rd next", 278, filteredBI.next());
    579           filteredBI.first();
    580         }
    581 
    582         {
    583           logln("Constructing English builder\n");
    584           builder = FilteredBreakIteratorBuilder.getInstance(ULocale.ENGLISH);
    585 
    586           logln("Constructing base BI\n");
    587           baseBI = BreakIterator.getSentenceInstance(Locale.ENGLISH);
    588 
    589           logln("unsuppressing 'Capt'");
    590           assertEquals("1st suppressBreakAfter", true, builder.unsuppressBreakAfter(ABBR_CAPT));
    591 
    592           logln("Building new BI\n");
    593           filteredBI = builder.wrapIteratorWithFilter(baseBI);
    594 
    595           if(filteredBI != null) {
    596             logln("Testing:");
    597             filteredBI.setText(text);
    598             assertEquals("4th next", 84, filteredBI.next());
    599             assertEquals("4th next", 90, filteredBI.next());
    600             assertEquals("4th next", 278, filteredBI.next());
    601             filteredBI.first();
    602           }
    603         }
    604 
    605         {
    606           logln("Constructing English builder\n");
    607           builder = FilteredBreakIteratorBuilder.getInstance(ULocale.ENGLISH);
    608 
    609           logln("Constructing base BI\n");
    610           baseBI = BreakIterator.getSentenceInstance(Locale.ENGLISH);
    611 
    612           logln("Building new BI\n");
    613           filteredBI = builder.wrapIteratorWithFilter(baseBI);
    614 
    615           if(filteredBI != null) {
    616             assertEnglishBreakBehavior(filteredBI, text);
    617           }
    618         }
    619 
    620         {
    621             logln("Constructing English @ss=standard\n");
    622             filteredBI = BreakIterator.getSentenceInstance(ULocale.forLanguageTag("en-US-u-ss-standard"));
    623 
    624             if(filteredBI != null) {
    625               assertEnglishBreakBehavior(filteredBI, text);
    626             }
    627         }
    628 
    629         {
    630             logln("Constructing Afrikaans @ss=standard - should be == default\n");
    631             filteredBI = BreakIterator.getSentenceInstance(ULocale.forLanguageTag("af-u-ss-standard"));
    632 
    633             assertDefaultBreakBehavior(filteredBI, text);
    634         }
    635 
    636         {
    637             logln("Constructing Japanese @ss=standard - should be == default\n");
    638             filteredBI = BreakIterator.getSentenceInstance(ULocale.forLanguageTag("ja-u-ss-standard"));
    639 
    640             assertDefaultBreakBehavior(filteredBI, text);
    641         }
    642         {
    643             logln("Constructing tfg @ss=standard - should be == default\n");
    644             filteredBI = BreakIterator.getSentenceInstance(ULocale.forLanguageTag("tfg-u-ss-standard"));
    645 
    646             assertDefaultBreakBehavior(filteredBI, text);
    647         }
    648 
    649         {
    650           logln("Constructing French builder");
    651           builder = FilteredBreakIteratorBuilder.getInstance(ULocale.FRENCH);
    652 
    653           logln("Constructing base BI\n");
    654           baseBI = BreakIterator.getSentenceInstance(Locale.FRENCH);
    655 
    656           logln("Building new BI\n");
    657           filteredBI = builder.wrapIteratorWithFilter(baseBI);
    658 
    659           if(filteredBI != null) {
    660             assertFrenchBreakBehavior(filteredBI, text);
    661           }
    662         }
    663     }
    664 
    665     /**
    666      * @param filteredBI
    667      * @param text
    668      */
    669     private void assertFrenchBreakBehavior(BreakIterator filteredBI, String text) {
    670         logln("Testing French behavior:");
    671         filteredBI.setText(text);
    672         assertEquals("6th next", 20, filteredBI.next());
    673         assertEquals("6th next", 84, filteredBI.next());
    674         filteredBI.first();
    675     }
    676 
    677     /**
    678      * @param filteredBI
    679      * @param text
    680      */
    681     private void assertEnglishBreakBehavior(BreakIterator filteredBI, String text) {
    682         logln("Testing English filtered behavior:");
    683           filteredBI.setText(text);
    684 
    685           assertEquals("5th next", 84, filteredBI.next());
    686           assertEquals("5th next", 278, filteredBI.next());
    687           filteredBI.first();
    688     }
    689 
    690     /**
    691      * @param filteredBI
    692      * @param text
    693      */
    694     private void assertDefaultBreakBehavior(BreakIterator filteredBI, String text) {
    695         logln("Testing Default Behavior:");
    696         filteredBI.setText(text);
    697         assertEquals("1st next", 20, filteredBI.next());
    698         assertEquals("1st next", 84, filteredBI.next());
    699         assertEquals("1st next", 90, filteredBI.next());
    700         assertEquals("1st next", 181, filteredBI.next());
    701         assertEquals("1st next", 278, filteredBI.next());
    702         filteredBI.first();
    703     }
    704 }
    705