1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

Merge pull request #913 from knight42/pinky

Implement pinky
This commit is contained in:
mpkh 2016-07-26 13:38:53 +04:00 committed by GitHub
commit da0de488e6
12 changed files with 642 additions and 32 deletions

80
tests/test_pinky.rs Normal file
View file

@ -0,0 +1,80 @@
use common::util::*;
static UTIL_NAME: &'static str = "pinky";
extern crate uu_pinky;
pub use self::uu_pinky::*;
#[test]
fn test_capitalize() {
assert_eq!("Zbnmasd", "zbnmasd".capitalize());
assert_eq!("Abnmasd", "Abnmasd".capitalize());
assert_eq!("1masd", "1masd".capitalize());
assert_eq!("", "".capitalize());
}
#[test]
#[cfg(target_os = "linux")]
fn test_long_format() {
let (_, mut ucmd) = testing(UTIL_NAME);
ucmd.arg("-l").arg("root");
let expected = "Login name: root In real life: root\nDirectory: /root Shell: /bin/bash\n\n";
assert_eq!(expected, ucmd.run().stdout);
let (_, mut ucmd) = testing(UTIL_NAME);
ucmd.arg("-lb").arg("root");
let expected = "Login name: root In real life: root\n\n";
assert_eq!(expected, ucmd.run().stdout);
}
#[test]
#[cfg(target_os = "macos")]
fn test_long_format() {
let (_, mut ucmd) = testing(UTIL_NAME);
ucmd.arg("-l").arg("root");
let expected = "Login name: root In real life: System Administrator\nDirectory: /var/root Shell: /bin/sh\n\n";
assert_eq!(expected, ucmd.run().stdout);
let (_, mut ucmd) = testing(UTIL_NAME);
ucmd.arg("-lb").arg("root");
let expected = "Login name: root In real life: System Administrator\n\n";
assert_eq!(expected, ucmd.run().stdout);
}
#[cfg(target_os = "linux")]
#[test]
#[ignore]
fn test_short_format() {
let (_, mut ucmd) = testing(UTIL_NAME);
let args = ["-s"];
ucmd.args(&args);
assert_eq!(expected_result(&args), ucmd.run().stdout);
let (_, mut ucmd) = testing(UTIL_NAME);
let args = ["-f"];
ucmd.args(&args);
assert_eq!(expected_result(&args), ucmd.run().stdout);
let (_, mut ucmd) = testing(UTIL_NAME);
let args = ["-w"];
ucmd.args(&args);
assert_eq!(expected_result(&args), ucmd.run().stdout);
let (_, mut ucmd) = testing(UTIL_NAME);
let args = ["-i"];
ucmd.args(&args);
assert_eq!(expected_result(&args), ucmd.run().stdout);
let (_, mut ucmd) = testing(UTIL_NAME);
let args = ["-q"];
ucmd.args(&args);
assert_eq!(expected_result(&args), ucmd.run().stdout);
}
#[cfg(target_os = "linux")]
fn expected_result(args: &[&str]) -> String {
use std::process::Command;
let output = Command::new(UTIL_NAME).args(args).output().unwrap();
String::from_utf8_lossy(&output.stdout).into_owned()
}

View file

@ -145,8 +145,11 @@ fn test_invalid_option() {
ucmd.fails();
}
#[allow(unused_variable)]
const NORMAL_FMTSTR: &'static str = "%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s %u %U %w %W %x %X %y %Y %z %Z";
#[allow(unused_variable)]
const DEV_FMTSTR: &'static str = "%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s (%t/%T) %u %U %w %W %x %X %y %Y %z %Z";
#[allow(unused_variable)]
const FS_FMTSTR: &'static str = "%a %b %c %d %f %i %l %n %s %S %t %T";
#[test]
@ -230,6 +233,7 @@ fn test_printf() {
assert_eq!(ucmd.run().stdout, "123?\r\"\\\x07\x08\x1B\x0C\x0B /\x12wZJ\n");
}
#[allow(dead_code)]
fn expected_result(args: &[&str]) -> String {
use std::process::Command;

View file

@ -30,6 +30,7 @@ unix_only! {
"install", test_install;
"mv", test_mv;
"pathchk", test_pathchk;
"pinky", test_pinky;
"stdbuf", test_stdbuf;
"touch", test_touch;
"unlink", test_unlink;