@@ -7,36 +7,36 @@ const std = @import("std");
77const testing = std .testing ;
88
99// Import FFI functions
10- extern fn {{ project }} _init () ? * opaque {};
11- extern fn {{ project }} _free (? * opaque {}) void ;
12- extern fn {{ project }} _process (? * opaque {}, u32 ) c_int ;
13- extern fn {{ project }} _get_string (? * opaque {}) ? [* :0 ]const u8 ;
14- extern fn {{ project }} _free_string (? [* :0 ]const u8 ) void ;
15- extern fn {{ project }} _last_error () ? [* :0 ]const u8 ;
16- extern fn {{ project }} _version () [* :0 ]const u8 ;
17- extern fn {{ project }} _is_initialized (? * opaque {}) u32 ;
10+ extern fn panel_clades_init () ? * opaque {};
11+ extern fn panel_clades_free (? * opaque {}) void ;
12+ extern fn panel_clades_process (? * opaque {}, u32 ) c_int ;
13+ extern fn panel_clades_get_string (? * opaque {}) ? [* :0 ]const u8 ;
14+ extern fn panel_clades_free_string (? [* :0 ]const u8 ) void ;
15+ extern fn panel_clades_last_error () ? [* :0 ]const u8 ;
16+ extern fn panel_clades_version () [* :0 ]const u8 ;
17+ extern fn panel_clades_is_initialized (? * opaque {}) u32 ;
1818
1919//==============================================================================
2020// Lifecycle Tests
2121//==============================================================================
2222
2323test "create and destroy handle" {
24- const handle = {{ project }} _init () orelse return error .InitFailed ;
25- defer {{ project }} _free (handle );
24+ const handle = panel_clades_init () orelse return error .InitFailed ;
25+ defer panel_clades_free (handle );
2626
2727 try testing .expect (handle != null );
2828}
2929
3030test "handle is initialized" {
31- const handle = {{ project }} _init () orelse return error .InitFailed ;
32- defer {{ project }} _free (handle );
31+ const handle = panel_clades_init () orelse return error .InitFailed ;
32+ defer panel_clades_free (handle );
3333
34- const initialized = {{ project }} _is_initialized (handle );
34+ const initialized = panel_clades_is_initialized (handle );
3535 try testing .expectEqual (@as (u32 , 1 ), initialized );
3636}
3737
3838test "null handle is not initialized" {
39- const initialized = {{ project }} _is_initialized (null );
39+ const initialized = panel_clades_is_initialized (null );
4040 try testing .expectEqual (@as (u32 , 0 ), initialized );
4141}
4242
@@ -45,15 +45,15 @@ test "null handle is not initialized" {
4545//==============================================================================
4646
4747test "process with valid handle" {
48- const handle = {{ project }} _init () orelse return error .InitFailed ;
49- defer {{ project }} _free (handle );
48+ const handle = panel_clades_init () orelse return error .InitFailed ;
49+ defer panel_clades_free (handle );
5050
51- const result = {{ project }} _process (handle , 42 );
51+ const result = panel_clades_process (handle , 42 );
5252 try testing .expectEqual (@as (c_int , 0 ), result ); // 0 = ok
5353}
5454
5555test "process with null handle returns error" {
56- const result = {{ project }} _process (null , 42 );
56+ const result = panel_clades_process (null , 42 );
5757 try testing .expectEqual (@as (c_int , 4 ), result ); // 4 = null_pointer
5858}
5959
@@ -62,17 +62,17 @@ test "process with null handle returns error" {
6262//==============================================================================
6363
6464test "get string result" {
65- const handle = {{ project }} _init () orelse return error .InitFailed ;
66- defer {{ project }} _free (handle );
65+ const handle = panel_clades_init () orelse return error .InitFailed ;
66+ defer panel_clades_free (handle );
6767
68- const str = {{ project }} _get_string (handle );
69- defer if (str ) | s | {{ project }} _free_string (s );
68+ const str = panel_clades_get_string (handle );
69+ defer if (str ) | s | panel_clades_free_string (s );
7070
7171 try testing .expect (str != null );
7272}
7373
7474test "get string with null handle" {
75- const str = {{ project }} _get_string (null );
75+ const str = panel_clades_get_string (null );
7676 try testing .expect (str == null );
7777}
7878
@@ -81,9 +81,9 @@ test "get string with null handle" {
8181//==============================================================================
8282
8383test "last error after null handle operation" {
84- _ = {{ project }} _process (null , 0 );
84+ _ = panel_clades_process (null , 0 );
8585
86- const err = {{ project }} _last_error ();
86+ const err = panel_clades_last_error ();
8787 try testing .expect (err != null );
8888
8989 if (err ) | e | {
@@ -93,10 +93,10 @@ test "last error after null handle operation" {
9393}
9494
9595test "no error after successful operation" {
96- const handle = {{ project }} _init () orelse return error .InitFailed ;
97- defer {{ project }} _free (handle );
96+ const handle = panel_clades_init () orelse return error .InitFailed ;
97+ defer panel_clades_free (handle );
9898
99- _ = {{ project }} _process (handle , 0 );
99+ _ = panel_clades_process (handle , 0 );
100100
101101 // Error should be cleared after successful operation
102102 // (This depends on implementation)
@@ -107,14 +107,14 @@ test "no error after successful operation" {
107107//==============================================================================
108108
109109test "version string is not empty" {
110- const ver = {{ project }} _version ();
110+ const ver = panel_clades_version ();
111111 const ver_str = std .mem .span (ver );
112112
113113 try testing .expect (ver_str .len > 0 );
114114}
115115
116116test "version string is semantic version format" {
117- const ver = {{ project }} _version ();
117+ const ver = panel_clades_version ();
118118 const ver_str = std .mem .span (ver );
119119
120120 // Should be in format X.Y.Z
@@ -126,37 +126,37 @@ test "version string is semantic version format" {
126126//==============================================================================
127127
128128test "multiple handles are independent" {
129- const h1 = {{ project }} _init () orelse return error .InitFailed ;
130- defer {{ project }} _free (h1 );
129+ const h1 = panel_clades_init () orelse return error .InitFailed ;
130+ defer panel_clades_free (h1 );
131131
132- const h2 = {{ project }} _init () orelse return error .InitFailed ;
133- defer {{ project }} _free (h2 );
132+ const h2 = panel_clades_init () orelse return error .InitFailed ;
133+ defer panel_clades_free (h2 );
134134
135135 try testing .expect (h1 != h2 );
136136
137137 // Operations on h1 should not affect h2
138- _ = {{ project }} _process (h1 , 1 );
139- _ = {{ project }} _process (h2 , 2 );
138+ _ = panel_clades_process (h1 , 1 );
139+ _ = panel_clades_process (h2 , 2 );
140140}
141141
142142test "double free is safe" {
143- const handle = {{ project }} _init () orelse return error .InitFailed ;
143+ const handle = panel_clades_init () orelse return error .InitFailed ;
144144
145- {{ project }} _free (handle );
146- {{ project }} _free (handle ); // Should not crash
145+ panel_clades_free (handle );
146+ panel_clades_free (handle ); // Should not crash
147147}
148148
149149test "free null is safe" {
150- {{ project }} _free (null ); // Should not crash
150+ panel_clades_free (null ); // Should not crash
151151}
152152
153153//==============================================================================
154154// Thread Safety Tests (if applicable)
155155//==============================================================================
156156
157157test "concurrent operations" {
158- const handle = {{ project }} _init () orelse return error .InitFailed ;
159- defer {{ project }} _free (handle );
158+ const handle = panel_clades_init () orelse return error .InitFailed ;
159+ defer panel_clades_free (handle );
160160
161161 const ThreadContext = struct {
162162 h : * opaque {},
@@ -165,7 +165,7 @@ test "concurrent operations" {
165165
166166 const thread_fn = struct {
167167 fn run (ctx : ThreadContext ) void {
168- _ = {{ project }} _process (ctx .h , ctx .id );
168+ _ = panel_clades_process (ctx .h , ctx .id );
169169 }
170170 }.run ;
171171
0 commit comments