crate::ix!();
#[inline]
pub fn sanity_test_widen(testchar: u8) -> bool {
trace!(
target: "compat::glibcxx_sanity",
func = "sanity_test_widen",
testchar = testchar
);
let wide = char::from(testchar); let narrow = wide as u32 as u8;
let ok = narrow == testchar;
debug!(
target: "compat::glibcxx_sanity",
func = "sanity_test_widen",
result = ok
);
ok
}
#[inline]
pub fn sanity_test_list(size: u32) -> bool {
trace!(
target: "compat::glibcxx_sanity",
func = "sanity_test_list",
size = size
);
let mut lst: LinkedList<u32> = LinkedList::new();
for i in 0..size {
lst.push_back(i + 1);
}
if lst.len() as u32 != size {
return false;
}
while let Some(back) = lst.back().copied() {
if back != lst.len() as u32 {
return false;
}
lst.pop_back();
}
true
}
#[inline]
pub fn sanity_test_range_fmt() -> bool {
trace!(
target: "compat::glibcxx_sanity",
func = "sanity_test_range_fmt"
);
let ok = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
let s = String::new();
let _ = s.chars().nth(1).unwrap();
}))
.is_err();
debug!(
target: "compat::glibcxx_sanity",
func = "sanity_test_range_fmt",
result = ok
);
ok
}
#[inline]
pub fn glibcxx_sanity_test() -> bool {
sanity_test_widen(b'a')
&& sanity_test_list(100)
&& sanity_test_range_fmt()
}