Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/uu/pinky/src/pinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,16 @@ impl Capitalize for str {
})
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_capitalize() {
assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line
assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line
assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line
assert_eq!("", "".capitalize());
}
}
17 changes: 3 additions & 14 deletions tests/by-util/test_pinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,22 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use pinky::Capitalize;
#[cfg(not(target_os = "openbsd"))]
use uucore::entries::{Locate, Passwd};
use uutests::new_ucmd;
use uutests::unwrap_or_return;
#[cfg(target_os = "openbsd")]
use uutests::util::TestScenario;
#[cfg(not(target_os = "openbsd"))]
use uutests::util::{TestScenario, expected_result};
use uutests::util_name;
use uutests::{new_ucmd, unwrap_or_return, util_name};

#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
}

#[test]
fn test_capitalize() {
assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line
assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line
assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line
assert_eq!("", "".capitalize());
}

#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_long_format() {
use pinky::Capitalize;

let login = "root";
let pw: Passwd = Passwd::locate(login).unwrap();
let user_info = pw.user_info.unwrap_or_default();
Expand Down
Loading