Skip to content

Commit 95495c3

Browse files
committed
dircolors: turn integration test into unit tests
1 parent 55549fa commit 95495c3

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

src/uu/dircolors/src/dircolors.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ pub fn generate_dircolors_config() -> String {
539539

540540
#[cfg(test)]
541541
mod tests {
542-
use super::escape;
542+
use super::*;
543543

544544
#[test]
545545
fn test_escape() {
@@ -548,4 +548,24 @@ mod tests {
548548
assert_eq!("\\:", escape(":"));
549549
assert_eq!("\\:", escape("\\:"));
550550
}
551+
552+
#[test]
553+
fn test_purify() {
554+
let s = " asd#zcv #hk\t\n ";
555+
assert_eq!("asd#zcv", s.purify());
556+
}
557+
558+
#[test]
559+
fn test_fnmatch() {
560+
let s = "con256asd";
561+
assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line
562+
}
563+
564+
#[test]
565+
fn test_split_two() {
566+
let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line
567+
let (k, v) = s.split_two();
568+
assert_eq!("zxc", k);
569+
assert_eq!("qwe jlk hjl", v);
570+
}
551571
}

tests/by-util/test_dircolors.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
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::{OutputFmt, StrUtils, guess_syntax};
12+
use dircolors::{OutputFmt, guess_syntax};
1113

1214
#[test]
1315
#[cfg(target_os = "linux")]
@@ -74,20 +76,6 @@ fn test_shell_syntax() {
7476
}
7577
}
7678

77-
#[test]
78-
fn test_str_utils() {
79-
let s = " asd#zcv #hk\t\n ";
80-
assert_eq!("asd#zcv", s.purify());
81-
82-
let s = "con256asd";
83-
assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line
84-
85-
let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line
86-
let (k, v) = s.split_two();
87-
assert_eq!("zxc", k);
88-
assert_eq!("qwe jlk hjl", v);
89-
}
90-
9179
#[test]
9280
fn test1() {
9381
test_helper("test1", "gnome");

0 commit comments

Comments
 (0)