1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-15 19:36:16 +00:00

chore: standardize creation of empty strings

This commit is contained in:
Daniel Hofstetter 2022-11-30 10:37:59 +01:00
parent efa0fd498b
commit 9a2174ba02
15 changed files with 48 additions and 48 deletions

View file

@ -1174,7 +1174,7 @@ fn test_ls_long_symlink_color() {
captures.get(1).unwrap().as_str().to_string(),
captures.get(2).unwrap().as_str().to_string(),
),
None => ("".to_string(), input.to_string()),
None => (String::new(), input.to_string()),
}
}

View file

@ -57,7 +57,7 @@ fn test_long_format_multiple_users() {
// and an account that (probably) doesn't exist
let runner = match std::env::var("USER") {
Ok(user) => user,
Err(_) => "".to_string(),
Err(_) => String::new(),
};
let args = ["-l", "root", "root", "root", &runner, "no_such_user"];
let ts = TestScenario::new(util_name!());

View file

@ -2485,8 +2485,8 @@ fn test_follow_inotify_only_regular() {
p.kill().unwrap();
let (buf_stdout, buf_stderr) = take_stdout_stderr(&mut p);
assert_eq!(buf_stdout, "".to_string());
assert_eq!(buf_stderr, "".to_string());
assert_eq!(buf_stdout, String::new());
assert_eq!(buf_stderr, String::new());
}
fn take_stdout_stderr(p: &mut std::process::Child) -> (String, String) {

View file

@ -127,7 +127,7 @@ impl RandomString {
D: Distribution<u8>,
{
if length == 0 {
return String::from("");
return String::new();
} else if length == 1 {
return if num_delimiter > 0 {
String::from(delimiter as char)

View file

@ -747,7 +747,7 @@ impl AtPath {
log_info("resolve_link", self.plus_as_string(path));
match fs::read_link(self.plus(path)) {
Ok(p) => self.minus_as_string(p.to_str().unwrap()),
Err(_) => "".to_string(),
Err(_) => String::new(),
}
}
@ -1483,7 +1483,7 @@ mod tests {
#[test]
fn test_code_is() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: Some(32),
@ -1498,7 +1498,7 @@ mod tests {
#[should_panic]
fn test_code_is_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: Some(32),
@ -1512,7 +1512,7 @@ mod tests {
#[test]
fn test_failure() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1527,7 +1527,7 @@ mod tests {
#[should_panic]
fn test_failure_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1541,7 +1541,7 @@ mod tests {
#[test]
fn test_success() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1556,7 +1556,7 @@ mod tests {
#[should_panic]
fn test_success_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1570,7 +1570,7 @@ mod tests {
#[test]
fn test_no_stderr_output() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1586,7 +1586,7 @@ mod tests {
#[should_panic]
fn test_no_stderr_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1602,7 +1602,7 @@ mod tests {
#[should_panic]
fn test_no_stdout_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1617,7 +1617,7 @@ mod tests {
#[test]
fn test_std_does_not_contain() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1633,7 +1633,7 @@ mod tests {
#[should_panic]
fn test_stdout_does_not_contain_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1649,7 +1649,7 @@ mod tests {
#[should_panic]
fn test_stderr_does_not_contain_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1664,7 +1664,7 @@ mod tests {
#[test]
fn test_stdout_matches() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1682,7 +1682,7 @@ mod tests {
#[should_panic]
fn test_stdout_matches_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1699,7 +1699,7 @@ mod tests {
#[should_panic]
fn test_stdout_not_matches_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1715,7 +1715,7 @@ mod tests {
#[test]
fn test_normalized_newlines_stdout_is() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,
@ -1733,7 +1733,7 @@ mod tests {
#[should_panic]
fn test_normalized_newlines_stdout_is_fail() {
let res = CmdResult {
bin_path: "".into(),
bin_path: String::new(),
util_name: None,
tmpd: None,
code: None,