6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /* @test
25 * @summary Check that error cases are replaced correctly in String/ISR/OSW
26 * @bug 4457851
27 *
28 * @build Errors Util
29 * @run main Errors
30 */
31
32 import java.io.*;
33 import java.nio.*;
34
35
36 public class Errors {
37
38 static PrintStream log = System.err;
39 static int failures = 0;
40
41 static final byte Q = (byte)'?';
42 static final byte X = (byte)'x';
43 static final byte Y = (byte)'y';
44 static final byte Z = (byte)'z';
45
46 static abstract class Test {
176 t.test("\uD800\uDC00x", new byte[] { Q, X });
177 t.test("\uF000", new byte[] { Q });
178 t.test("\uFFFE", new byte[] { Q });
179 t.test("\uFFFF", new byte[] { Q });
180 t.test(new byte[] { X, (byte)0x7f, Y }, "x\u007Fy");
181 t.test(new byte[] { X, (byte)0x80, Y }, "x\u0080y");
182 t.test(new byte[] { (byte)0xf0, (byte)0xf0 }, "\u00F0\u00F0");
183 }
184
185 static void test_UTF_8(Test t) {
186 t.run();
187 t.test("\u0080", new byte[] { (byte)0xC2, (byte)0x80 });
188 t.test("\u0100", new byte[] { (byte)0xC4, (byte)0x80 });
189 t.test("\uD800\uDC00",
190 new byte[] { (byte)0xF0, (byte)0x90, (byte)0x80, (byte)0x80 });
191 t.test("\uF000", new byte[] { (byte)0xEF, (byte)0x80, (byte)0x80 });
192 t.test("\uFFFE", new byte[] { (byte)0xEF, (byte)0xBF, (byte)0xBE });
193 t.test("\uFFFF", new byte[] { (byte)0xEF, (byte)0xBF, (byte)0xBF });
194 t.test(new byte[] { X, (byte)0x7f, Y }, "x\u007Fy");
195 t.test(new byte[] { X, (byte)0x80, Y }, "x\uFFFDy");
196 t.test(new byte[] { (byte)0xf0, (byte)0xf0 }, "\uFFFD");
197 }
198
199 public static void main(String[] args) throws Exception {
200
201 test_US_ASCII(new TestString("US-ASCII"));
202 test_US_ASCII(new TestStream("US-ASCII"));
203
204 test_ISO_8859_1(new TestString("ISO-8859-1"));
205 test_ISO_8859_1(new TestStream("ISO-8859-1"));
206
207 test_ISO_8859_1(new TestString("ISO-8859-15"));
208 test_ISO_8859_1(new TestStream("ISO-8859-15"));
209
210 test_UTF_8(new TestString("UTF-8"));
211 test_UTF_8(new TestStream("UTF-8"));
212
213 if (failures > 0) {
214 log.println();
215 throw new Exception("Tests failed: " + failures);
216 }
217
218 }
219
220 }
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /* @test
25 * @summary Check that error cases are replaced correctly in String/ISR/OSW
26 * @bug 4457851 7096080
27 *
28 * @build Errors Util
29 * @run main Errors
30 */
31
32 import java.io.*;
33 import java.nio.*;
34
35
36 public class Errors {
37
38 static PrintStream log = System.err;
39 static int failures = 0;
40
41 static final byte Q = (byte)'?';
42 static final byte X = (byte)'x';
43 static final byte Y = (byte)'y';
44 static final byte Z = (byte)'z';
45
46 static abstract class Test {
176 t.test("\uD800\uDC00x", new byte[] { Q, X });
177 t.test("\uF000", new byte[] { Q });
178 t.test("\uFFFE", new byte[] { Q });
179 t.test("\uFFFF", new byte[] { Q });
180 t.test(new byte[] { X, (byte)0x7f, Y }, "x\u007Fy");
181 t.test(new byte[] { X, (byte)0x80, Y }, "x\u0080y");
182 t.test(new byte[] { (byte)0xf0, (byte)0xf0 }, "\u00F0\u00F0");
183 }
184
185 static void test_UTF_8(Test t) {
186 t.run();
187 t.test("\u0080", new byte[] { (byte)0xC2, (byte)0x80 });
188 t.test("\u0100", new byte[] { (byte)0xC4, (byte)0x80 });
189 t.test("\uD800\uDC00",
190 new byte[] { (byte)0xF0, (byte)0x90, (byte)0x80, (byte)0x80 });
191 t.test("\uF000", new byte[] { (byte)0xEF, (byte)0x80, (byte)0x80 });
192 t.test("\uFFFE", new byte[] { (byte)0xEF, (byte)0xBF, (byte)0xBE });
193 t.test("\uFFFF", new byte[] { (byte)0xEF, (byte)0xBF, (byte)0xBF });
194 t.test(new byte[] { X, (byte)0x7f, Y }, "x\u007Fy");
195 t.test(new byte[] { X, (byte)0x80, Y }, "x\uFFFDy");
196 }
197
198 public static void main(String[] args) throws Exception {
199 test_US_ASCII(new TestString("US-ASCII"));
200 test_US_ASCII(new TestStream("US-ASCII"));
201
202 test_ISO_8859_1(new TestString("ISO-8859-1"));
203 test_ISO_8859_1(new TestStream("ISO-8859-1"));
204
205 test_ISO_8859_1(new TestString("ISO-8859-15"));
206 test_ISO_8859_1(new TestStream("ISO-8859-15"));
207
208 test_UTF_8(new TestString("UTF-8"));
209 test_UTF_8(new TestStream("UTF-8"));
210
211 if (failures > 0) {
212 log.println();
213 throw new Exception("Tests failed: " + failures);
214 }
215
216 }
217
218 }
|