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 package android.icu.dev.test.rbbi; 5 6 import java.text.CharacterIterator; 7 8 import org.junit.Before; 9 import org.junit.Test; 10 11 import android.icu.dev.test.TestFmwk; 12 import android.icu.text.BreakIterator; 13 14 /** 15 * @author sgill 16 * 17 */ 18 public class AbstractBreakIteratorTests extends TestFmwk { 19 20 private class AbstractBreakIterator extends BreakIterator { 21 private int position = 0; 22 private static final int LIMIT = 100; 23 24 private int set(int n) { 25 position = n; 26 if (position > LIMIT) { 27 position = LIMIT; 28 return DONE; 29 } 30 if (position < 0) { 31 position = 0; 32 return DONE; 33 } 34 return position; 35 } 36 37 @Override 38 public int first() { 39 return set(0); 40 } 41 42 @Override 43 public int last() { 44 return set(LIMIT); 45 } 46 47 @Override 48 public int next(int n) { 49 return set(position + n); 50 } 51 52 @Override 53 public int next() { 54 return next(1); 55 } 56 57 @Override 58 public int previous() { 59 return next(-1); 60 } 61 62 @Override 63 public int following(int offset) { 64 return set(offset + 1); 65 } 66 67 @Override 68 public int current() { 69 return position; 70 } 71 72 @Override 73 public CharacterIterator getText() { 74 return null; 75 } 76 77 @Override 78 public void setText(CharacterIterator newText) { 79 } 80 81 } 82 83 private BreakIterator bi; 84 85 @Before 86 public void createBreakIterator() { 87 bi = new AbstractBreakIterator(); 88 } 89 90 @Test 91 public void testPreceding() { 92 int pos = bi.preceding(0); 93 TestFmwk.assertEquals("BreakIterator preceding position not correct", BreakIterator.DONE, pos); 94 95 pos = bi.preceding(5); 96 TestFmwk.assertEquals("BreakIterator preceding position not correct", 4, pos); 97 } 98 99 @Test 100 public void testIsBoundary() { 101 boolean b = bi.isBoundary(0); 102 TestFmwk.assertTrue("BreakIterator is boundary not correct", b); 103 104 b = bi.isBoundary(5); 105 TestFmwk.assertTrue("BreakIterator is boundary not correct", b); 106 } 107 108 } 109