1 17 package org.apache.tools.ant.util; 18 19 import java.util.Vector ; 20 21 import junit.framework.TestCase; 22 23 26 public class StringUtilsTest extends TestCase { 27 public StringUtilsTest(String s) { 28 super(s); 29 } 30 31 public void testSplit(){ 32 final String data = "a,b,,"; 33 Vector res = StringUtils.split(data, ','); 34 assertEquals(4, res.size()); 35 assertEquals("a", res.elementAt(0)); 36 assertEquals("b", res.elementAt(1)); 37 assertEquals("", res.elementAt(2)); 38 assertEquals("", res.elementAt(3)); 39 } 40 41 public void testSplitLines(){ 42 final String data = "a\r\nb\nc\nd\ne"; 43 Vector res = StringUtils.lineSplit(data); 44 assertEquals(5, res.size()); 45 assertEquals("a\r", res.elementAt(0)); 46 assertEquals("b", res.elementAt(1)); 47 assertEquals("c", res.elementAt(2)); 48 assertEquals("d", res.elementAt(3)); 49 assertEquals("e", res.elementAt(4)); 50 } 51 52 public void testReplace() { 53 final String data = "abcabcabca"; 54 String res = StringUtils.replace(data, "a", ""); 55 assertEquals("bcbcbc", res); 56 } 57 58 } 59 | Popular Tags |