jdk/test/java/lang/StringBuilder/Exceptions.java
changeset 33663 2cd62a4bd471
parent 5506 202f599c92aa
equal deleted inserted replaced
33662:747a61ad0977 33663:2cd62a4bd471
    92                     new StringBuilder("foo");
    92                     new StringBuilder("foo");
    93                 }});
    93                 }});
    94 
    94 
    95         System.out.println("StringBuilder.replace(int start, int end, String str)");
    95         System.out.println("StringBuilder.replace(int start, int end, String str)");
    96         tryCatch("  -1, 2, \" \"",
    96         tryCatch("  -1, 2, \" \"",
    97                  new StringIndexOutOfBoundsException(-1),
    97                  new StringIndexOutOfBoundsException("start -1, end 2, length 7"),
    98                  new Runnable() {
    98                  new Runnable() {
    99                 public void run() {
    99                 public void run() {
   100                     StringBuilder sb = new StringBuilder("hilbert");
   100                     StringBuilder sb = new StringBuilder("hilbert");
   101                     sb.replace(-1, 2, " ");
   101                     sb.replace(-1, 2, " ");
   102                 }});
   102                 }});
   103         tryCatch("  7, 8, \" \"",
   103         tryCatch("  7, 8, \" \"",
   104                  new StringIndexOutOfBoundsException("start > length()"),
   104                  new StringIndexOutOfBoundsException("start 7, end 6, length 6"),
   105                  new Runnable() {
   105                  new Runnable() {
   106                 public void run() {
   106                 public void run() {
   107                     StringBuilder sb = new StringBuilder("banach");
   107                     StringBuilder sb = new StringBuilder("banach");
   108                     sb.replace(7, 8, " ");
   108                     sb.replace(7, 8, " ");
   109                 }});
   109                 }});
   110         tryCatch("  2, 1, \" \"",
   110         tryCatch("  2, 1, \" \"",
   111                  new StringIndexOutOfBoundsException("start > end"),
   111                  new StringIndexOutOfBoundsException("start 2, end 1, length 7"),
   112                  new Runnable() {
   112                  new Runnable() {
   113                 public void run() {
   113                 public void run() {
   114                     StringBuilder sb = new StringBuilder("riemann");
   114                     StringBuilder sb = new StringBuilder("riemann");
   115                     sb.replace(2, 1, " ");
   115                     sb.replace(2, 1, " ");
   116                 }});
   116                 }});