* config/rs6000/xcoff.h (ASM_OUTPUT_ALIGNED_COMMON): Use floor_log2.
[official-gcc.git] / libjava / testsuite / libjava.lang / StringBuffer_1.java
blob1429122597617baec1be6a32aa4bed0fa12819e4
1 // Test StringBuffer.replace(), reverse(), insert(String), append(String),
2 // and delete().
4 public class StringBuffer_1
6 public static void main(String args[])
8 StringBuffer sb = new StringBuffer("45");
9 sb.insert(0, "123");
10 sb.append("89");
11 sb.insert(5, "6");
12 sb.insert(6, '7');
13 System.out.println (sb);
15 sb.delete (3, 99);
17 String foo = sb.toString();
19 System.out.println (foo);
20 sb.reverse();
21 System.out.println (foo);
23 System.out.println (sb);
24 sb = new StringBuffer("1234");
25 System.out.println(sb.reverse());
27 sb = new StringBuffer("123456789");
28 sb.append ("0");
29 System.out.println(sb);
31 sb.replace (2, 99, "foo");
32 System.out.println (sb);
34 sb = new StringBuffer("123456789");
35 sb.replace (1, 1, "XX");
36 System.out.println (sb);
38 sb = new StringBuffer("123456789");
39 sb.replace (0, 2, "XX");
40 System.out.println (sb);
42 sb = new StringBuffer("123456789");
43 sb.replace (5, 9, "54321");
44 System.out.println (sb);
46 sb = new StringBuffer("123456789");
48 sb.delete (1,4);
49 System.out.println (sb);
51 // Test bounds checks
52 try
54 sb.insert (-2, "x");
56 catch (StringIndexOutOfBoundsException x)
58 System.out.println (x.getClass());
61 try
63 sb.insert (96, "x");
65 catch (StringIndexOutOfBoundsException x)
67 System.out.println (x.getClass());
70 try
72 sb.delete (-2, 2);
74 catch (StringIndexOutOfBoundsException x)
76 System.out.println (x.getClass());
79 try
81 sb.delete (96, 418);
83 catch (StringIndexOutOfBoundsException x)
85 System.out.println (x.getClass());
88 try
90 sb.delete (4, 2);
92 catch (StringIndexOutOfBoundsException x)
94 System.out.println (x.getClass());
97 try
99 sb.replace (-2, 2, "54321");
101 catch (StringIndexOutOfBoundsException x)
103 System.out.println (x.getClass());
108 sb.replace (4, 2, "54321");
110 catch (StringIndexOutOfBoundsException x)
112 System.out.println (x.getClass());
117 sb.replace (12, 18, "54321");
119 catch (StringIndexOutOfBoundsException x)
121 System.out.println (x.getClass());