6
6
7
7
extern crate regex;
8
8
9
- use regex:: { Regex , RegexSet } ;
10
- use regex:: bytes:: { Regex as BRegex , RegexSet as BRegexSet } ;
9
+ use regex:: { Regex , RegexSet , RegexBuilder } ;
10
+ use regex:: bytes:: { Regex as BRegex , RegexSet as BRegexSet , RegexBuilder as BRegexBuilder } ;
11
11
12
12
const OPENING_PAREN : & ' static str = "(" ;
13
13
const NOT_A_REAL_REGEX : & ' static str = "foobar" ;
14
14
15
15
fn syntax_error ( ) {
16
16
let pipe_in_wrong_position = Regex :: new ( "|" ) ;
17
17
//~^ERROR: regex syntax error: empty alternate
18
+ let pipe_in_wrong_position_builder = RegexBuilder :: new ( "|" ) ;
19
+ //~^ERROR: regex syntax error: empty alternate
18
20
let wrong_char_ranice = Regex :: new ( "[z-a]" ) ;
19
21
//~^ERROR: regex syntax error: invalid character class range
20
22
let some_unicode = Regex :: new ( "[é-è]" ) ;
@@ -27,6 +29,8 @@ fn syntax_error() {
27
29
//~^ERROR: regex syntax error: empty alternate
28
30
let some_binary_regex = BRegex :: new ( OPENING_PAREN ) ;
29
31
//~^ERROR: regex syntax error on position 0: unclosed
32
+ let some_binary_regex_builder = BRegexBuilder :: new ( OPENING_PAREN ) ;
33
+ //~^ERROR: regex syntax error on position 0: unclosed
30
34
31
35
let closing_paren = ")" ;
32
36
let not_linted = Regex :: new ( closing_paren) ;
@@ -57,6 +61,10 @@ fn trivial_regex() {
57
61
//~^ERROR: trivial regex
58
62
//~|HELP consider using `==` on `str`s
59
63
64
+ let trivial_eq_builder = RegexBuilder :: new ( "^foobar$" ) ;
65
+ //~^ERROR: trivial regex
66
+ //~|HELP consider using `==` on `str`s
67
+
60
68
let trivial_starts_with = Regex :: new ( "^foobar" ) ;
61
69
//~^ERROR: trivial regex
62
70
//~|HELP consider using `str::starts_with`
@@ -96,11 +104,13 @@ fn trivial_regex() {
96
104
97
105
// non-trivial regexes
98
106
let non_trivial_dot = Regex :: new ( "a.b" ) ;
107
+ let non_trivial_dot_builder = RegexBuilder :: new ( "a.b" ) ;
99
108
let non_trivial_eq = Regex :: new ( "^foo|bar$" ) ;
100
109
let non_trivial_starts_with = Regex :: new ( "^foo|bar" ) ;
101
110
let non_trivial_ends_with = Regex :: new ( "^foo|bar" ) ;
102
111
let non_trivial_ends_with = Regex :: new ( "foo|bar" ) ;
103
112
let non_trivial_binary = BRegex :: new ( "foo|bar" ) ;
113
+ let non_trivial_binary_builder = BRegexBuilder :: new ( "foo|bar" ) ;
104
114
}
105
115
106
116
fn main ( ) {
0 commit comments