Duplicate tests that are run twice as both C and C++ tests to fix parallel make: li_cdata

This commit is contained in:
William S Fulton 2016-02-21 15:01:37 +00:00
commit 819bd9c97e
5 changed files with 55 additions and 1 deletions

View file

@ -265,7 +265,7 @@ CPP_TEST_CASES += \
li_boost_shared_ptr_template \
li_boost_shared_ptr_attribute \
li_carrays_cpp \
li_cdata \
li_cdata_cpp \
li_cpointer \
li_std_auto_ptr \
li_stdint \

View file

@ -0,0 +1,13 @@
package main
import . "./li_cdata_cpp"
func main() {
s := "ABC abc"
m := Malloc(256)
Memmove(m, s, len(s))
ss := Cdata(m, 7)
if string(ss) != "ABC abc" {
panic("failed")
}
}

View file

@ -0,0 +1,24 @@
import li_cdata_cpp.*;
public class li_cdata_cpp_runme {
static {
try {
System.loadLibrary("li_cdata_cpp");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) throws Throwable
{
byte[] s = "ABC abc".getBytes();
SWIGTYPE_p_void m = li_cdata_cpp.malloc(256);
li_cdata_cpp.memmove(m, s);
byte[] ss = li_cdata_cpp.cdata(m, 7);
String ss_string = new String(ss);
if (!ss_string.equals("ABC abc"))
throw new RuntimeException("failed got: " + ss_string);
}
}

View file

@ -0,0 +1,8 @@
%module li_cdata_cpp
%include <cdata.i>
%cdata(int);
%cdata(double);
void *malloc(size_t size);

View file

@ -0,0 +1,9 @@
from li_cdata_cpp import *
s = "ABC abc"
m = malloc(256)
memmove(m, s)
ss = cdata(m, 7)
if ss != "ABC abc":
raise "failed"