tests(src/types/newtypes): Test if a full round-trip works

This commit is contained in:
Benedikt Peetz 2024-05-04 21:10:35 +02:00
parent c2ef7d0a59
commit 31493968b5
1 changed files with 31 additions and 0 deletions

View File

@ -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());
}
}