Skip to content

Commit 585d5c1

Browse files
committed
Add integration tests for functions taking array parameters
1 parent d223b2f commit 585d5c1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

integration-tests/tests/integration_test.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5001,6 +5001,43 @@ fn test_take_array_in_struct() {
50015001
run_test("", hdr, rs, &["take_array"], &["data"]);
50025002
}
50035003

5004+
#[test]
5005+
fn test_take_struct_built_array_in_function() {
5006+
let hdr = indoc! {"
5007+
#include <cstdint>
5008+
struct data {
5009+
char a[4];
5010+
};
5011+
uint32_t take_array(char a[4]) {
5012+
return a[0] + a[2];
5013+
}
5014+
"};
5015+
let rs = quote! {
5016+
let mut c = ffi::data { a: [ 10, 20, 30, 40 ] };
5017+
unsafe {
5018+
assert_eq!(ffi::take_array(c.a.as_mut_ptr()), 40);
5019+
}
5020+
};
5021+
run_test("", hdr, rs, &["take_array"], &["data"]);
5022+
}
5023+
5024+
#[test]
5025+
fn test_take_array_in_function() {
5026+
let hdr = indoc! {"
5027+
#include <cstdint>
5028+
uint32_t take_array(char a[4]) {
5029+
return a[0] + a[2];
5030+
}
5031+
"};
5032+
let rs = quote! {
5033+
let mut a: [i8; 4] = [ 10, 20, 30, 40 ];
5034+
unsafe {
5035+
assert_eq!(ffi::take_array(a.as_mut_ptr()), 40);
5036+
}
5037+
};
5038+
run_test("", hdr, rs, &["take_array"], &[]);
5039+
}
5040+
50045041
#[test]
50055042
fn test_union_ignored() {
50065043
let hdr = indoc! {"

0 commit comments

Comments
 (0)