mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 23:29:50 +00:00
Adding tests for functions in other namespaces.
This commit is contained in:
parent
d47af7a9d3
commit
ddc146ef9f
@ -46,5 +46,10 @@ pub mod ffi2 {
|
||||
fn c_return_ns_opaque_ptr() -> UniquePtr<F>;
|
||||
fn c_return_ns_unique_ptr() -> UniquePtr<H>;
|
||||
fn c_take_ref_ns_c(h: &H);
|
||||
|
||||
#[namespace (namespace = other)]
|
||||
fn ns_c_take_trivial(d: D);
|
||||
#[namespace (namespace = other)]
|
||||
fn ns_c_return_trivial() -> D;
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +199,9 @@ pub mod ffi {
|
||||
fn cOverloadedFunction(x: i32) -> String;
|
||||
#[rust_name = "str_overloaded_function"]
|
||||
fn cOverloadedFunction(x: &str) -> String;
|
||||
|
||||
#[namespace (namespace = other)]
|
||||
fn ns_c_take_ns_shared(shared: AShared);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -627,3 +627,24 @@ extern "C" const char *cxx_run_test() noexcept {
|
||||
}
|
||||
|
||||
} // namespace tests
|
||||
|
||||
namespace other {
|
||||
|
||||
void ns_c_take_trivial(::tests::D d) {
|
||||
if (d.d == 30) {
|
||||
cxx_test_suite_set_correct();
|
||||
}
|
||||
}
|
||||
|
||||
::tests::D ns_c_return_trivial() {
|
||||
::tests::D d;
|
||||
d.d = 30;
|
||||
return d;
|
||||
}
|
||||
|
||||
void ns_c_take_ns_shared(::A::AShared shared) {
|
||||
if (shared.z == 2020) {
|
||||
cxx_test_suite_set_correct();
|
||||
}
|
||||
}
|
||||
}
|
@ -177,3 +177,9 @@ rust::String cOverloadedFunction(int32_t x);
|
||||
rust::String cOverloadedFunction(rust::Str x);
|
||||
|
||||
} // namespace tests
|
||||
|
||||
namespace other {
|
||||
void ns_c_take_trivial(::tests::D d);
|
||||
::tests::D ns_c_return_trivial();
|
||||
void ns_c_take_ns_shared(::A::AShared shared);
|
||||
} // namespace other
|
@ -103,6 +103,7 @@ fn test_c_take() {
|
||||
check!(ffi::c_take_primitive(2020));
|
||||
check!(ffi::c_take_shared(ffi::Shared { z: 2020 }));
|
||||
check!(ffi::c_take_ns_shared(ffi::AShared { z: 2020 }));
|
||||
check!(ffi::ns_c_take_ns_shared(ffi::AShared { z: 2020 }));
|
||||
check!(ffi::c_take_nested_ns_shared(ffi::ABShared { z: 2020 }));
|
||||
check!(ffi::c_take_box(Box::new(2020)));
|
||||
check!(ffi::c_take_ref_c(&unique_ptr));
|
||||
@ -226,6 +227,8 @@ fn test_extern_trivial() {
|
||||
let d = ffi2::c_return_trivial_ptr();
|
||||
check!(ffi2::c_take_trivial_ptr(d));
|
||||
cxx::UniquePtr::new(ffi2::D { d: 42 });
|
||||
let d = ffi2::ns_c_return_trivial();
|
||||
check!(ffi2::ns_c_take_trivial(d));
|
||||
|
||||
let g = ffi2::c_return_trivial_ns();
|
||||
check!(ffi2::c_take_trivial_ns_ref(&g));
|
||||
|
Loading…
Reference in New Issue
Block a user