/*
* 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 6380723
* @summary Decode many byte sequences in many ways
* @author Martin Buchholz
*/
public class FindDecoderBugs {
return false;
}
return list;
}
}
for (byte b : a) {
}
}
for (char c : a) {
}
}
static class Reporter {
// Some machinery to make sure only a small number of errors
// that are "too similar" are reported.
return count+1;
}
}
failed++;
return true;
}
return false;
}
void summarize() {
}
}
static class Result {
final int limit;
final int ipos;
final boolean direct;
final byte[] ia;
final char[] oa;
}
byte[] a = new byte[b.limit()];
b.position(0);
b.get(a);
return a;
}
char[] a = new char[b.position()];
b.position(0);
b.get(a);
return a;
}
return x == y ||
}
}
}
// legend: r=regular d=direct In=Input Ou=Output
static {
for (int i = 0; i < maxBufSize; i++) {
}
}
static class CharsetTester {
// private static final long maxCharsetFailures = Long.MAX_VALUE;
}
}
try {
char canary = '\u4242';
bug("OVERFLOW, but there's lots of room: %s %s",
cs, r);
// if (cr.isOverflow() && ib.remaining() == 0)
// bug("OVERFLOW, yet remaining() == 0: %s %s",
// cs, r);
bug("remaining() < CoderResult.length(): %s %s",
cs, r);
// if (ib.position() == 0 && ob.position() > 0)
// reporter. bug("output only if input consumed: %s %s",
// cs, r);
// Should we warn if cr.isUnmappable() ??
bug("Coding operation not idempotent: %s%n %s%n %s",
bug("Buffer overrun: %s %s %s",
return r;
} catch (Throwable t) {
if (bug("Unexpected exception: %s %s %s",
t.printStackTrace();
return null;
}
}
bug("Results differ for direct buffers: %s%n %s%n %s",
return r1;
}
throw new TooManyFailures();
if (olen > 0) {
bug("Results differ: %s%n %s%n %s",
}
for (int i = 0; i < olen; i++) {
bug("Expected OVERFLOW: %s%n %s%n %s",
}
}
return roomy;
}
for (int i = 0; i < 0x100; i++) {
if (n == 1)
else
}
}
for (int i = 0; i < 5000; i++) {
for (int j = 0; j < n; j++)
}
}
// Can you spare a week of CPU time?
// testExhaustively(cs, tester, prefix, 3);
}
}
private static byte randomByte() {
}
byte[] a = new byte[len];
for (int i = 0; i < len; i++)
a[i] = randomByte();
return a;
}
private final static byte[][] stateChangers = {
};
private final static byte[][]escapeSequences = {
{ESC, 'N'},
{ESC, 'O'},
};
return r == null ? false :
(r.cr.isUnderflow() &&
}
private final static byte[][] incompletePrefixes = {
{ESC},
{ESC, '('},
{ESC, '$'},
};
return r == null ? false :
(r.cr.isUnderflow() &&
r.ipos == 0 &&
}
return;
}
for (byte[] prefix : stateChangers)
for (byte[] prefix : incompletePrefixes)
for (byte[] prefix : escapeSequences)
}
}
try {
} catch (TooManyFailures e) {
} catch (Throwable t) {
unexpected(t);
}
}
}
//--------------------- Infrastructure ---------------------------
else fail(x + " not equal to " + y);}
static void equal(int x, int y) {
if (x == y) pass();
else fail(x + " not equal to " + y);}
}