Author: mturk
Date: Thu Jun 18 17:15:35 2009
New Revision: 786169

URL: http://svn.apache.org/viewvc?rev=786169&view=rev
Log:
Test for array overflow

Modified:
    
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java

Modified: 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java?rev=786169&r1=786168&r2=786169&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java
 Thu Jun 18 17:15:35 2009
@@ -182,6 +182,22 @@
         dst.free();
     }
 
+    public void testArray()
+        throws Throwable
+    {
+        Pointer p = Memory.calloc(1000);
+        assertNotNull("Pointer", p);
+        byte[] b = Memory.toByteArray(p, 0, 1000);
+        assertNotNull("Array", b);
+        try {
+            char[] c = Memory.toCharArray(p, 0, 501);
+            fail("Missing IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException ix) {
+            // Succedded.
+        }
+        p.free();
+    }
+
     public void testByteArray()
         throws Throwable
     {


Reply via email to