}
private void testConstructor4(TestHarness harness)
{
harness.checkPoint("IndexColorModel(int, int, byte[], int, boolean)");
IndexColorModel m1 = new IndexColorModel(2, 4, CMAP, 0, false);
harness.check(!m1.isAlphaPremultiplied());
harness.check(m1.getRed(0), 1);
harness.check(m1.getRed(1), 2);
harness.check(m1.getRed(2), 3);
harness.check(m1.getRed(3), 4);
harness.check(m1.getGreen(0), 5);
harness.check(m1.getGreen(1), 6);
harness.check(m1.getGreen(2), 7);
harness.check(m1.getGreen(3), 8);
harness.check(m1.getBlue(0), 9);
harness.check(m1.getBlue(1), 10);
harness.check(m1.getBlue(2), 11);
harness.check(m1.getBlue(3), 12);
harness.check(m1.getAlpha(0), 255);
harness.check(m1.getAlpha(1), 255);
harness.check(m1.getAlpha(2), 255);
harness.check(m1.getAlpha(3), 255);
harness.check(!m1.hasAlpha());
IndexColorModel m2 = new IndexColorModel(2, 4, CMAP_WITH_ALPHA, 0, true);
harness.check(m2.getRed(0), 1);
harness.check(m2.getRed(1), 2);
harness.check(m2.getRed(2), 3);
harness.check(m2.getRed(3), 4);
harness.check(m2.getGreen(0), 5);
harness.check(m2.getGreen(1), 6);
harness.check(m2.getGreen(2), 7);
harness.check(m2.getGreen(3), 8);
harness.check(m2.getBlue(0), 9);
harness.check(m2.getBlue(1), 10);
harness.check(m2.getBlue(2), 11);
harness.check(m2.getBlue(3), 12);
harness.check(m2.getAlpha(0), 13);
harness.check(m2.getAlpha(1), 14);
harness.check(m2.getAlpha(2), 15);
harness.check(m2.getAlpha(3), 16);
harness.check(m2.hasAlpha());
// try bits < 1
boolean pass = false;
try
{
/* IndexColorModel m = */ new IndexColorModel(0, 4, CMAP, 0, false);
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// try bits > 16
pass = false;
try
{
/* IndexColorModel m = */ new IndexColorModel(17, 4, CMAP, 0, false);
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// try size bigger than arrays
pass = false;
try
{
/* IndexColorModel m = */ new IndexColorModel(2, 99, CMAP, 0, false);
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
harness.check(pass);
// try null cmap array
pass = false;
try
{
/* IndexColorModel m = */ new IndexColorModel(2, 4, null, 0, false);
}
catch (NullPointerException e)
{
pass = true;
}