diff options
author | Chih-Hung Hsieh <chh@google.com> | 2020-04-16 10:44:21 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2020-04-16 10:45:53 -0700 |
commit | e42c505f54ac2e7b2ca7d0197304cac1b4f605e9 (patch) | |
tree | 7ca22ebdbdb7d0c9dc5c66d31f564aeaf51cece4 /tests/set.rs | |
parent | 815d0a2344b5321fd47f0cb7dba96e4cb4e84615 (diff) | |
download | regex-e42c505f54ac2e7b2ca7d0197304cac1b4f605e9.tar.gz |
Import 'regex' package vesion 1.3.6
* Add OWNERS
* No Android.bp yet
Bug: 152884384
Test: make
Change-Id: I455caf7833b6c437c1c133bc7b2f47b83da9cbce
Diffstat (limited to 'tests/set.rs')
-rw-r--r-- | tests/set.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/set.rs b/tests/set.rs new file mode 100644 index 0000000..3e9755c --- /dev/null +++ b/tests/set.rs @@ -0,0 +1,45 @@ +matset!(set1, &["a", "a"], "a", 0, 1); +matset!(set2, &["a", "a"], "ba", 0, 1); +matset!(set3, &["a", "b"], "a", 0); +matset!(set4, &["a", "b"], "b", 1); +matset!(set5, &["a|b", "b|a"], "b", 0, 1); +matset!(set6, &["foo", "oo"], "foo", 0, 1); +matset!(set7, &["^foo", "bar$"], "foo", 0); +matset!(set8, &["^foo", "bar$"], "foo bar", 0, 1); +matset!(set9, &["^foo", "bar$"], "bar", 1); +matset!(set10, &[r"[a-z]+$", "foo"], "01234 foo", 0, 1); +matset!(set11, &[r"[a-z]+$", "foo"], "foo 01234", 1); +matset!(set12, &[r".*?", "a"], "zzzzzza", 0, 1); +matset!(set13, &[r".*", "a"], "zzzzzza", 0, 1); +matset!(set14, &[r".*", "a"], "zzzzzz", 0); +matset!(set15, &[r"(?-u)\ba\b"], "hello a bye", 0); +matset!(set16, &["a"], "a", 0); +matset!(set17, &[".*a"], "a", 0); +matset!(set18, &["a", "β"], "β", 1); + +nomatset!(nset1, &["a", "a"], "b"); +nomatset!(nset2, &["^foo", "bar$"], "bar foo"); +nomatset!( + nset3, + { + let xs: &[&str] = &[]; + xs + }, + "a" +); +nomatset!(nset4, &[r"^rooted$", r"\.log$"], "notrooted"); + +// See: https://github.com/rust-lang/regex/issues/187 +#[test] +fn regression_subsequent_matches() { + let set = regex_set!(&["ab", "b"]); + let text = text!("ba"); + assert!(set.matches(text).matched(1)); + assert!(set.matches(text).matched(1)); +} + +#[test] +fn get_set_patterns() { + let set = regex_set!(&["a", "b"]); + assert_eq!(vec!["a", "b"], set.patterns()); +} |