]> git.proxmox.com Git - rustc.git/blame - vendor/regex-0.2.11/tests/test_default.rs
New upstream version 1.33.0+dfsg1
[rustc.git] / vendor / regex-0.2.11 / tests / test_default.rs
CommitLineData
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
13extern crate rand;
14extern 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.
23macro_rules! regex_new {
24 ($re:expr) => {{
25 use regex::Regex;
26 Regex::new($re)
27 }}
28}
29
30macro_rules! regex {
31 ($re:expr) => {
32 regex_new!($re).unwrap()
33 }
34}
35
36macro_rules! regex_set_new {
37 ($re:expr) => {{
38 use regex::RegexSet;
39 RegexSet::new($re)
40 }}
41}
42
43macro_rules! regex_set {
44 ($res:expr) => {
45 regex_set_new!($res).unwrap()
46 }
47}
48
49// Must come before other module definitions.
50include!("macros_str.rs");
51include!("macros.rs");
52
53mod api;
54mod api_str;
55mod crazy;
56mod flags;
57mod fowler;
58mod misc;
59mod multiline;
60mod noparse;
61mod regression;
62mod replace;
63mod searcher;
64mod set;
65mod shortest_match;
66mod suffix_reverse;
67mod unicode;
68mod word_boundary;
69mod word_boundary_unicode;
70
71#[test]
72fn 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}