tests/libjava-mauve/src/gnu/testlet/java/lang/String/split.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: JDK1.4
       
     2 
       
     3 // Copyright (C) 2005 Mark J Wielaard (mark@klomp.org)
       
     4 
       
     5 // This file is part of Mauve.
       
     6 
       
     7 // Mauve is free software; you can redistribute it and/or modify
       
     8 // it under the terms of the GNU General Public License as published by
       
     9 // the Free Software Foundation; either version 2, or (at your option)
       
    10 // any later version.
       
    11 
       
    12 // Mauve is distributed in the hope that it will be useful,
       
    13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15 // GNU General Public License for more details.
       
    16 
       
    17 // You should have received a copy of the GNU General Public License
       
    18 // along with Mauve; see the file COPYING.  If not, write to
       
    19 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    20 // Boston, MA 02111-1307, USA.
       
    21 
       
    22 package gnu.testlet.java.lang.String;
       
    23 
       
    24 import gnu.testlet.Testlet;
       
    25 import gnu.testlet.TestHarness;
       
    26 
       
    27 import java.io.*;
       
    28 
       
    29 /**
       
    30  * Tests for split bug based on a test submitted by Amit Jain
       
    31  * (amitrjain@hotmail.com) to GNU Classpath.
       
    32  */
       
    33 public class split implements Testlet
       
    34 {
       
    35   public void test (TestHarness harness)
       
    36   {
       
    37     String fullPath = "test.txt";
       
    38     String text
       
    39       = "A\tB\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tC"
       
    40       + "\n"
       
    41       + "A\t\tB\t\t\t\t\t\t\t\t\tC\t"
       
    42       + "\n";
       
    43 
       
    44     String[] s1, s2;
       
    45     try
       
    46       {
       
    47 	StringReader sr = new StringReader(text);
       
    48 	BufferedReader r = new BufferedReader(sr);
       
    49 	
       
    50 	String row1 = r.readLine();
       
    51 	s1 = row1.split("\t");
       
    52 	String row2 = r.readLine();
       
    53 	s2 = row2.split("\t");
       
    54 	r.close();
       
    55       }
       
    56     catch (IOException ioe)
       
    57       {
       
    58 	harness.debug(ioe);
       
    59 	harness.check(false, ioe.toString());
       
    60 	return;
       
    61       }
       
    62 
       
    63     harness.check(s1.length, 18);
       
    64     harness.check(s1[0], "A");
       
    65     harness.check(s1[1], "B");
       
    66     harness.check(s1[2], "");
       
    67     harness.check(s1[3], "");
       
    68     harness.check(s1[4], "");
       
    69     harness.check(s1[5], "");
       
    70     harness.check(s1[6], "");
       
    71     harness.check(s1[7], "");
       
    72     harness.check(s1[8], "");
       
    73     harness.check(s1[9], "");
       
    74     harness.check(s1[10], "");
       
    75     harness.check(s1[11], "");
       
    76     harness.check(s1[12], "");
       
    77     harness.check(s1[13], "");
       
    78     harness.check(s1[14], "");
       
    79     harness.check(s1[15], "");
       
    80     harness.check(s1[16], "");
       
    81     harness.check(s1[17], "C");
       
    82 
       
    83     // Note that trailing "empties" are discarded.
       
    84     harness.check(s2.length, 12);
       
    85     harness.check(s2[0], "A");
       
    86     harness.check(s2[1], "");
       
    87     harness.check(s2[2], "B");
       
    88     harness.check(s2[3], "");
       
    89     harness.check(s2[4], "");
       
    90     harness.check(s2[5], "");
       
    91     harness.check(s2[6], "");
       
    92     harness.check(s2[7], "");
       
    93     harness.check(s2[8], "");
       
    94     harness.check(s2[9], "");
       
    95     harness.check(s2[10], "");
       
    96     harness.check(s2[11], "C");
       
    97 
       
    98     String[] s3 = "hello, world".split("\uFFFF");
       
    99     harness.check(s3.length, 1);
       
   100     harness.check(s3[0], "hello, world");
       
   101   }
       
   102 }