
* Add rawmemchr * Add stpncpy * Add strchrnul * Fix strcat * Added strncat * Add wcschr * Minor tweak * Add wcsncmp * Add wcsnlen * Add wcsrchr * Add wmemchr * Fix asan load/store sizes for wide string functions * Refactor patches * Rename tracking functions to prevent collision with allocator * Change return type of asan_sym to make it consistent with the other native functions * Fix mutex re-entrancy issue in Patches by splitting locks * Fix tests on 32-bit platforms --------- Co-authored-by: Your Name <you@example.com>
43 lines
1.0 KiB
Rust
43 lines
1.0 KiB
Rust
#[cfg(test)]
|
|
#[cfg(feature = "hooks")]
|
|
mod tests {
|
|
use core::ptr::null;
|
|
|
|
use asan::{expect_panic, hooks::wcsnlen::wcsnlen, wchar_t};
|
|
use widestring::widecstr;
|
|
|
|
#[test]
|
|
fn test_wcsnlen_zero_length() {
|
|
let ret = unsafe { wcsnlen(null() as *const wchar_t, 0) };
|
|
assert_eq!(ret, 0);
|
|
}
|
|
|
|
#[test]
|
|
fn test_wcsnlen_cs_null() {
|
|
expect_panic();
|
|
unsafe { wcsnlen(null() as *const wchar_t, 10) };
|
|
unreachable!();
|
|
}
|
|
|
|
#[test]
|
|
fn test_wcsnlen_cs_empty() {
|
|
let data = widecstr!("");
|
|
let ret = unsafe { wcsnlen(data.as_ptr() as *const wchar_t, 10) };
|
|
assert_eq!(ret, 0);
|
|
}
|
|
|
|
#[test]
|
|
fn test_wcsnlen_full() {
|
|
let data = widecstr!("abcdefghij");
|
|
let ret = unsafe { wcsnlen(data.as_ptr() as *const wchar_t, data.len()) };
|
|
assert_eq!(ret, 10);
|
|
}
|
|
|
|
#[test]
|
|
fn test_wcsnlen_partial() {
|
|
let data = widecstr!("abcdefghij");
|
|
let ret = unsafe { wcsnlen(data.as_ptr() as *const wchar_t, 5) };
|
|
assert_eq!(ret, 5);
|
|
}
|
|
}
|