pub use wbase::glob::{glob_match, glob_match_nocase, glob_match_opt};
#[cfg(test)]
mod tests {
use super::{glob_match, glob_match_nocase, glob_match_opt};
#[test]
fn test_glob_basic() {
assert!(!glob_match(b"*", b""));
assert!(glob_match(b"*", b"hello"));
assert!(glob_match(b"", b""));
assert!(!glob_match(b"", b"a"));
assert!(glob_match(b"h?llo", b"hello"));
assert!(!glob_match(b"h?llo", b"hllo"));
}
#[test]
fn test_glob_brackets_and_escapes() {
assert!(glob_match(b"[a-z]ello", b"hello"));
assert!(!glob_match(b"[0-9]ello", b"hello"));
assert!(!glob_match(b"[!0-9]ello", b"hello"));
assert!(glob_match(b"[!0-9]ello", b"!ello"));
assert!(glob_match(b"[^0-9]ello", b"hello"));
assert!(glob_match(b"[\\]]", b"]"));
assert!(glob_match(b"[\\\\\\\\]", b"\\"));
assert!(glob_match(b"\\*hello", b"*hello"));
assert!(!glob_match(b"\\*hello", b"foo_hello"));
assert!(glob_match(b"[a-]", b"]"));
assert!(glob_match(b"[a-]", b"a"));
assert!(!glob_match(b"[a-]", b"b"));
assert!(glob_match(b"[a-]x]", b"x"));
assert!(glob_match(b"[a-]x]", b"]"));
assert!(!glob_match(b"[a-]x]", b"]x"));
assert!(glob_match(b"[z-a]", b"m"));
assert!(glob_match(b"[abc", b"a"));
assert!(!glob_match(b"[abc", b"d"));
assert!(!glob_match(b"[", b"["));
}
#[test]
fn test_glob_nocase() {
assert!(!glob_match(b"hello", b"HELLO"));
assert!(glob_match_nocase(b"hello", b"HELLO"));
assert!(glob_match_opt(b"h[a-z]llo", b"hEllo", true));
assert!(!glob_match_nocase(b"[k-M]ello", b"lello"));
assert!(!glob_match_nocase(b"[Z-a]ello", b"mello"));
assert!(!glob_match_nocase(b"[a-Z]ello", b"mello"));
}
}