1 /***
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package test.net.sourceforge.pmd.util;
5
6 import junit.framework.TestCase;
7 import net.sourceforge.pmd.util.StringUtil;
8
9 public class StringUtilTest extends TestCase {
10
11 public void testReplaceWithOneChar() {
12 assertEquals("faa", StringUtil.replaceString("foo", 'o', "a"));
13 }
14
15 public void testReplaceWithMultipleChars() {
16 assertEquals("faaaa", StringUtil.replaceString("foo", 'o', "aa"));
17 }
18
19 public void testReplaceStringWithString() {
20 assertEquals("foo]]>bar", StringUtil.replaceString("foo]]>bar", "]]>", "]]>"));
21 }
22
23 public void testReplaceStringWithString2() {
24 assertEquals("replaceString didn't work with a >", "foobar", StringUtil.replaceString("foobar", "]]>", "]]>"));
25 }
26
27 public void testReplaceWithNull() {
28 assertEquals("replaceString didn't work with a char", "f", StringUtil.replaceString("foo", 'o', null));
29 }
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 }