diff --git a/tests/by-util/test_basename.rs b/tests/by-util/test_basename.rs index ecbfe6c5d..7ad5008b2 100644 --- a/tests/by-util/test_basename.rs +++ b/tests/by-util/test_basename.rs @@ -278,3 +278,21 @@ fn test_suffix_implies_multiple() { .succeeds() .stdout_is("foo\no\n"); } + +#[test] +fn test_emoji_handling() { + new_ucmd!() + .arg("/path/to/๐Ÿฆ€.txt") + .succeeds() + .stdout_only("๐Ÿฆ€.txt\n"); + + new_ucmd!() + .arg("/๐ŸŒ/path/to/๐Ÿš€.exe") + .succeeds() + .stdout_only("๐Ÿš€.exe\n"); + + new_ucmd!() + .args(&["/path/to/file๐ŸŽฏ.emoji", ".emoji"]) + .succeeds() + .stdout_only("file๐ŸŽฏ\n"); +} diff --git a/tests/by-util/test_comm.rs b/tests/by-util/test_comm.rs index 9c04f39c6..96a1e5497 100644 --- a/tests/by-util/test_comm.rs +++ b/tests/by-util/test_comm.rs @@ -587,3 +587,19 @@ fn test_comm_extra_arg_error() { .stderr_contains("Usage: comm [OPTION]... FILE1 FILE2") .stderr_contains("For more information, try '--help'."); } + +#[test] +fn comm_emoji_sorted_inputs() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.write("file1", "๐Ÿ’\n๐Ÿฆ€\n"); + at.write("file2", "๐Ÿฆ€\n๐Ÿชฝ\n"); + + scene + .ucmd() + .args(&["file1", "file2"]) + .env("LC_ALL", "C.UTF-8") + .succeeds() + .stdout_only("๐Ÿ’\n\t\t๐Ÿฆ€\n\t๐Ÿชฝ\n"); +} diff --git a/tests/by-util/test_dirname.rs b/tests/by-util/test_dirname.rs index 933e882d7..d5aedc45a 100644 --- a/tests/by-util/test_dirname.rs +++ b/tests/by-util/test_dirname.rs @@ -84,3 +84,21 @@ fn test_dirname_non_utf8_paths() { assert!(!output.is_empty()); assert!(output.contains("test_")); } + +#[test] +fn test_emoji_handling() { + new_ucmd!() + .arg("/๐ŸŒ/path/to/๐Ÿฆ€.txt") + .succeeds() + .stdout_is("/๐ŸŒ/path/to\n"); + + new_ucmd!() + .arg("/๐ŸŽ‰/path/to/๐Ÿš€/") + .succeeds() + .stdout_is("/๐ŸŽ‰/path/to\n"); + + new_ucmd!() + .args(&["-z", "/๐ŸŒŸ/emoji/path/๐Ÿฆ‹.file"]) + .succeeds() + .stdout_is("/๐ŸŒŸ/emoji/path\u{0}"); +} diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index ab5b8b1ab..34e60e316 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -785,3 +785,21 @@ fn test_escape_sequence_ctrl_c() { .success() .stdout_only("show"); } + +#[test] +fn test_emoji_output() { + new_ucmd!() + .arg("Hello ๐ŸŒ World ๐Ÿš€") + .succeeds() + .stdout_only("Hello ๐ŸŒ World ๐Ÿš€\n"); + + new_ucmd!() + .args(&["-n", "Status: ๐ŸŽฏ Complete"]) + .succeeds() + .stdout_only("Status: ๐ŸŽฏ Complete"); + + new_ucmd!() + .args(&["๐Ÿฆ€", "loves", "๐Ÿš€", "and", "๐ŸŒŸ"]) + .succeeds() + .stdout_only("๐Ÿฆ€ loves ๐Ÿš€ and ๐ŸŒŸ\n"); +} diff --git a/tests/by-util/test_env.rs b/tests/by-util/test_env.rs index 82cec1889..b2db4a277 100644 --- a/tests/by-util/test_env.rs +++ b/tests/by-util/test_env.rs @@ -1755,6 +1755,17 @@ fn test_simulation_of_terminal_pty_pipes_into_data_and_sends_eot_automatically() std::assert_eq!(String::from_utf8_lossy(out.stderr()), ""); } +#[test] +#[cfg(not(windows))] +fn test_emoji_env_vars() { + new_ucmd!() + .arg("๐ŸŽฏ_VAR=Hello ๐ŸŒ") + .arg("printenv") + .arg("๐ŸŽฏ_VAR") + .succeeds() + .stdout_contains("Hello ๐ŸŒ"); +} + #[cfg(unix)] #[test] fn test_simulation_of_terminal_pty_write_in_data_and_sends_eot_automatically() { diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 729b91290..bd5e19099 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -58,6 +58,16 @@ fn test_simple_arithmetic() { .args(&["4", "/", "2"]) .succeeds() .stdout_only("2\n"); + + new_ucmd!() + .args(&["4", "=", "2"]) + .fails_with_code(1) + .stdout_only("0\n"); + + new_ucmd!() + .args(&["4", "=", "4"]) + .succeeds() + .stdout_only("1\n"); } #[test] @@ -1927,3 +1937,32 @@ mod gnu_expr_multibyte { } } } + +#[test] +fn test_emoji_operations() { + new_ucmd!() + .args(&["๐Ÿš€", "=", "๐Ÿš€"]) + .succeeds() + .stdout_only("1\n"); + + new_ucmd!() + .args(&["๐Ÿš€", "!=", "๐Ÿš€"]) + .fails() + .stdout_only("0\n"); + + new_ucmd!() + .args(&["๐Ÿš€", "=", "๐Ÿงจ"]) + .fails() + .stdout_only("0\n"); + + new_ucmd!() + .args(&["length", "๐Ÿฆ€๐Ÿš€๐ŸŽฏ"]) + .env("LC_ALL", "fr_FR.UTF-8") + .succeeds() + .stdout_only("3\n"); + + new_ucmd!() + .args(&["๐ŸŒ", "!=", "๐ŸŒŽ"]) + .succeeds() + .stdout_only("1\n"); +} diff --git a/tests/by-util/test_fmt.rs b/tests/by-util/test_fmt.rs index abf2e132c..5959569de 100644 --- a/tests/by-util/test_fmt.rs +++ b/tests/by-util/test_fmt.rs @@ -388,3 +388,12 @@ fn test_fmt_non_utf8_paths() { ucmd.arg(&filename).succeeds(); } + +#[test] +fn fmt_reflow_unicode() { + new_ucmd!() + .args(&["-w", "4"]) + .pipe_in("ๆผขๅญ—ๆผขๅญ— ๐Ÿ’ ๆ—ฅๆœฌ่ชžใฎๆ–‡ๅญ—\n") + .succeeds() + .stdout_is("ๆผขๅญ—ๆผขๅญ—\n๐Ÿ’\nๆ—ฅๆœฌ่ชžใฎๆ–‡ๅญ—\n"); +} diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 5e2c0c7a0..a10d5fd18 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -1453,3 +1453,11 @@ fn non_utf_8_input() { .fails() .stderr_contains("expected a numeric value"); } + +#[test] +fn test_emoji_formatting() { + new_ucmd!() + .args(&["Status: %s ๐ŸŽฏ Count: %d\n", "Success ๐Ÿš€", "42"]) + .succeeds() + .stdout_only("Status: Success ๐Ÿš€ ๐ŸŽฏ Count: 42\n"); +} diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index 1e40a2791..3f6455c21 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -4946,3 +4946,12 @@ fn test_dev_zero() { .succeeds() .stdout_only("\0"); } + +#[test] +fn tail_n_lines_with_emoji() { + new_ucmd!() + .args(&["-n", "1"]) + .pipe_in("a\n๐Ÿ’\n") + .succeeds() + .stdout_only("๐Ÿ’\n"); +}