mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
pinky: add tests
This commit is contained in:
parent
6fff3a7665
commit
be20d8605d
3 changed files with 81 additions and 7 deletions
|
@ -13,13 +13,6 @@ time = "*"
|
|||
libc = "^0.2"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[dependencies.clippy]
|
||||
version = "*"
|
||||
optional = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
[[bin]]
|
||||
name = "pinky"
|
||||
path = "main.rs"
|
||||
|
|
80
tests/test_pinky.rs
Normal file
80
tests/test_pinky.rs
Normal 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()
|
||||
}
|
|
@ -29,6 +29,7 @@ unix_only! {
|
|||
"chown", test_chown;
|
||||
"mv", test_mv;
|
||||
"pathchk", test_pathchk;
|
||||
"pinky", test_pinky;
|
||||
"stdbuf", test_stdbuf;
|
||||
"touch", test_touch;
|
||||
"unlink", test_unlink;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue