commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1091675 - in /commons/sandbox/runtime/trunk/src/main: native/shared/clazz.c test/org/apache/commons/runtime/TestMemory.java
Date Wed, 13 Apr 2011 07:09:02 GMT
Author: mturk
Date: Wed Apr 13 07:09:02 2011
New Revision: 1091675

URL: http://svn.apache.org/viewvc?rev=1091675&view=rev
Log:
Add few more memory test cases

Modified:
    commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
    commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=1091675&r1=1091674&r2=1091675&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Wed Apr 13 07:09:02 2011
@@ -223,6 +223,7 @@ AcrLoadRuntimeClasses(JNI_STDENV)
     ACR_CLASS_LOPT(Unsafe);
     ACR_CLASS_LOAD(ConstPointer);
     ACR_CLASS_LOAD(HeapPointer);
+    ACR_CLASS_LOAD(SlicePointer);
     ACR_CLASS_LOAD(FileDescriptor);
 
 #ifdef WIN32
@@ -237,6 +238,7 @@ AcrUnloadRuntimeClasses(JNI_STDENV)
 
     ACR_CLASS_UNLOAD(ConstPointer);
     ACR_CLASS_UNLOAD(HeapPointer);
+    ACR_CLASS_UNLOAD(SlicePointer);
     ACR_CLASS_UNLOAD(FileDescriptor);
     ACR_CLASS_UNLOAD(Callback);
     ACR_CLASS_UNLOAD(Unsafe);

Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java?rev=1091675&r1=1091674&r2=1091675&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java
Wed Apr 13 07:09:02 2011
@@ -25,7 +25,7 @@ public class TestMemory
 
 
     @Test(groups = { "private" })
-    public void malloc()
+    public void zeroMalloc()
     {
         Pointer p = Memory.malloc();
         Assert.assertNotNull(p);
@@ -69,4 +69,39 @@ public class TestMemory
         p.free();
     }
 
+    @Test(groups = { "private" })
+    public void heapMalloc()
+        throws Throwable
+    {
+        Pointer p = Memory.malloc(1000);
+        Assert.assertNotNull(p);
+        p.free();
+    }
+
+    @Test(groups = { "private" })
+    public void heapSlice()
+        throws Throwable
+    {
+        Pointer p = Memory.malloc(1000);
+        Assert.assertNotNull(p);
+        Pointer s = Memory.slice(p, 0, 1000);
+        p.free();
+        s.free();
+    }
+
+    @Test(groups = { "private" })
+    public void toByteArray()
+        throws Throwable
+    {
+        Pointer p = Memory.calloc(1000);
+        Assert.assertNotNull(p);
+        Memory.set(p, 0, 1000, 0xFF);
+        byte[] b = Memory.toByteArray(p, 0, 1000);
+        Assert.assertNotNull(b);
+        Assert.assertEquals(1000, b.length);
+        Assert.assertEquals((byte)0xFF, b[0]);
+
+        p.free();
+    }
+
 }



Mime
View raw message