1c67d6573Sopenharmony_cimatset!(set1, &["a", "a"], "a", 0, 1);
2c67d6573Sopenharmony_cimatset!(set2, &["a", "a"], "ba", 0, 1);
3c67d6573Sopenharmony_cimatset!(set3, &["a", "b"], "a", 0);
4c67d6573Sopenharmony_cimatset!(set4, &["a", "b"], "b", 1);
5c67d6573Sopenharmony_cimatset!(set5, &["a|b", "b|a"], "b", 0, 1);
6c67d6573Sopenharmony_cimatset!(set6, &["foo", "oo"], "foo", 0, 1);
7c67d6573Sopenharmony_cimatset!(set7, &["^foo", "bar$"], "foo", 0);
8c67d6573Sopenharmony_cimatset!(set8, &["^foo", "bar$"], "foo bar", 0, 1);
9c67d6573Sopenharmony_cimatset!(set9, &["^foo", "bar$"], "bar", 1);
10c67d6573Sopenharmony_cimatset!(set10, &[r"[a-z]+$", "foo"], "01234 foo", 0, 1);
11c67d6573Sopenharmony_cimatset!(set11, &[r"[a-z]+$", "foo"], "foo 01234", 1);
12c67d6573Sopenharmony_cimatset!(set12, &[r".*?", "a"], "zzzzzza", 0, 1);
13c67d6573Sopenharmony_cimatset!(set13, &[r".*", "a"], "zzzzzza", 0, 1);
14c67d6573Sopenharmony_cimatset!(set14, &[r".*", "a"], "zzzzzz", 0);
15c67d6573Sopenharmony_cimatset!(set15, &[r"(?-u)\ba\b"], "hello a bye", 0);
16c67d6573Sopenharmony_cimatset!(set16, &["a"], "a", 0);
17c67d6573Sopenharmony_cimatset!(set17, &[".*a"], "a", 0);
18c67d6573Sopenharmony_cimatset!(set18, &["a", "β"], "β", 1);
19c67d6573Sopenharmony_ci
20c67d6573Sopenharmony_ci// regexes that match the empty string
21c67d6573Sopenharmony_cimatset!(setempty1, &["", "a"], "abc", 0, 1);
22c67d6573Sopenharmony_cimatset!(setempty2, &["", "b"], "abc", 0, 1);
23c67d6573Sopenharmony_cimatset!(setempty3, &["", "z"], "abc", 0);
24c67d6573Sopenharmony_cimatset!(setempty4, &["a", ""], "abc", 0, 1);
25c67d6573Sopenharmony_cimatset!(setempty5, &["b", ""], "abc", 0, 1);
26c67d6573Sopenharmony_cimatset!(setempty6, &["z", ""], "abc", 1);
27c67d6573Sopenharmony_cimatset!(setempty7, &["b", "(?:)"], "abc", 0, 1);
28c67d6573Sopenharmony_cimatset!(setempty8, &["(?:)", "b"], "abc", 0, 1);
29c67d6573Sopenharmony_cimatset!(setempty9, &["c(?:)", "b"], "abc", 0, 1);
30c67d6573Sopenharmony_ci
31c67d6573Sopenharmony_cinomatset!(nset1, &["a", "a"], "b");
32c67d6573Sopenharmony_cinomatset!(nset2, &["^foo", "bar$"], "bar foo");
33c67d6573Sopenharmony_cinomatset!(
34c67d6573Sopenharmony_ci    nset3,
35c67d6573Sopenharmony_ci    {
36c67d6573Sopenharmony_ci        let xs: &[&str] = &[];
37c67d6573Sopenharmony_ci        xs
38c67d6573Sopenharmony_ci    },
39c67d6573Sopenharmony_ci    "a"
40c67d6573Sopenharmony_ci);
41c67d6573Sopenharmony_cinomatset!(nset4, &[r"^rooted$", r"\.log$"], "notrooted");
42c67d6573Sopenharmony_ci
43c67d6573Sopenharmony_ci// See: https://github.com/rust-lang/regex/issues/187
44c67d6573Sopenharmony_ci#[test]
45c67d6573Sopenharmony_cifn regression_subsequent_matches() {
46c67d6573Sopenharmony_ci    let set = regex_set!(&["ab", "b"]);
47c67d6573Sopenharmony_ci    let text = text!("ba");
48c67d6573Sopenharmony_ci    assert!(set.matches(text).matched(1));
49c67d6573Sopenharmony_ci    assert!(set.matches(text).matched(1));
50c67d6573Sopenharmony_ci}
51c67d6573Sopenharmony_ci
52c67d6573Sopenharmony_ci#[test]
53c67d6573Sopenharmony_cifn get_set_patterns() {
54c67d6573Sopenharmony_ci    let set = regex_set!(&["a", "b"]);
55c67d6573Sopenharmony_ci    assert_eq!(vec!["a", "b"], set.patterns());
56c67d6573Sopenharmony_ci}
57c67d6573Sopenharmony_ci
58c67d6573Sopenharmony_ci#[test]
59c67d6573Sopenharmony_cifn len_and_empty() {
60c67d6573Sopenharmony_ci    let empty = regex_set!(&[""; 0]);
61c67d6573Sopenharmony_ci    assert_eq!(empty.len(), 0);
62c67d6573Sopenharmony_ci    assert!(empty.is_empty());
63c67d6573Sopenharmony_ci
64c67d6573Sopenharmony_ci    let not_empty = regex_set!(&["ab", "b"]);
65c67d6573Sopenharmony_ci    assert_eq!(not_empty.len(), 2);
66c67d6573Sopenharmony_ci    assert!(!not_empty.is_empty());
67c67d6573Sopenharmony_ci}
68