mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-24 07:40:19 +00:00
Test Debug impls
This commit is contained in:
parent
f84c98bdb7
commit
990eb3cf82
@ -15,7 +15,7 @@ use std::os::raw::c_char;
|
|||||||
|
|
||||||
#[cxx::bridge(namespace = "tests")]
|
#[cxx::bridge(namespace = "tests")]
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
struct Shared {
|
struct Shared {
|
||||||
z: usize,
|
z: usize,
|
||||||
}
|
}
|
||||||
@ -24,6 +24,7 @@ pub mod ffi {
|
|||||||
msg: String,
|
msg: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum Enum {
|
enum Enum {
|
||||||
AVal,
|
AVal,
|
||||||
BVal = 2020,
|
BVal = 2020,
|
||||||
|
@ -227,6 +227,13 @@ fn test_enum_representations() {
|
|||||||
assert_eq!(2021, ffi::Enum::CVal.repr);
|
assert_eq!(2021, ffi::Enum::CVal.repr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_debug() {
|
||||||
|
assert_eq!("Shared { z: 1 }", format!("{:?}", ffi::Shared { z: 1 }));
|
||||||
|
assert_eq!("BVal", format!("{:?}", ffi::Enum::BVal));
|
||||||
|
assert_eq!("Enum(9)", format!("{:?}", ffi::Enum { repr: 9 }));
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn cxx_test_suite_get_box() -> *mut R {
|
extern "C" fn cxx_test_suite_get_box() -> *mut R {
|
||||||
Box::into_raw(Box::new(R(2020usize)))
|
Box::into_raw(Box::new(R(2020usize)))
|
||||||
|
Loading…
Reference in New Issue
Block a user