}
public void testMethod2(TestHarness harness)
{
harness.checkPoint("(int, int, float[], DataBuffer)");
SampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 5, 10,
3, 16, new int[] {0, 2, 1});
DataBuffer db = m.createDataBuffer();
float[] pixel = new float[3];
m.getPixel(1, 2, pixel, db);
harness.check(Arrays.equals(pixel, new float[] {0, 0, 0}));
m.setPixel(1, 2, new int[] {1, 2, 3}, db);
m.getPixel(1, 2, pixel, db);
harness.check(Arrays.equals(pixel, new float[] {1, 2, 3}));
// if the incoming array is null, a new one is created
pixel = m.getPixel(1, 2, (float[]) null, db);
harness.check(Arrays.equals(pixel, new float[] {1, 2, 3}));
// try x < 0
boolean pass = false;
try
{
m.getPixel(-1, 1, (float[]) null, db);
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
harness.check(pass);
// try x == width
pass = false;
try
{
m.getPixel(5, 1, (float[]) null, db);
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
harness.check(pass);
// try y < 0
pass = false;
try
{
m.getPixel(1, -1, (float[]) null, db);
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
harness.check(pass);
// try y == height
pass = false;
try
{
m.getPixel(1, 10, (float[]) null, db);
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
harness.check(pass);
// try null data buffer
pass = false;
try
{
m.getPixel(1, 2, pixel, null);
}
catch (NullPointerException e)
{
pass = true;
}