Skip to content

Commit f2d41fd

Browse files
committed
fix generating invalid utf8 ostring
1 parent 418d016 commit f2d41fd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

asyncgit/src/sync/hooks.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ mod tests {
8484

8585
fn repo_init() -> Result<(TempDir, Repository)> {
8686
const INVALID_UTF8: &[u8] = b"\xED\xA0\x80";
87+
8788
let mut os_string: OsString = OsString::new();
8889

8990
os_string.push("gitui $# ' ");
@@ -92,14 +93,16 @@ mod tests {
9293
{
9394
use std::os::windows::ffi::OsStringExt;
9495

95-
const INVALID_UTF8: &[u16] =
96-
INVALID_UTF8.map(|b| b as u16);
96+
let invalid_utf8 = INVALID_UTF8
97+
.into_iter()
98+
.map(|b| b as u16)
99+
.collect::<Vec<u16>>();
97100

98-
os_str.push(OsString::from_wide(INVALID_UTF8));
101+
os_string.push(OsString::from_wide(&invalid_utf8));
99102

100103
assert!(os_string.to_str().is_none());
101104
}
102-
#[cfg(unix)]
105+
#[cfg(target_os = "linux")]
103106
{
104107
use std::os::unix::ffi::OsStrExt;
105108

0 commit comments

Comments
 (0)