tests/libjava-mauve/src/gnu/testlet/java/text/CollationElementIterator/offset.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 /*************************************************************************
       
     2 /* offset -- Test get/setOffset features in CollationElementIterator.
       
     3 /*
       
     4 /* Copyright (c) 2004 Guilhem Lavaux <guilhem.lavaux@free.fr>
       
     5 /*
       
     6 /* This program is free software; you can redistribute it and/or modify
       
     7 /* it under the terms of the GNU General Public License as published
       
     8 /* by the Free Software Foundation, either version 2 of the License, or
       
     9 /* (at your option) any later version.
       
    10 /*
       
    11 /* This program is distributed in the hope that it will be useful, but
       
    12 /* WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    14 /* GNU General Public License for more details.
       
    15 /*
       
    16 /* You should have received a copy of the GNU General Public License
       
    17 /* along with this program; if not, write to the Free Software Foundation
       
    18 /* Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
       
    19 /*************************************************************************/
       
    20  
       
    21 // Tags: JDK1.2
       
    22 
       
    23 package gnu.testlet.java.text.CollationElementIterator;
       
    24 
       
    25 import gnu.testlet.Testlet;
       
    26 import gnu.testlet.TestHarness;
       
    27 import java.text.CollationElementIterator;
       
    28 import java.text.RuleBasedCollator;
       
    29 import java.text.ParseException;
       
    30 
       
    31 public class offset implements Testlet
       
    32 {
       
    33   public void test(TestHarness harness)
       
    34   {
       
    35     try 
       
    36       {
       
    37 	RuleBasedCollator collator = new RuleBasedCollator("<a,A<AB,ab<ABC,abc");
       
    38 	CollationElementIterator iter;
       
    39 	
       
    40 	iter = collator.getCollationElementIterator("abaaABC");
       
    41 	iter.setOffset(1);
       
    42 	harness.check(iter.getOffset(), 0);
       
    43 
       
    44 	iter.setOffset(0);
       
    45 	iter.next();
       
    46 	harness.check(iter.getOffset(), 2); 
       
    47 	iter.next();
       
    48 	harness.check(iter.getOffset(), 3); 
       
    49 	iter.next();
       
    50 	harness.check(iter.getOffset(), 4); 
       
    51 	iter.next();
       
    52 	harness.check(iter.getOffset(), 7); 
       
    53       }
       
    54     catch (ParseException e)
       
    55       {
       
    56 	harness.fail("Unexpected parse error exception");
       
    57 	harness.debug(e);
       
    58       }
       
    59 
       
    60   }
       
    61 }