equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
178 // private static final long maxCharsetFailures = Long.MAX_VALUE; |
178 // private static final long maxCharsetFailures = Long.MAX_VALUE; |
179 private static final long maxCharsetFailures = 10000L; |
179 private static final long maxCharsetFailures = 10000L; |
180 private final long failed0 = failed; |
180 private final long failed0 = failed; |
181 |
181 |
182 // legend: r=regular d=direct In=Input Ou=Output |
182 // legend: r=regular d=direct In=Input Ou=Output |
183 static final int maxBufSize = 20; |
183 static final int maxBufSize = 40; |
184 static final CharBuffer[] rInBuffers = new CharBuffer[maxBufSize]; |
184 static final CharBuffer[] rInBuffers = new CharBuffer[maxBufSize]; |
185 static final CharBuffer[] dInBuffers = new CharBuffer[maxBufSize]; |
185 static final CharBuffer[] dInBuffers = new CharBuffer[maxBufSize]; |
186 |
186 |
187 static final ByteBuffer[] rOuBuffers = new ByteBuffer[maxBufSize]; |
187 static final ByteBuffer[] rOuBuffers = new ByteBuffer[maxBufSize]; |
188 static final ByteBuffer[] dOuBuffers = new ByteBuffer[maxBufSize]; |
188 static final ByteBuffer[] dOuBuffers = new ByteBuffer[maxBufSize]; |
442 ia[len + j] = randomChar(); |
442 ia[len + j] = randomChar(); |
443 test(ia); |
443 test(ia); |
444 } |
444 } |
445 } |
445 } |
446 |
446 |
|
447 void testISO88591InvalidChar() { |
|
448 // Several architectures implement the ISO-8859-1 encoder as an |
|
449 // intrinsic where the vectorised assembly has separate cases |
|
450 // for different input sizes, so exhaustively test all sizes |
|
451 // from 0 to maxBufSize to ensure we get coverage |
|
452 |
|
453 for (int i = 0; i < CharsetTester.maxBufSize; i++) { |
|
454 char[] ia = new char[i]; |
|
455 for (int j = 0; j < i; j++) |
|
456 ia[j] = randomChar(); |
|
457 |
|
458 test(ia); |
|
459 |
|
460 // Test break on unrepresentable character |
|
461 for (int j = 0; j < i; j++) { |
|
462 char[] iaInvalid = ia.clone(); |
|
463 iaInvalid[j] = (char)(randomChar() | 0x100); |
|
464 test(iaInvalid); |
|
465 } |
|
466 } |
|
467 } |
|
468 |
447 void testPrefix(char[] prefix) { |
469 void testPrefix(char[] prefix) { |
448 if (prefix.length > 0) |
470 if (prefix.length > 0) |
449 System.out.printf("Testing prefix %s%n", string(prefix)); |
471 System.out.printf("Testing prefix %s%n", string(prefix)); |
450 |
472 |
451 test(prefix); |
473 test(prefix); |
490 |
512 |
491 if (csn.equals("x-ISCII91")) { |
513 if (csn.equals("x-ISCII91")) { |
492 System.out.println("More ISCII testing..."); |
514 System.out.println("More ISCII testing..."); |
493 new CharsetTester(cs).testPrefix(new char[]{'\u094d'}); // Halant |
515 new CharsetTester(cs).testPrefix(new char[]{'\u094d'}); // Halant |
494 new CharsetTester(cs).testPrefix(new char[]{'\u093c'}); // Nukta |
516 new CharsetTester(cs).testPrefix(new char[]{'\u093c'}); // Nukta |
|
517 } else if (csn.equals("ISO-8859-1")) { |
|
518 System.out.println("More ISO-8859-1 testing..."); |
|
519 new CharsetTester(cs).testISO88591InvalidChar(); |
495 } |
520 } |
496 } |
521 } |
497 |
522 |
498 private static void realMain(String[] args) { |
523 private static void realMain(String[] args) { |
499 for (Charset cs : sort(Charset.availableCharsets().values())) { |
524 for (Charset cs : sort(Charset.availableCharsets().values())) { |