From abb08f8e1ad4e002b761aa42a915c131d2f63bcc Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Sun, 24 Oct 2021 11:14:34 +0100 Subject: [PATCH] Tests: Add tests for multi regex support --- tests/test_flags.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_flags.rs b/tests/test_flags.rs index e7cab29..ed790d3 100644 --- a/tests/test_flags.rs +++ b/tests/test_flags.rs @@ -129,18 +129,29 @@ pub fn test_show_files_by_type() { } #[test] -pub fn test_show_files_by_regex() { +pub fn test_show_files_by_regex_match_lots() { // Check we can see '.rs' files in the tests directory let output = build_command(vec!["-c", "-e", "\\.rs$", "tests"]); assert!(output.contains(" ┌─┴ tests")); assert!(!output.contains("0B ┌── tests")); assert!(!output.contains("0B ┌─┴ tests")); +} +#[test] +pub fn test_show_files_by_regex_match_nothing() { // Check there are no files named: '.match_nothing' in the tests directory let output = build_command(vec!["-c", "-e", "match_nothing$", "tests"]); assert!(output.contains("0B ┌── tests")); } +#[test] +pub fn test_show_files_by_regex_match_multiple() { + let output = build_command(vec!["-c", "-e", "test_dir2", "-e", "unicode", "tests"]); + assert!(output.contains("test_dir2")); + assert!(output.contains("test_dir_unicode")); + assert!(!output.contains("many")); // We do not find the 'many' folder in the 'test_dir' folder +} + #[test] pub fn test_show_files_by_invert_regex() { let output = build_command(vec!["-c", "-f", "-v", "e", "tests/test_dir2"]); @@ -155,3 +166,13 @@ pub fn test_show_files_by_invert_regex() { let output = build_command(vec!["-c", "-f", "-v", "match_nothing$", "tests/test_dir2"]); assert!(output.contains("4 ┌─┴ test_dir2")); } + +#[test] +pub fn test_show_files_by_invert_regex_match_multiple() { + // We ignore test_dir2 & test_dir_unicode, leaving the test_dir folder + // which has the 'many' folder inside + let output = build_command(vec!["-c", "-v", "test_dir2", "-v", "unicode", "tests"]); + assert!(!output.contains("test_dir2")); + assert!(!output.contains("test_dir_unicode")); + assert!(output.contains("many")); +}