forked from rust-lang/regex
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathregression.rs
More file actions
70 lines (56 loc) · 2.83 KB
/
regression.rs
File metadata and controls
70 lines (56 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// See: https://github.com/rust-lang/regex/issues/48
#[test]
fn invalid_regexes_no_crash() {
assert!(regex_new!("(*)").is_err());
assert!(regex_new!("(?:?)").is_err());
assert!(regex_new!("(?)").is_err());
assert!(regex_new!("*").is_err());
}
// See: https://github.com/rust-lang/regex/issues/98
#[test]
fn regression_many_repeat_stack_overflow() {
let re = regex!("^.{1,2500}");
assert_eq!(vec![(0, 1)], findall!(re, "a"));
}
// See: https://github.com/rust-lang/regex/issues/75
mat!(regression_unsorted_binary_search_1, r"(?i)[a_]+", "A_", Some((0, 2)));
mat!(regression_unsorted_binary_search_2, r"(?i)[A_]+", "a_", Some((0, 2)));
// See: https://github.com/rust-lang/regex/issues/99
mat!(regression_negated_char_class_1, r"(?i)[^x]", "x", None);
mat!(regression_negated_char_class_2, r"(?i)[^x]", "X", None);
// See: https://github.com/rust-lang/regex/issues/101
mat!(regression_ascii_word_underscore, r"[:word:]", "_", Some((0, 1)));
// See: https://github.com/rust-lang-nursery/regex/issues/129
#[test]
fn regression_captures_rep() {
let re = regex!(r"([a-f]){2}(?P<foo>[x-z])");
let caps = re.captures(text!("abx")).unwrap();
assert_eq!(caps.name("foo").unwrap(), text!("x"));
}
// See: https://github.com/rust-lang-nursery/regex/issues/153
mat!(regression_alt_in_alt1, r"ab?|$", "az", Some((0, 1)));
mat!(regression_alt_in_alt2, r"^(.*?)(\n|\r\n?|$)", "ab\rcd", Some((0, 3)));
// See: https://github.com/rust-lang-nursery/regex/issues/169
mat!(regression_leftmost_first_prefix, r"z*azb", "azb", Some((0, 3)));
// See: https://github.com/rust-lang/regex/issues/76
mat!(uni_case_lower_nocase_flag, u!(r"(?i)\p{Ll}+"), "ΛΘΓΔα", Some((0, 10)));
// See: https://github.com/rust-lang-nursery/regex/issues/191
mat!(many_alternates, r"1|2|3|4|5|6|7|8|9|10|int", "int", Some((0, 3)));
// burntsushi was bad and didn't create an issue for this bug.
mat!(anchored_prefix1, r"^a\S", "a ", None);
mat!(anchored_prefix2, r"^a\S", "foo boo a ", None);
mat!(anchored_prefix3, r"^-[a-z]", "r-f", None);
// See: https://github.com/rust-lang-nursery/regex/issues/204
split!(split_on_word_boundary, r"\b", r"Should this (work?)",
&[t!(""), t!("Should"), t!(" "), t!("this"),
t!(" ("), t!("work"), t!("?)")]);
matiter!(word_boundary_dfa, r"\b", "a b c",
(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5));
// See: https://github.com/rust-lang-nursery/regex/issues/268
matiter!(partial_anchor, u!(r"^a|b"), "ba", (0, 1));
// See: https://github.com/rust-lang-nursery/regex/issues/264
mat!(ascii_boundary_no_capture, u!(r"(?-u)\B"), "\u{28f3e}", Some((0, 0)));
mat!(ascii_boundary_capture, u!(r"(?-u)(\B)"), "\u{28f3e}", Some((0, 0)));
// See: https://github.com/rust-lang-nursery/regex/issues/280
ismatch!(partial_anchor_alternate_begin, u!(r"^a|z"), "yyyyya", false);
ismatch!(partial_anchor_alternate_end, u!(r"a$|z"), "ayyyyy", false);