*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
BandedSampleModel m = new BandedSampleModel(DataBuffer.TYPE_INT, 2, 3, 2);
DataBufferInt b = new DataBufferInt(6, 2);
b.setElem(0, 0, 0xA0);
b.setElem(0, 1, 0xA1);
b.setElem(0, 2, 0xA2);
b.setElem(0, 3, 0xA3);
b.setElem(0, 4, 0xA4);
b.setElem(0, 5, 0xA5);
b.setElem(1, 0, 0xB0);
b.setElem(1, 1, 0xB1);
b.setElem(1, 2, 0xB2);
b.setElem(1, 3, 0xB3);
b.setElem(1, 4, 0xB4);
b.setElem(1, 5, 0xB5);
int[] samples = m.getSamples(1, 1, 1, 2, 0, (int[]) null, b);
harness.check(samples[0], 0xA3);
harness.check(samples[1], 0xA5);
samples = m.getSamples(1, 1, 1, 2, 1, (int[]) null, b);
harness.check(samples[0], 0xB3);
harness.check(samples[1], 0xB5);
// check negative x
boolean pass = false;
try
{
m.getSamples(-1, 1, 1, 2, 1, (int[]) null, b);
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
harness.check(pass);
// check negative y
pass = false;
try
{
m.getSamples(1, -1, 1, 2, 1, (int[]) null, b);
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
harness.check(pass);
// check negative w
pass = false;
try
{
m.getSamples(1, 1, -1, 2, 1, (int[]) null, b);
}
catch (NegativeArraySizeException e)
{
pass = true;
}
harness.check(pass);
// check negative h
pass = false;
try
{
m.getSamples(1, 1, 1, -1, 1, (int[]) null, b);
}
catch (NegativeArraySizeException e)
{
pass = true;
}
harness.check(pass);
// check null data buffer
pass = false;
try
{
m.getSamples(1, 1, 1, 1, 1, (int[]) null, null);
}
catch (NullPointerException e)
{
pass = true;
}