From 9ef9bf7b80aac54fe6767255a7b39ba6e673d4d9 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 3 Apr 2020 11:50:43 +0200 Subject: [PATCH] Add tests for regex_helper --- src/regex_helper.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/regex_helper.rs b/src/regex_helper.rs index 131d0b6..4cadd96 100644 --- a/src/regex_helper.rs +++ b/src/regex_helper.rs @@ -33,3 +33,20 @@ fn hir_has_uppercase_char(hir: &Hir) -> bool { _ => false, } } + +#[test] +fn pattern_has_uppercase_char_simple() { + assert!(pattern_has_uppercase_char("A")); + assert!(pattern_has_uppercase_char("foo.EXE")); + + assert!(!pattern_has_uppercase_char("a")); + assert!(!pattern_has_uppercase_char("foo.exe123")); +} + +#[test] +fn pattern_has_uppercase_char_advanced() { + assert!(pattern_has_uppercase_char("foo.[a-zA-Z]")); + + assert!(!pattern_has_uppercase_char(r"\Acargo")); + assert!(!pattern_has_uppercase_char(r"carg\x6F")); +}