2017-03-17 18:38:21 +00:00
|
|
|
extern crate uucore;
|
2016-07-26 08:43:25 +00:00
|
|
|
|
2017-03-17 18:38:21 +00:00
|
|
|
use common::util::*;
|
2016-08-20 11:50:31 +00:00
|
|
|
|
2017-03-17 18:38:21 +00:00
|
|
|
use self::uucore::entries::{Locate, Passwd};
|
2016-08-20 11:50:31 +00:00
|
|
|
|
2016-07-26 08:43:25 +00:00
|
|
|
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]
|
|
|
|
fn test_long_format() {
|
2017-03-17 18:38:21 +00:00
|
|
|
let ulogin = "root";
|
|
|
|
let pw: Passwd = Passwd::locate(ulogin).unwrap();
|
|
|
|
let real_name = pw.user_info().replace("&", &pw.name().capitalize());
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-l").arg(ulogin)
|
|
|
|
.run()
|
|
|
|
.stdout_is(format!("Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n",
|
|
|
|
ulogin, real_name, pw.user_dir(), pw.user_shell()));
|
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-lb")
|
|
|
|
.arg(ulogin)
|
|
|
|
.run()
|
|
|
|
.stdout_is(format!("Login name: {:<28}In real life: {1}\n\n",
|
|
|
|
ulogin, real_name));
|
2016-07-26 08:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
#[test]
|
|
|
|
fn test_short_format() {
|
2016-08-23 11:52:43 +00:00
|
|
|
let scene = TestScenario::new(util_name!());
|
2016-07-26 08:43:25 +00:00
|
|
|
|
|
|
|
let args = ["-i"];
|
2016-07-29 21:26:32 +00:00
|
|
|
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
2016-07-26 08:43:25 +00:00
|
|
|
|
|
|
|
let args = ["-q"];
|
2016-07-29 21:26:32 +00:00
|
|
|
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
2016-07-26 08:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
fn expected_result(args: &[&str]) -> String {
|
2018-04-22 06:07:38 +00:00
|
|
|
TestScenario::new(util_name!()).cmd_keepenv(util_name!()).env("LANGUAGE", "C").args(args).run().stdout
|
2016-07-26 08:43:25 +00:00
|
|
|
}
|