Test Debug impls

This commit is contained in:
David Tolnay 2020-11-27 11:36:05 -08:00
parent f84c98bdb7
commit 990eb3cf82
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 9 additions and 1 deletions

View File

@ -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,

View File

@ -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)))