From 08315736695d767b7fe9d15dfbf57f360f642c07 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Wed, 26 Jul 2017 21:01:22 +0100 Subject: [PATCH] Add tests for dot filters --- src/options/filter.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/options/filter.rs b/src/options/filter.rs index 3ef00d2..3f80de2 100644 --- a/src/options/filter.rs +++ b/src/options/filter.rs @@ -141,7 +141,7 @@ mod test { use options::parser::{parse, Args, Arg}; use std::ffi::OsString; - static TEST_ARGS: &[&Arg] = &[ &flags::SORT ]; + static TEST_ARGS: &[&Arg] = &[ &flags::SORT, &flags::ALL, &flags::TREE ]; let bits = $inputs.as_ref().into_iter().map(|&o| os(o)).collect::>(); let results = parse(&Args(TEST_ARGS), bits.iter()); @@ -170,4 +170,20 @@ mod test { test!(overridden: SortField <- ["--sort=cr", "--sort", "mod"] => Ok(SortField::ModifiedDate)); test!(overridden_2: SortField <- ["--sort", "none", "--sort=Extension"] => Ok(SortField::Extension(SortCase::Insensitive))); } + + + mod dot_filters { + use super::*; + + // Default behaviour + test!(empty: DotFilter <- [] => Ok(DotFilter::JustFiles)); + + // --all + test!(all: DotFilter <- ["--all"] => Ok(DotFilter::Dotfiles)); + test!(all_all: DotFilter <- ["--all", "-a"] => Ok(DotFilter::DotfilesAndDots)); + test!(all_all_2: DotFilter <- ["-aa"] => Ok(DotFilter::DotfilesAndDots)); + + // --all and --tree + test!(tree: DotFilter <- ["-Taa"] => Err(Misfire::TreeAllAll)); + } }