/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4812591 4705328 5019111
* @summary Test append and insert methods with CharSequence params
*/
public class AppendCharSequence {
bash();
checkNulls();
checkOffsets();
}
// Sanity test of contents
for (int i=0; i<1000; i++) {
// append(CharSequence cs)
throw new RuntimeException("StringBuffer.append failure 1");
// append (CharSequence cs, int start, int end)
}
throw new RuntimeException("StringBuffer.append failure 2");
// insert(int dstOffset, CharSequence cs)
}
throw new RuntimeException("StringBuffer.insert failure 1");
// insert(int dstOffset, CharSequence s, int start, int end)
}
}
throw new RuntimeException("StringBuffer.insert failure 2");
}
}
return constraint1 + x;
}
for(int y=0; y<aNewLength; y++) {
}
return aNewStringBuffer;
}
// Check handling of null as "null"
throw new RuntimeException("StringBuffer.append failure 3");
sb1 = new StringBuffer();
throw new RuntimeException("StringBuffer.append failure 4");
throw new RuntimeException("StringBuffer.insert failure 3");
throw new RuntimeException("StringBuffer.insert failure 4");
}
// Test the bounds checking
// append (CharSeqeunce cs, int start, int end)
for (int i=0; i<100; i++) {
int index = 0;
int len = 0;
if (index < 0)
break;
if (len < 0)
break;
}
try {
throw new RuntimeException("Append bounds checking failure");
} catch (IndexOutOfBoundsException e) {
// Correct result
}
}
// insert(int dstOffset, CharSequence cs)
for (int i=0; i<100; i++) {
int index = 0;
if (index < 0)
break;
}
try {
throw new RuntimeException("Insert bounds checking failure");
} catch (IndexOutOfBoundsException e) {
// Correct result
}
}
// insert(int dstOffset, CharSequence s, int start, int end)
for (int i=0; i<100; i++) {
int index1 = 0;
if (index1 < 0)
break;
}
int index2 = 0;
int len = 0;
if (index2 < 0)
break;
if (len < 0)
break;
}
try {
throw new RuntimeException("Insert bounds checking failure");
} catch (IndexOutOfBoundsException e) {
// Correct result
}
}
}
// Test the CharSequence constructor
for (int i=0; i<100; i++) {
throw new RuntimeException("CharSequence constructor failure");
}
}
}
}