}
public void testMethod2(TestHarness harness)
{
harness.checkPoint("(int, int, int, int, int, float[], DataBuffer)");
SampleModel m = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, 10,
20, new int[] { 224, 28, 3 });
DataBuffer db = m.createDataBuffer();
float[] samples = new float[6];
m.getSamples(1, 2, 2, 3, 1, samples, db);
harness.check(Arrays.equals(samples, new float[] {0, 0, 0, 0, 0, 0}));
m.setSamples(1, 2, 2, 3, 0, new float[] {1, 2, 3, 4 ,5 ,6}, db);
m.getSamples(1, 2, 2, 3, 0, samples, db);
harness.check(Arrays.equals(samples, new float[] {1, 2, 3, 4, 5, 6}));
m.setSamples(1, 2, 2, 3, 1, new float[] {7, 8, 9, 10, 11, 12}, db);
m.getSamples(1, 2, 2, 3, 1, samples, db);
harness.check(Arrays.equals(samples, new float[] {7, 0, 1, 2, 3, 4}));
m.setSamples(1, 2, 2, 3, 2, new float[] {13, 14, 15, 16, 17, 18}, db);
m.getSamples(1, 2, 2, 3, 2, samples, db);
harness.check(Arrays.equals(samples, new float[] {1, 2, 3, 0, 1, 2}));
// try invalid band
boolean pass = false;
try
{
m.setSamples(1, 2, 2, 3, 3, samples, db);
}
catch (ArrayIndexOutOfBoundsException e)
{
pass = true;
}
harness.check(pass);
// try null sample data
pass = false;
try
{
m.setSamples(1, 2, 2, 3, 0, (float[]) null, db);
}
catch (NullPointerException e)
{
pass = true;
}
harness.check(pass);
// try null data buffer
pass = false;
try
{
m.getSamples(1, 2, 2, 3, 0, samples, null);
}
catch (NullPointerException e)
{
pass = true;
}