diff --git a/test/c/ffi_test.c b/test/c/ffi_test.c index d0d4c03..8c98f48 100644 --- a/test/c/ffi_test.c +++ b/test/c/ffi_test.c @@ -39,35 +39,41 @@ char* upcall_test_int_fn_string_ret(int (*f)(void)) { } CString get_string1(void) { - return responses[counter++ % 3]; + return responses[counter++ % 3]; } CString get_string2(void) { - return "Alternate string"; + return "Alternate string"; } StringFactory get_downcall(int whichString) { - switch (whichString % 2) { - case 0: - return get_string1; - case 1: - return get_string2; - default: - return 0; - } + switch (whichString % 2) { + case 0: + return get_string1; + case 1: + return get_string2; + default: + return 0; + } } typedef struct alignment_test { - char a; - double x; - float y; + char a; + double x; + float y; } AlignmentTest; AlignmentTest get_struct() { - AlignmentTest ret = {}; - ret.a = 'x'; - ret.x = 3.14; - ret.y = 42.0; + AlignmentTest ret = {}; + ret.a = 'x'; + ret.x = 3.14; + ret.y = 42.0; - return ret; + return ret; } + +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); + return; +} + diff --git a/test/clj/coffi/ffi_test.clj b/test/clj/coffi/ffi_test.clj index ac075e4..45c1930 100644 --- a/test/clj/coffi/ffi_test.clj +++ b/test/clj/coffi/ffi_test.clj @@ -59,3 +59,12 @@ (ffi/freset! (ffi/static-variable "counter" ::mem/int) 1) (t/is (= ((ffi/cfn "get_string1" [] ::mem/c-string)) "Goodbye friend."))) + +(t/deftest can-call-with-trailing-string-arg + (t/is + (= + ((ffi/cfn "test_call_with_trailing_string_arg" + [::mem/int ::mem/int ::mem/c-string] + ::mem/void) + 1 2 "third arg") + )))