Resolve invalid_utf8_in_unchecked clippy lint in ancient test code
error: non UTF-8 literal in `std::str::from_utf8_unchecked` --> test_suite/tests/test_ser.rs:803:25 | 803 | let path = unsafe { str::from_utf8_unchecked(b"Hello \xF0\x90\x80World") }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::invalid-utf8-in-unchecked` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#invalid_utf8_in_unchecked
This commit is contained in:
parent
7cc6f7fbb0
commit
a0eb83a5d4
@ -800,17 +800,14 @@ fn test_never_result() {
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_cannot_serialize_paths() {
|
||||
let path = unsafe { str::from_utf8_unchecked(b"Hello \xF0\x90\x80World") };
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
assert_ser_tokens_error(
|
||||
&Path::new(path),
|
||||
&Path::new(OsStr::from_bytes(b"Hello \xF0\x90\x80World")),
|
||||
&[],
|
||||
"path contains invalid UTF-8 characters",
|
||||
);
|
||||
|
||||
let mut path_buf = PathBuf::new();
|
||||
path_buf.push(path);
|
||||
|
||||
assert_ser_tokens_error(&path_buf, &[], "path contains invalid UTF-8 characters");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user