]>
Commit | Line | Data |
---|---|---|
94b46f34 XL |
1 | // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | #![cfg_attr(feature = "pattern", feature(pattern))] | |
12 | ||
13 | extern crate rand; | |
14 | extern crate regex; | |
15 | ||
16 | // Due to macro scoping rules, this definition only applies for the modules | |
17 | // defined below. Effectively, it allows us to use the same tests for both | |
18 | // native and dynamic regexes. | |
19 | // | |
20 | // This is also used to test the various matching engines. This one exercises | |
21 | // the normal code path which automatically chooses the engine based on the | |
22 | // regex and the input. Other dynamic tests explicitly set the engine to use. | |
23 | macro_rules! regex_new { | |
24 | ($re:expr) => {{ | |
25 | use regex::Regex; | |
26 | Regex::new($re) | |
27 | }} | |
28 | } | |
29 | ||
30 | macro_rules! regex { | |
31 | ($re:expr) => { | |
32 | regex_new!($re).unwrap() | |
33 | } | |
34 | } | |
35 | ||
36 | macro_rules! regex_set_new { | |
37 | ($re:expr) => {{ | |
38 | use regex::RegexSet; | |
39 | RegexSet::new($re) | |
40 | }} | |
41 | } | |
42 | ||
43 | macro_rules! regex_set { | |
44 | ($res:expr) => { | |
45 | regex_set_new!($res).unwrap() | |
46 | } | |
47 | } | |
48 | ||
49 | // Must come before other module definitions. | |
50 | include!("macros_str.rs"); | |
51 | include!("macros.rs"); | |
52 | ||
53 | mod api; | |
54 | mod api_str; | |
55 | mod crazy; | |
56 | mod flags; | |
57 | mod fowler; | |
58 | mod misc; | |
59 | mod multiline; | |
60 | mod noparse; | |
61 | mod regression; | |
62 | mod replace; | |
63 | mod searcher; | |
64 | mod set; | |
65 | mod shortest_match; | |
66 | mod suffix_reverse; | |
67 | mod unicode; | |
68 | mod word_boundary; | |
69 | mod word_boundary_unicode; | |
70 | ||
71 | #[test] | |
72 | fn disallow_non_utf8() { | |
73 | assert!(regex::Regex::new(r"(?-u)\xFF").is_err()); | |
74 | assert!(regex::Regex::new(r"(?-u).").is_err()); | |
75 | assert!(regex::Regex::new(r"(?-u)[\xFF]").is_err()); | |
76 | assert!(regex::Regex::new(r"(?-u)☃").is_err()); | |
77 | } |