public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: ComponentSampleModel - new tests
@ 2006-07-19  4:29 David Gilbert
  0 siblings, 0 replies; 2+ messages in thread
From: David Gilbert @ 2006-07-19  4:29 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 1469 bytes --]

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

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 38636 bytes --]

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);    
+  }
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* FYI: ComponentSampleModel - new tests
@ 2006-07-17 16:35 David Gilbert
  0 siblings, 0 replies; 2+ messages in thread
From: David Gilbert @ 2006-07-17 16:35 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 564 bytes --]

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

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

	* gnu/testlet/java/awt/image/ComponentSampleModel/constructors.java: New file,
	* gnu/testlet/java/awt/image/ComponentSampleModel/createDataBuffer.java: New file
	* gnu/testlet/java/awt/image/ComponentSampleModel/equals.java: New file,
	* gnu/testlet/java/awt/image/ComponentSampleModel/hashCode.java: New file,
	* gnu/testlet/java/awt/image/ComponentSampleModel/MyComponentSampleModel.java: New 
file.

Regards,

Dave

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 14965 bytes --]

Index: gnu/testlet/java/awt/image/ComponentSampleModel/MyComponentSampleModel.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/MyComponentSampleModel.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/MyComponentSampleModel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/MyComponentSampleModel.java	17 Jul 2006 16:30:43 -0000
@@ -0,0 +1,51 @@
+/* MyComponentSampleModel.java -- provides access to protected attributes.
+   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: not-a-test
+
+package gnu.testlet.java.awt.image.ComponentSampleModel;
+
+import java.awt.image.ComponentSampleModel;
+
+public class MyComponentSampleModel extends ComponentSampleModel
+{
+  public MyComponentSampleModel(int dataType, int w, int h, int pixelStride, 
+          int scanlineStride, int[] bandOffsets)
+  {
+    super(dataType, w, h, pixelStride, scanlineStride, bandOffsets);
+  }
+  
+  public MyComponentSampleModel(int dataType, int w, int h, int pixelStride, 
+          int scanlineStride, int[] bandOffsets, int[] bankIndices)
+  {
+    super(dataType, w, h, pixelStride, scanlineStride, bandOffsets);
+  }
+  
+  public int[] getBandOffsetsDirect()
+  {
+    return this.bandOffsets;
+  }
+  
+  public int[] getBankIndicesDirect()
+  {
+    return this.bankIndices;
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/constructors.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/constructors.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/constructors.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/constructors.java	17 Jul 2006 16:30:43 -0000
@@ -0,0 +1,171 @@
+/* constructors.java -- some checks for the constructors 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 constructors implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    testConstructor1(harness);
+    testConstructor2(harness);
+    testDefensiveCopies(harness);
+  }
+  
+  public void testConstructor1(TestHarness harness)
+  {
+    harness.checkPoint("testConstructor1()");
+    
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE,
+            10, 20, 3, 30, new int[] {0, 1, 2});
+    harness.check(m.getDataType(), DataBuffer.TYPE_BYTE);
+    harness.check(m.getWidth(), 10);
+    harness.check(m.getHeight(), 20);
+    harness.check(m.getPixelStride(), 3);
+    harness.check(m.getScanlineStride(), 30);
+    harness.check(Arrays.equals(m.getBandOffsets(), new int[] {0, 1, 2}));
+    
+    // try bad type
+    boolean pass = false;
+    try
+    {
+      m = new ComponentSampleModel(DataBuffer.TYPE_UNDEFINED, 10, 20, 3, 30, 
+              new int[] {0, 1, 2});
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // try zero width
+    pass = false;
+    try
+    {
+      m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 0, 20, 3, 30, 
+              new int[] {0, 1, 2});
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+
+    // try zero height
+    pass = false;
+    try
+    {
+      m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 10, 0, 3, 30, 
+              new int[] {0, 1, 2});
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // try negative pixel stride
+    pass = false;
+    try
+    {
+      m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 10, 20, -1, 30, 
+              new int[] {0, 1, 2});
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+
+    // try negative scanline stride
+    pass = false;
+    try
+    {
+      m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 10, 20, 3, -1, 
+              new int[] {0, 1, 2});
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // try width * height > Integer.MAX_VALUE
+    pass = false;
+    try
+    {
+      m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 3, 
+              Integer.MAX_VALUE / 2, 3, 30, new int[] {0, 1, 2});
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // try null band offsets
+    pass = false;
+    try
+    {
+      m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 10, 20, 3, 30, null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);    
+  }
+  
+  public void testConstructor2(TestHarness harness)
+  {
+    harness.checkPoint("testConstructor2()");
+    
+  }
+  
+  public void testDefensiveCopies(TestHarness harness)
+  {
+    harness.checkPoint("testDefensiveCopies()");
+    int[] bandOffsets = new int[] {0, 1, 2};
+    MyComponentSampleModel m = new MyComponentSampleModel(DataBuffer.TYPE_BYTE,
+            10, 20, 3, 30, bandOffsets);
+    harness.check(bandOffsets != m.getBandOffsetsDirect());
+    harness.check(Arrays.equals(bandOffsets, m.getBandOffsetsDirect()));
+
+    int[] bankIndices = new int[] {0, 0, 0};
+    MyComponentSampleModel m2 = new MyComponentSampleModel(DataBuffer.TYPE_BYTE,
+            10, 20, 3, 30, bandOffsets, bankIndices);
+    harness.check(bandOffsets != m.getBandOffsetsDirect());
+    harness.check(Arrays.equals(bandOffsets, m.getBandOffsetsDirect()));
+    harness.check(bankIndices != m.getBankIndicesDirect());
+    harness.check(Arrays.equals(bankIndices, m.getBankIndicesDirect()));
+
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/createDataBuffer.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/createDataBuffer.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/createDataBuffer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/createDataBuffer.java	17 Jul 2006 16:30:43 -0000
@@ -0,0 +1,44 @@
+/* createDataBuffer.java -- some checks for the createDataBuffer() 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 createDataBuffer implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    ComponentSampleModel m = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 10, 
+            20, 3, 30, new int[] {0, 1, 2});
+    DataBuffer db = m.createDataBuffer();
+    harness.check(db.getDataType(), DataBuffer.TYPE_BYTE);
+    harness.check(db.getNumBanks(), 1);
+    harness.check(db.getSize(), 600);
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/equals.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/equals.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/equals.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/equals.java	17 Jul 2006 16:30:43 -0000
@@ -0,0 +1,78 @@
+/* equals.java -- some checks for the equals() 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 equals implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 
+            10, 20, 3, 40, new int[] {0, 1, 2});
+    ComponentSampleModel m2 = new ComponentSampleModel(DataBuffer.TYPE_INT, 
+            10, 20, 3, 40, new int[] {0, 1, 2});
+    harness.check(m1.equals(m2));
+    
+    m1 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            10, 20, 3, 40, new int[] {0, 1, 2});
+    harness.check(!m1.equals(m2));
+    m2 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            10, 20, 3, 40, new int[] {0, 1, 2});
+    harness.check(m1.equals(m2));
+    
+    m1 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            9, 20, 3, 40, new int[] {0, 1, 2});
+    harness.check(!m1.equals(m2));
+    m2 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            9, 20, 3, 40, new int[] {0, 1, 2});
+    harness.check(m1.equals(m2));
+    
+    m1 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            9, 19, 3, 40, new int[] {0, 1, 2});
+    harness.check(!m1.equals(m2));
+    m2 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            9, 19, 3, 40, new int[] {0, 1, 2});
+    harness.check(m1.equals(m2));
+    
+    m1 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            9, 19, 4, 40, new int[] {0, 1, 2});
+    harness.check(!m1.equals(m2));
+    m2 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            9, 19, 4, 40, new int[] {0, 1, 2});
+    harness.check(m1.equals(m2));
+
+    m1 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            9, 19, 4, 40, new int[] {0, 2, 1});
+    harness.check(!m1.equals(m2));
+    m2 = new ComponentSampleModel(DataBuffer.TYPE_BYTE, 
+            9, 19, 4, 40, new int[] {0, 2, 1});
+    harness.check(m1.equals(m2));
+  }
+}
Index: gnu/testlet/java/awt/image/ComponentSampleModel/hashCode.java
===================================================================
RCS file: gnu/testlet/java/awt/image/ComponentSampleModel/hashCode.java
diff -N gnu/testlet/java/awt/image/ComponentSampleModel/hashCode.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/image/ComponentSampleModel/hashCode.java	17 Jul 2006 16:30:43 -0000
@@ -0,0 +1,46 @@
+/* hashCode.java -- some checks for the hashCode() 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 hashCode implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    // equal instances should have equal hashCodes...
+    ComponentSampleModel m1 = new ComponentSampleModel(DataBuffer.TYPE_INT, 
+            10, 20, 3, 3, new int[] {0, 1, 2});
+    ComponentSampleModel m2 = new ComponentSampleModel(DataBuffer.TYPE_INT, 
+            10, 20, 3, 3, new int[] {0, 1, 2});
+    harness.check(m1.equals(m2));
+    harness.check(m1.hashCode(), m2.hashCode());
+  }
+
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-19  4:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-19  4:29 FYI: ComponentSampleModel - new tests David Gilbert
  -- strict thread matches above, loose matches on Subject: below --
2006-07-17 16:35 David Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).