This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: ComponentSampleModel - new tests


This patch (committed) adds some new tests for the ComponentSampleModel class:

2006-07-19 David Gilbert <david.gilbert@object-refinery.com>

* gnu/testlet/java/awt/image/ComponentSampleModel/createCompatibleSampleModel.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/createSubsetSampleModel.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getBandOffsets.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getDataElements.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getNumDataElements.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getPixel.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getPixels.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getPixelStride.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getSamples.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getSampleSize.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/getScanlineStride.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/setDataElements.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/setPixel.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/setPixels.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/setSample.java: New file,
* gnu/testlet/java/awt/image/ComponentSampleModel/setSamples.java: New file.


Regards,

Dave
Index: gnu/testlet/java/awt/image/ComponentSampleModel/createCompatibleSampleModel.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/createCompatibleSampleModel.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/createCompatibleSampleModel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/createCompatibleSampleModel.java	19 Jul 2006 04:19:50 -0000
@@ -0,0 +1,50 @@
+/* createCompatibleSampleModel.java -- some checks for the 
+       createCompatibleSampleModel() method in the ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.SampleModel;
+import java.util.Arrays;
+
+public class createCompatibleSampleModel implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 
+            11, 1, 25, new int[] {1, 2}, new int[] {3, 4});
+    SampleModel m2 = m1.createCompatibleSampleModel(33, 44);
+    harness.check(m2 instanceof ComponentSampleModel);
+    harness.check(m2.getDataType(), DataBuffer.TYPE_INT);
+    harness.check(m2.getWidth(), 33);
+    harness.check(m2.getHeight(), 44);
+    harness.check(m2.getNumBands(), 2);
+    harness.check(Arrays.equals(m1.getBandOffsets(), new int[] {3, 4}));
+    harness.check(Arrays.equals(m1.getBankIndices(), new int[] {1, 2}));
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/createSubsetSampleModel.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/createSubsetSampleModel.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/createSubsetSampleModel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/createSubsetSampleModel.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,47 @@
+/* createSubsetSampleModel.java -- some checks for the createSubsetSampleModel()
+       method in the ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.SampleModel;
+
+public class createSubsetSampleModel implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 
+            11, 2, 44, new int[] {0, 1});
+    SampleModel m2 = m1.createSubsetSampleModel(new int[] {1});
+    harness.check(m2 instanceof ComponentSampleModel);
+    harness.check(m2.getDataType(), DataBuffer.TYPE_INT);
+    harness.check(m2.getWidth(), 22);
+    harness.check(m2.getHeight(), 11);
+    harness.check(m2.getNumBands(), 1);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/getBandOffsets.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/getBandOffsets.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/getBandOffsets.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/getBandOffsets.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,48 @@
+/* getBandOffsets.java -- some checks for the getBandOffsets() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.util.Arrays;
+
+public class getBandOffsets implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    int[] bo = new int[] {1, 2};
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 
+            33, 1, 23, bo);
+    int[] bo1 = m1.getBandOffsets();
+    harness.check(Arrays.equals(bo1, new int[] {1, 2}));
+    int[] bo2 = m1.getBandOffsets();
+    harness.check(bo1 != bo2);
+    bo[1] = 3;
+    harness.check(m1.getBandOffsets()[1], 2);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/getDataElements.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/getDataElements.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/getDataElements.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/getDataElements.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,72 @@
+/* getDataElements.java -- some checks for the getDataElements() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+
+public class getDataElements implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    DataBuffer db = new DataBufferInt(12);
+    for (int i = 0; i < 12; i++)
+      db.setElem(i, i);
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    Object elements = m.getDataElements(0, 0, 2, 1, null, db);
+    int[] de = (int[]) elements;
+    harness.check(de.length, 4);
+    harness.check(de[0], 0);
+    harness.check(de[1], 1);
+    harness.check(de[2], 2);
+    harness.check(de[3], 3);
+    
+    // try passing in a result array
+    int[] result = new int[4];
+    de = (int[]) m.getDataElements(0, 0, 2, 1, result, db);
+    harness.check(de[0], 0);
+    harness.check(de[1], 1);
+    harness.check(de[2], 2);
+    harness.check(de[3], 3);
+    harness.check(de == result);
+    
+    // try null data buffer
+    boolean pass = false;
+    try
+      {
+        m.getDataElements(0, 0, 2, 1, result, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;  
+      }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/getNumDataElements.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/getNumDataElements.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/getNumDataElements.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/getNumDataElements.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,41 @@
+/* getNumDataElements.java -- some checks for the getNumDataElements() method
+       in the ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+
+public class getNumDataElements implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    harness.check(m.getNumDataElements(), 2);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/getPixelStride.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/getPixelStride.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/getPixelStride.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/getPixelStride.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,41 @@
+/* getPixelStride.java -- some checks for the getPixelStride() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class getPixelStride implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 
+        11, 2, 44, new int[] {0, 0});
+    harness.check(m1.getPixelStride(), 2);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/getPixels.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/getPixels.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/getPixels.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/getPixels.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,71 @@
+/* getPixels.java -- some checks for the getPixels() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class getPixels implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    DataBuffer db = new DataBufferInt(12);
+    for (int i = 0; i < 12; i++)
+      db.setElem(i, i);
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    int[] pixels = m.getPixels(1, 0, 2, 1, (int[]) null, db);
+    harness.check(pixels.length, 4);
+    harness.check(pixels[0], 2);
+    harness.check(pixels[1], 3);
+    harness.check(pixels[2], 4);
+    harness.check(pixels[3], 5);
+    
+    // try passing in a result array
+    int[] result = new int[4];
+    pixels = m.getPixels(1, 1, 2, 1, result, db);
+    harness.check(pixels[0], 8);
+    harness.check(pixels[1], 9);
+    harness.check(pixels[2], 10);
+    harness.check(pixels[3], 11);
+    harness.check(pixels == result);
+    
+    // try null data buffer
+    boolean pass = false;
+    try
+      {
+        m.getPixels(1, 1, 2, 1, result, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;  
+      }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/getSampleSize.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/getSampleSize.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/getSampleSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/getSampleSize.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,71 @@
+/* getSampleSize.java -- some checks for the getSampleSize() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class getSampleSize implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    test1(harness);
+    test2(harness);
+  }
+  
+  private void test1(TestHarness harness)
+  {
+    harness.checkPoint("()");  
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 
+            11, 2, 44, new int[] {0, 0});
+    int[] sizes = m1.getSampleSize();
+    harness.check(sizes.length, 2);
+    harness.check(sizes[0], 32);
+    harness.check(sizes[1], 32);
+
+    ComponentSampleModel m2 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 22, 
+            11, 2, 44, new int[] {0, 0, 0});
+    int[] sizes2 = m2.getSampleSize();
+    harness.check(sizes2.length, 3);
+    harness.check(sizes2[0], 8);
+    harness.check(sizes2[1], 8);
+    harness.check(sizes2[2], 8);
+  }
+  
+  private void test2(TestHarness harness)
+  {
+    harness.checkPoint("(int)");  
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 
+            11, 2, 44, new int[] {0, 0});
+    harness.check(m1.getSampleSize(0), 32);
+    harness.check(m1.getSampleSize(1), 32);
+    harness.check(m1.getSampleSize(2), 32);
+    harness.check(m1.getSampleSize(3), 32);
+    harness.check(m1.getSampleSize(-1), 32);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/getSamples.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/getSamples.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/getSamples.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/getSamples.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,68 @@
+/* getSamples.java -- some checks for the getSamples() method in the 
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class getSamples implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    DataBuffer db = new DataBufferInt(12);
+    for (int i = 0; i < 12; i++)
+      db.setElem(i, i);
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    int[] samples = m.getSamples(0, 1, 2, 1, 0, (int[]) null, db);
+    harness.check(samples.length, 2);
+    harness.check(samples[0], 6);
+    harness.check(samples[1], 8);
+    
+    // try passing in a result array
+    int[] result = new int[2];
+    samples = m.getSamples(0, 1, 2, 1, 1, result, db);
+    harness.check(samples.length, 2);
+    harness.check(samples[0], 7);
+    harness.check(samples[1], 9);
+    harness.check(samples == result);
+    
+    // try null data buffer
+    boolean pass = false;
+    try
+      {
+        m.getSamples(0, 1, 2, 1, 1, result, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;  
+      }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/getScanlineStride.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/getScanlineStride.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/getScanlineStride.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/getScanlineStride.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,41 @@
+/* getScanlineStride.java -- some checks for the getScanlineStride() method
+       in the ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class getScanlineStride implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 22, 
+        11, 2, 44, new int[] {0, 0});
+    harness.check(m1.getScanlineStride(), 44);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/setDataElements.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/setDataElements.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/setDataElements.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/setDataElements.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,83 @@
+/* setDataElements.java -- some checks for the setDataElements() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+
+public class setDataElements implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    DataBuffer db = new DataBufferInt(12);
+    int[] pixel = new int[] {11, 22};
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    m.setDataElements(1, 1, pixel, db);
+    harness.check(db.getElem(0, 8), 11);
+    harness.check(db.getElem(0, 9), 22);
+        
+    // check bad type for data element array
+    boolean pass = false;
+    try
+      {
+        m.setDataElements(1, 1, "???", db);
+      }
+    catch (ClassCastException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+    
+    // check that a null pixel array generates a NullPointerException
+    pass = false;
+    try
+      {
+        m.setDataElements(1, 1, (int[]) null, db);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);    
+
+    // check that a null data buffer generates a NullPointerException
+    pass = false;
+    try
+      {
+        m.setDataElements(1, 1, pixel, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);    
+  
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/setPixel.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/setPixel.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/setPixel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/setPixel.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,71 @@
+/* setPixel.java -- some checks for the setPixel() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+
+public class setPixel implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    DataBuffer db = new DataBufferInt(12);
+    int[] pixel = new int[] {11, 22};
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    m.setPixel(1, 1, pixel, db);
+    harness.check(db.getElem(0, 8), 11);
+    harness.check(db.getElem(0, 9), 22);
+        
+    // check that a null pixel array generates a NullPointerException
+    boolean pass = false;
+    try
+      {
+        m.setPixel(1, 1, (int[]) null, db);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);    
+
+    // check that a null data buffer generates a NullPointerException
+    pass = false;
+    try
+      {
+        m.setPixel(1, 1, pixel, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);    
+  
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/setPixels.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/setPixels.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/setPixels.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/setPixels.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,73 @@
+/* setPixels.java -- some checks for the setPixels() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+
+public class setPixels implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    DataBuffer db = new DataBufferInt(12);
+    int[] pixels = new int[] {11, 22, 33, 44};
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    m.setPixels(0, 0, 2, 1, pixels, db);
+    harness.check(db.getElem(0, 0), 11);
+    harness.check(db.getElem(0, 1), 22);
+    harness.check(db.getElem(0, 2), 33);
+    harness.check(db.getElem(0, 3), 44);
+        
+    // check that a null pixel array generates a NullPointerException
+    boolean pass = false;
+    try
+      {
+        m.setPixels(0, 0, 2, 1, (int[]) null, db);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);    
+
+    // check that a null data buffer generates a NullPointerException
+    pass = false;
+    try
+      {
+        m.setPixels(0, 0, 2, 1, pixels, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);    
+  
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/setSample.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/setSample.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/setSample.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/setSample.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,140 @@
+/* setSample.java -- some checks for the setSample() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferDouble;
+import java.awt.image.DataBufferFloat;
+import java.awt.image.DataBufferInt;
+
+public class setSample implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    test1(harness);
+    test2(harness);
+    test3(harness);
+  }
+  
+  private void test1(TestHarness harness)
+  {
+    harness.checkPoint("(int, int, int, double, DataBuffer)");  
+    DataBuffer db = new DataBufferDouble(12);
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE,
+            3, 2, 2, 6, new int[] {0, 1});
+    m.setSample(2, 1, 0, 99.9, db);
+    harness.check(db.getElem(0, 10), 99.0d);
+    m.setSample(2, 1, 1, 88.8, db);
+    harness.check(db.getElem(0, 11), 88.0d);
+    
+    // what happens if the data buffer doesn't hold doubles?
+    DataBuffer db2 = new DataBufferInt(12);
+    m.setSample(2, 1, 0, 99.9d, db2);
+    harness.check(db2.getElem(0, 10), 99);
+    m.setSample(2, 1, 1, 88.8d, db2);
+    harness.check(db2.getElem(0, 11), 88); 
+
+    // check that a null data buffer generates a NullPointerException
+    boolean pass = false;
+    try
+      {
+        m.setSample(2, 1, 1, 77.7d, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+  private void test2(TestHarness harness)
+  {
+    harness.checkPoint("(int, int, int, float, DataBuffer)");  
+
+    DataBuffer db = new DataBufferFloat(12);
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_FLOAT,
+            3, 2, 2, 6, new int[] {0, 1});
+    m.setSample(2, 1, 0, 99.9f, db);
+    harness.check(db.getElem(0, 10), 99.0f);
+    m.setSample(2, 1, 1, 88.8f, db);
+    harness.check(db.getElem(0, 11), 88.0f);
+    
+    // what happens if the data buffer doesn't hold floats?
+    DataBuffer db2 = new DataBufferInt(12);
+    m.setSample(2, 1, 0, 99.9f, db2);
+    harness.check(db2.getElem(0, 10), 99);
+    m.setSample(2, 1, 1, 88.8f, db2);
+    harness.check(db2.getElem(0, 11), 88); 
+     
+    // check that a null data buffer generates a NullPointerException
+    boolean pass = false;
+    try
+      {
+        m.setSample(2, 1, 1, 77.7f, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+  private void test3(TestHarness harness)
+  {
+    harness.checkPoint("(int, int, int, int, DataBuffer)");  
+    
+    DataBuffer db = new DataBufferInt(12);
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    m.setSample(2, 1, 0, 99, db);
+    harness.check(db.getElem(0, 10), 99);
+    m.setSample(2, 1, 1, 88, db);
+    harness.check(db.getElem(0, 11), 88);
+    
+    // what happens if the data buffer doesn't hold integers?
+    DataBuffer db2 = new DataBufferByte(12);
+    m.setSample(2, 1, 0, 99, db2);
+    harness.check(db2.getElem(0, 10), 99);
+    m.setSample(2, 1, 1, 888, db2);
+    harness.check(db2.getElem(0, 11), 120);  // (byte) 888
+    
+    // check that a null data buffer generates a NullPointerException
+    boolean pass = false;
+    try
+      {
+        m.setSample(2, 1, 1, 77, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/setSamples.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/setSamples.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/setSamples.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/setSamples.java	19 Jul 2006 04:19:51 -0000
@@ -0,0 +1,58 @@
+/* setSamples.java -- some checks for the setSamples() method in the
+       ComponentSampleModel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+
+public class setSamples implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    DataBuffer db = new DataBufferInt(12);
+    int[] samples = new int[] {11, 22};
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_INT,
+            3, 2, 2, 6, new int[] {0, 1});
+    m.setSamples(1, 0, 2, 1, 1, samples, db);
+    harness.check(db.getElem(0, 3), 11);
+    harness.check(db.getElem(0, 5), 22);
+        
+    // check that a null data buffer generates a NullPointerException
+    boolean pass = false;
+    try
+      {
+        m.setSamples(1, 0, 2, 1, 1, samples, null);
+      }
+    catch (NullPointerException e)
+      {
+        pass = true;
+      }
+    harness.check(pass);    
+  }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]