mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2025-02-17 15:09:41 +00:00
Add test involving empty vector
This commit is contained in:
parent
a5a14ce158
commit
80631e93ef
@ -145,6 +145,7 @@ pub mod ffi {
|
||||
fn r_take_rust_string(s: String);
|
||||
fn r_take_unique_ptr_string(s: UniquePtr<CxxString>);
|
||||
fn r_take_ref_vector(v: &CxxVector<u8>);
|
||||
fn r_take_ref_empty_vector(v: &CxxVector<u64>);
|
||||
fn r_take_rust_vec(v: Vec<u8>);
|
||||
fn r_take_rust_vec_string(v: Vec<String>);
|
||||
fn r_take_ref_rust_vec(v: &Vec<u8>);
|
||||
@ -313,6 +314,11 @@ fn r_take_ref_vector(v: &CxxVector<u8>) {
|
||||
assert_eq!(slice, [20, 2, 0]);
|
||||
}
|
||||
|
||||
fn r_take_ref_empty_vector(v: &CxxVector<u64>) {
|
||||
assert!(v.as_slice().is_empty());
|
||||
assert!(v.is_empty());
|
||||
}
|
||||
|
||||
fn r_take_rust_vec(v: Vec<u8>) {
|
||||
let _ = v;
|
||||
}
|
||||
|
@ -400,6 +400,10 @@ extern "C" const char *cxx_run_test() noexcept {
|
||||
r_take_unique_ptr_string(
|
||||
std::unique_ptr<std::string>(new std::string("2020")));
|
||||
r_take_ref_vector(std::vector<uint8_t>{20, 2, 0});
|
||||
std::vector<uint64_t> empty_vector;
|
||||
r_take_ref_empty_vector(empty_vector);
|
||||
empty_vector.reserve(10);
|
||||
r_take_ref_empty_vector(empty_vector);
|
||||
r_take_enum(Enum::AVal);
|
||||
|
||||
ASSERT(r_try_return_primitive() == 2020);
|
||||
|
Loading…
x
Reference in New Issue
Block a user