--- old/test/java/lang/String/IsEmpty.java 2013-02-16 22:32:09.036026328 -0800 +++ /dev/null 2013-02-12 14:41:59.585764023 -0800 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 - * @summary Basic isEmpty functionality - * @bug 6189137 - */ - -public class IsEmpty { - private static String [] tests = { "", " ", "a", - "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. -- Charles Dickens, Tale of Two Cities" - }; - - public static void main(String [] args) { - for (int i = 0; i < tests.length; i++) { - String s = tests[i]; - int len = s.length(); - boolean empty = s.isEmpty(); - - if ((len != 0 && empty) || (len == 0 && !empty)) - throw new RuntimeException("String \"" + s + "\": " - + " isEmpty = " + empty - + ", length = " + len); - } - } -} --- /dev/null 2013-02-12 14:41:59.585764023 -0800 +++ new/test/java/lang/String/SubSequence.java 2013-02-16 22:32:08.788026317 -0800 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 @summary Basic subSequence functionality. + * @bug 7197183 + */ +public class SubSequence { + + private final static String[] TESTS = {"", "0", "0123456789"}; + + public static void test(String testString) { + // empty subsequences + CharSequence subSequence = testString.subSequence(0, 0); + if (subSequence.length() != 0) { + throw new RuntimeException("not empty"); + } + if (0 != subSequence.hashCode()) { + throw new RuntimeException("bad hashCode"); + } + + // single char sub-sequences + for (int each = 0; each < testString.length(); each++) { + subSequence = testString.subSequence(each, each + 1); + String subString = testString.substring(each, each + 1); + + if (subSequence.length() != subString.length()) { + throw new RuntimeException("wrong length"); + } + + if (subSequence.charAt(0) != testString.charAt(each)) { + throw new RuntimeException("wrong char" + subSequence.charAt(0) + "!=" + testString.charAt(each)); + } + + if (subString.hashCode() != subSequence.hashCode()) { + throw new RuntimeException("bad hashCode " + subString.hashCode() + " != " + subSequence.hashCode()); + } + if (!subSequence.equals(subString)) { + throw new RuntimeException("not equal"); + } + if (!subString.equals(subSequence)) { + throw new RuntimeException("not equal"); + } + if (!subString.equals(subSequence.toString())) { + throw new RuntimeException("not equal"); + } + } + + subSequence = testString.subSequence(testString.length(), testString.length()); + if (subSequence.length() != 0) { + throw new RuntimeException("not empty"); + } + if (0 != subSequence.hashCode()) { + throw new RuntimeException("bad hashCode"); + } + + // full length sub-sequence + subSequence = testString.subSequence(0, testString.length()); + if (testString.length() != subSequence.length()) { + throw new RuntimeException("wrong length"); + } + if (testString.hashCode() != subSequence.hashCode()) { + throw new RuntimeException("bad hashCode"); + } + if (!subSequence.equals(testString)) { + throw new RuntimeException("not equal"); + } + if (!testString.equals(subSequence)) { + throw new RuntimeException("not equal"); + } + if (!testString.equals(subSequence.toString())) { + throw new RuntimeException("not equal"); + } + } + + public static void main(String[] args) { + for (String each : TESTS) { + try { + System.out.println("Test : \"" + each + "\""); + test(each); + } catch (Throwable all) { + throw new AssertionError("Failed testing : \"" + each + "\"", all); + } + } + } +}