From 0bf267e44ad0460f246caae7fdc6589fa4d4d1f4 Mon Sep 17 00:00:00 2001 From: Kristin Rutenkolk Date: Tue, 23 Jul 2024 15:35:21 +0200 Subject: [PATCH] add more failing test cases --- test/c/ffi_test.c | 3 ++- test/clj/coffi/ffi_test.clj | 4 ++-- test/clj/coffi/mem_test.clj | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 test/clj/coffi/mem_test.clj diff --git a/test/c/ffi_test.c b/test/c/ffi_test.c index 8c98f48..e38ff30 100644 --- a/test/c/ffi_test.c +++ b/test/c/ffi_test.c @@ -73,7 +73,8 @@ AlignmentTest get_struct() { } void test_call_with_trailing_string_arg(int a, int b, char* text) { - printf("call of `test_call_with_trailing_string_arg` with a=%i b=%i text='%s'",a,b,text); + printf("call of `test_call_with_trailing_string_arg` with a=%i b=%i text='%s'",1,2,text); + printf("\r "); return; } diff --git a/test/clj/coffi/ffi_test.clj b/test/clj/coffi/ffi_test.clj index 45c1930..d45e3ae 100644 --- a/test/clj/coffi/ffi_test.clj +++ b/test/clj/coffi/ffi_test.clj @@ -66,5 +66,5 @@ ((ffi/cfn "test_call_with_trailing_string_arg" [::mem/int ::mem/int ::mem/c-string] ::mem/void) - 1 2 "third arg") - ))) + 1 2 "third arg")))) + diff --git a/test/clj/coffi/mem_test.clj b/test/clj/coffi/mem_test.clj new file mode 100644 index 0000000..b52c1eb --- /dev/null +++ b/test/clj/coffi/mem_test.clj @@ -0,0 +1,32 @@ +(ns coffi.mem-test + (:require + [clojure.test :as t] + [coffi.ffi :as ffi] + [coffi.layout :as layout] + [coffi.mem :as mem]) + (:import + (java.lang.foreign + AddressLayout + Arena + MemoryLayout + MemorySegment + MemorySegment$Scope + SegmentAllocator + ValueLayout + ValueLayout$OfByte + ValueLayout$OfShort + ValueLayout$OfInt + ValueLayout$OfLong + ValueLayout$OfChar + ValueLayout$OfFloat + ValueLayout$OfDouble) + (java.lang.ref Cleaner) + (java.nio ByteOrder))) + +(ffi/load-library "target/ffi_test.so") + +(t/deftest can-serialize-string + (t/is + (instance? MemorySegment (mem/serialize "this is a string" ::mem/c-string)))) + +