Skip to content

Commit fe9bea0

Browse files
elichaiemilio
authored andcommitted
Added tests with typedef for array pointers
1 parent fc762a5 commit fe9bea0

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

tests/expectations/tests/with_array_pointers_arguments.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
)]
99

1010
extern "C" {
11-
pub fn test_fn(
12-
a: f32,
13-
arr: *mut [::std::os::raw::c_int; 20usize],
14-
) -> ::std::os::raw::c_int;
11+
pub fn test_fn(a: f32, arr: *mut [::std::os::raw::c_int; 20usize]) -> ::std::os::raw::c_int;
1512
}
1613
extern "C" {
17-
pub fn test_fn2(
18-
arr: *const [f32; 20usize],
19-
b: ::std::os::raw::c_int,
20-
) -> ::std::os::raw::c_int;
21-
}
14+
pub fn test_fn2(arr: *const [f32; 20usize], b: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
15+
}
16+
pub type defArr = [::std::os::raw::c_char; 20usize];
17+
pub type foo = ::std::option::Option<unsafe extern "C" fn(a: *mut defArr)>;
18+
extern "C" {
19+
pub fn bar(a: *mut defArr);
20+
}

tests/expectations/tests/without_array_pointers_arguments.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
)]
99

1010
extern "C" {
11-
pub fn test_fn(
12-
a: f32,
13-
arr: *mut ::std::os::raw::c_int,
14-
) -> ::std::os::raw::c_int;
11+
pub fn test_fn(a: f32, arr: *mut ::std::os::raw::c_int) -> ::std::os::raw::c_int;
1512
}
1613
extern "C" {
17-
pub fn test_fn2(
18-
arr: *const f32,
19-
b: ::std::os::raw::c_int,
20-
) -> ::std::os::raw::c_int;
21-
}
14+
pub fn test_fn2(arr: *const f32, b: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
15+
}
16+
pub type defArr = [::std::os::raw::c_char; 20usize];
17+
pub type foo = ::std::option::Option<unsafe extern "C" fn(a: *mut ::std::os::raw::c_char)>;
18+
extern "C" {
19+
pub fn bar(a: *mut ::std::os::raw::c_char);
20+
}

tests/headers/with_array_pointers_arguments.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22

33
int test_fn(float a, int arr[20]);
44

5-
int test_fn2(const float arr[20], int b);
5+
int test_fn2(const float arr[20], int b);
6+
7+
typedef char defArr[20];
8+
typedef void foo(defArr a);
9+
10+
void bar(defArr a);
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

22
int test_fn(float a, int arr[20]);
33

4-
int test_fn2(const float arr[20], int b);
4+
int test_fn2(const float arr[20], int b);
5+
6+
typedef char defArr[20];
7+
typedef void foo(defArr a);
8+
9+
void bar(defArr a);

0 commit comments

Comments
 (0)