< prev index next >

test/java/lang/Appendable/Basic.java

Print this page
rev 16193 : imported patch 8170348-StringBuilders-method-to-append-multiple-copies

*** 331,340 **** --- 331,354 ---- } catch (IOException x) { fail(x); } } + // appendN with negative count + int[] neg = { -1, -2, -65537, Integer.MIN_VALUE + 1, Integer.MIN_VALUE }; + for (int j = 0; j < neg.length; j++) { + try { + a.appendN('%', neg[j]); + fail("repeat count = " + neg[j], new IllegalArgumentException()); + a = thunk.reset(a); + } catch (IllegalArgumentException x) { + pass(); + } catch (IOException x) { + fail(x); + } + } + // appends of null int start = 1; int end = 2; try { thunk.init(a.append(null, start, end), "null",
*** 342,351 **** --- 356,381 ---- thunk.run(); a = thunk.reset(a); } catch (IOException x) { fail(x); } + + // appendN + for (int i = 128; i > 0; ) { + try { + i /= 2; + String s = ""; + for (int j = 0; j < i; j++) { + s += "@"; + } + thunk.init(a.appendN('@', i), "'@' x 0", s); + thunk.run(); + a = thunk.reset(a); + } catch (IOException x) { + fail(x); + } + } } public static void main(String [] args) throws Exception { // CharSequences CharBuffer cb = CharBuffer.allocate(128).put(s);
< prev index next >