Skip to content

Commit 21cc4b6

Browse files
committed
dircolors: turn integration test into unit tests
1 parent c5ee385 commit 21cc4b6

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

src/uu/dircolors/src/dircolors.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,24 @@ mod tests {
534534
assert_eq!(Some(OutputFmt::Shell), guess_syntax("foo"));
535535
assert_eq!(None, guess_syntax(""));
536536
}
537+
538+
#[test]
539+
fn test_purify() {
540+
let s = " asd#zcv #hk\t\n ";
541+
assert_eq!("asd#zcv", s.purify());
542+
}
543+
544+
#[test]
545+
fn test_fnmatch() {
546+
let s = "con256asd";
547+
assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line
548+
}
549+
550+
#[test]
551+
fn test_split_two() {
552+
let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line
553+
let (k, v) = s.split_two();
554+
assert_eq!("zxc", k);
555+
assert_eq!("qwe jlk hjl", v);
556+
}
537557
}

tests/by-util/test_dircolors.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5+
56
// spell-checker:ignore overridable colorterm
7+
68
#[cfg(target_os = "linux")]
79
use uutests::at_and_ucmd;
810
use uutests::new_ucmd;
911

10-
use dircolors::StrUtils;
11-
1212
#[test]
1313
#[cfg(target_os = "linux")]
1414
fn test_dircolors_non_utf8_paths() {
@@ -30,20 +30,6 @@ fn test_invalid_arg() {
3030
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
3131
}
3232

33-
#[test]
34-
fn test_str_utils() {
35-
let s = " asd#zcv #hk\t\n ";
36-
assert_eq!("asd#zcv", s.purify());
37-
38-
let s = "con256asd";
39-
assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line
40-
41-
let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line
42-
let (k, v) = s.split_two();
43-
assert_eq!("zxc", k);
44-
assert_eq!("qwe jlk hjl", v);
45-
}
46-
4733
#[test]
4834
fn test1() {
4935
test_helper("test1", "gnome");

0 commit comments

Comments
 (0)