test(src/types/newtypes): Test if a full round-trip works
This commit is contained in:
parent
1599631431
commit
7bced94bdd
|
@ -108,3 +108,34 @@ impl Drop for String {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::types::types_list;
|
||||
|
||||
use super::String;
|
||||
|
||||
#[test]
|
||||
fn test_string_round_trip() {
|
||||
let start = "HI! I'm a nice string".to_owned();
|
||||
let wrapper: String = start.clone().into();
|
||||
|
||||
assert_eq!(&start, wrapper.as_str());
|
||||
assert_eq!(start, wrapper.to_string());
|
||||
assert_eq!(start, wrapper.into_std_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_round_trip_through_c() {
|
||||
let start = "HI! I'm a nice string".to_owned();
|
||||
|
||||
let c_string: types_list::String = start.clone().into();
|
||||
let wrapper: String = Into::<types_list::String>::into(c_string)
|
||||
.try_into()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(&start, wrapper.as_str());
|
||||
assert_eq!(start, wrapper.to_string());
|
||||
assert_eq!(start, wrapper.into_std_string());
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue