Skip to content

Commit bd7581f

Browse files
authored
Merge pull request #8671 from cakebaker/pinky_move_test
pinky: move unit test away from the integration tests
2 parents ec7e88f + d2125f5 commit bd7581f

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/uu/pinky/src/pinky.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,16 @@ impl Capitalize for str {
135135
})
136136
}
137137
}
138+
139+
#[cfg(test)]
140+
mod test {
141+
use super::*;
142+
143+
#[test]
144+
fn test_capitalize() {
145+
assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line
146+
assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line
147+
assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line
148+
assert_eq!("", "".capitalize());
149+
}
150+
}

tests/by-util/test_pinky.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,22 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
use pinky::Capitalize;
76
#[cfg(not(target_os = "openbsd"))]
87
use uucore::entries::{Locate, Passwd};
9-
use uutests::new_ucmd;
10-
use uutests::unwrap_or_return;
11-
#[cfg(target_os = "openbsd")]
12-
use uutests::util::TestScenario;
138
#[cfg(not(target_os = "openbsd"))]
149
use uutests::util::{TestScenario, expected_result};
15-
use uutests::util_name;
10+
use uutests::{new_ucmd, unwrap_or_return, util_name};
1611

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

22-
#[test]
23-
fn test_capitalize() {
24-
assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line
25-
assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line
26-
assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line
27-
assert_eq!("", "".capitalize());
28-
}
29-
3017
#[test]
3118
#[cfg(not(target_os = "openbsd"))]
3219
fn test_long_format() {
20+
use pinky::Capitalize;
21+
3322
let login = "root";
3423
let pw: Passwd = Passwd::locate(login).unwrap();
3524
let user_info = pw.user_info.unwrap_or_default();

0 commit comments

Comments
 (0)