Skip to content

Commit 50085d7

Browse files
committed
printenv: add a test for non-utf-8 var
Like in : 5d4abd8
1 parent 6a3b559 commit 50085d7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/by-util/test_printenv.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,16 @@ fn test_non_utf8_value() {
117117
);
118118
result.stdout_is_bytes(b"/tmp/lib.so\xff\n");
119119
}
120+
121+
#[test]
122+
#[cfg(unix)]
123+
fn test_non_utf8_env_vars() {
124+
use std::ffi::OsString;
125+
use std::os::unix::ffi::OsStringExt;
126+
127+
let non_utf8_value = OsString::from_vec(b"hello\x80world".to_vec());
128+
new_ucmd!()
129+
.env("NON_UTF8_VAR", &non_utf8_value)
130+
.succeeds()
131+
.stdout_contains_bytes(b"NON_UTF8_VAR=hello\x80world");
132+
}

0 commit comments

Comments
 (0)