From b4e3e66236458a8887341b093dec833101a7df77 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Mon, 9 Jan 2023 22:31:48 -0600 Subject: [PATCH] test/uname ~ test for invisible characters in output (ie, NULs) --- tests/by-util/test_uname.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/by-util/test_uname.rs b/tests/by-util/test_uname.rs index e96721521..a0d20cab6 100644 --- a/tests/by-util/test_uname.rs +++ b/tests/by-util/test_uname.rs @@ -118,3 +118,11 @@ fn test_uname_help() { .succeeds() .stdout_contains("system information"); } + +#[test] +fn test_uname_output_for_invisible_chars() { + // let re = regex::Regex::new("[^[[:print:]]]").unwrap(); // matches invisible (and emojis) + let re = regex::Regex::new("[^[[:print:]]\\p{Other_Symbol}]").unwrap(); // matches invisible (not emojis) + let result = new_ucmd!().arg("--all").succeeds(); + assert_eq!(re.find(result.stdout_str().trim_end()), None); +}