You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/07/03 09:39:27 UTC

svn commit: r790816 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/Memory.java test/org/apache/commons/runtime/TestMemory.java

Author: mturk
Date: Fri Jul  3 07:39:27 2009
New Revision: 790816

URL: http://svn.apache.org/viewvc?rev=790816&view=rev
Log:
Add invalid realloc test case

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

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java?rev=790816&r1=790815&r2=790816&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java Fri Jul  3 07:39:27 2009
@@ -159,7 +159,7 @@
         throws OutOfMemoryError, IllegalArgumentException;
 
     private static native void realloc0(Pointer ptr, long size)
-        throws OutOfMemoryError, RuntimeException
+        throws OutOfMemoryError, RuntimeException;
     /**
      * Change the size of memory block pointed by {@code ptr}.
      *

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=790816&r1=790815&r2=790816&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 Fri Jul  3 07:39:27 2009
@@ -104,6 +104,25 @@
         p.free();
     }
 
+    public void testInvalidRealloc()
+        throws Throwable
+    {
+        Pointer p = Memory.calloc(1000);
+        p.poke(999, 23);
+        Memory.realloc(p, 9999);
+        assertNotNull("Pointer", p);
+        assertEquals("Value", 23, p.peek(999));
+        Pointer s = Memory.slice(p, 0, 1000);
+        assertNotNull("Pointer", s);
+        try {
+            Memory.realloc(s, 10000);
+            fail("Missing RuntimeException");
+        } catch (RuntimeException ix) {
+            // Succedded.
+        }
+        p.free();
+    }
+
     public void testExecutableMalloc()
         throws Throwable
     {