harness.checkPoint("(int, int, int, int, int, int[], int[])");
int[] bankIndices = new int[] {0, 1};
int[] bandOffsets = new int[] {0, 0};
ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
11, 1, 25, bankIndices, new int[] {0, 0});
harness.check(m.getDataType(), DataBuffer.TYPE_INT);
harness.check(m.getWidth(), 22);
harness.check(m.getHeight(), 11);
harness.check(m.getPixelStride(), 1);
harness.check(m.getNumBands(), 2);
harness.check(m.getNumDataElements(), 2);
harness.check(Arrays.equals(m.getBankIndices(), new int[] {0, 1}));
harness.check(m.getBankIndices() != bankIndices); // not the same instance
harness.check(Arrays.equals(m.getBandOffsets(), bandOffsets));
harness.check(m.getBandOffsets() != bandOffsets); // not the same instance
// check unknown data type
boolean pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_UNDEFINED, 22,
11, 1, 25, new int[] {0, 1}, new int[] {0, 0});
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// check w = 0
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, 0,
11, 1, 25, new int[] {0, 1}, new int[] {0, 0});
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// check h = 0
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
0, 1, 25, new int[] {0, 1}, new int[] {0, 0});
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// check w * h exceeds Integer.MAX_VALUE
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, Integer.MAX_VALUE - 1,
2, 1, 25, new int[] {0, 1}, new int[] {0, 0});
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// try pixelStride < 0
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
11, -1, 25, new int[] {0, 1}, new int[] {0, 0});
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// try scanlineStride = 0
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22,
11, 1, -1, new int[] {0, 1}, new int[] {0, 0});
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// try null bankIndices
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 11, 1, 25, null,
new int[] {0, 0});
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
// try empty bankIndices
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 11, 1, 25,
new int[0], new int[] {0, 0});
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// try null bandOffsets
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 11, 1, 25,
new int[] {0, 0}, null);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
// try arrays of different lengths
pass = false;
try
{
m = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 11, 1, 25,
new int[1], new int[2]);
}
catch (IllegalArgumentException e)
{
pass = true;