mirror of
https://github.com/openharmony/third_party_rust_os_str_bytes.git
synced 2026-07-20 01:23:35 -04:00
35 lines
697 B
Rust
35 lines
697 B
Rust
#![cfg(feature = "raw_os_str")]
|
|
|
|
use os_str_bytes::RawOsStr;
|
|
|
|
mod raw_common;
|
|
use raw_common::RAW_WTF8_STRING;
|
|
|
|
fn test(result: &str, string: &RawOsStr) {
|
|
assert_eq!(format!("RawOsStr({})", result), format!("{:?}", string));
|
|
assert_eq!(
|
|
format!("RawOsString({})", result),
|
|
format!("{:?}", string.to_owned()),
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn test_empty() {
|
|
test("\"\"", RawOsStr::from_str(""));
|
|
}
|
|
|
|
#[test]
|
|
fn test_wft8() {
|
|
let wchar = if cfg!(unix) {
|
|
"\\xED\\xA0\\xBD"
|
|
} else {
|
|
"\\u{D83D}"
|
|
};
|
|
test(&format!("\"foo{}\u{1F4A9}bar\"", wchar), RAW_WTF8_STRING);
|
|
}
|
|
|
|
#[test]
|
|
fn test_quote() {
|
|
test("\"foo\\\"bar\"", RawOsStr::from_str("foo\"bar"));
|
|
}
|