From 4c60ff5085f2572271c7626e62869b3f906a350a Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Tue, 29 Nov 2022 13:43:06 -0600 Subject: [PATCH] Add test for global variables --- test/c/ffi_test.c | 2 +- test/clj/coffi/ffi_test.clj | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/c/ffi_test.c b/test/c/ffi_test.c index 8235c1b..c689e87 100644 --- a/test/c/ffi_test.c +++ b/test/c/ffi_test.c @@ -26,7 +26,7 @@ CString upcall_test(StringFactory fun) { return fun(); } -static int counter = 0; +int counter = 0; static char* responses[] = { "Hello, world!", "Goodbye friend.", "co'oi prenu" }; diff --git a/test/clj/coffi/ffi_test.clj b/test/clj/coffi/ffi_test.clj index d7be985..15cc4b6 100644 --- a/test/clj/coffi/ffi_test.clj +++ b/test/clj/coffi/ffi_test.clj @@ -44,3 +44,8 @@ {:a \x :x 3.14 :y 42.0}))) + +(t/deftest static-variables-are-mutable + (ffi/freset! (ffi/static-variable "counter" ::mem/int) 1) + (t/is (= ((ffi/cfn "get_string1" [] ::mem/c-string)) + "Goodbye friend.")))