Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Dec 30, 2016
1 parent fab4069 commit 1f7f5c9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 16 deletions.
8 changes: 4 additions & 4 deletions tests/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ mat!(null_bytes, r"(?-u)(?P<cstr>[^\x00]+)\x00",
// Test that lookahead operators work properly in the face of invalid UTF-8.
// See: /~https://github.com/rust-lang-nursery/regex/issues/277
matiter!(invalidutf8_anchor1,
r"\xcc?^",
r"(?-u)\xcc?^",
R(b"\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4"),
(0, 0));
matiter!(invalidutf8_anchor2,
r"^\xf7|4\xff\d\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a##########[] d\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a##########[] #####\x80\S7|$",
r"(?-u)^\xf7|4\xff\d\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a##########[] d\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a##########[] #####\x80\S7|$",
R(b"\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4"),
(22, 22));
matiter!(invalidutf8_anchor3,
r"^|ddp\xff\xffdddddlQd@\x80",
r"(?-u)^|ddp\xff\xffdddddlQd@\x80",
R(b"\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4"),
(0, 0));

// See /~https://github.com/rust-lang-nursery/regex/issues/303
#[test]
fn negated_full_byte_range() {
assert!(::regex::bytes::Regex::new(r#"[^\x00-\xff]"#).is_err());
assert!(::regex::bytes::Regex::new(r#"(?-u)[^\x00-\xff]"#).is_err());
}
22 changes: 11 additions & 11 deletions tests/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ matiter!(word_boundary_dfa, r"\b", "a b c",
matiter!(partial_anchor, 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)));
mat!(ascii_boundary_no_capture, r"(?-u)\B", "\u{28f3e}", Some((0, 0)));
mat!(ascii_boundary_capture, 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);
ismatch!(partial_anchor_alternate_begin, r"^a|z", "yyyyya", false);
ismatch!(partial_anchor_alternate_end, r"a$|z", "ayyyyy", false);

// See: /~https://github.com/rust-lang-nursery/regex/issues/289
mat!(lits_unambiguous1, u!(r"(ABC|CDA|BC)X"), "CDAX", Some((0, 4)));
mat!(lits_unambiguous1, r"(ABC|CDA|BC)X", "CDAX", Some((0, 4)));

// See: /~https://github.com/rust-lang-nursery/regex/issues/291
mat!(lits_unambiguous2, u!(r"((IMG|CAM|MG|MB2)_|(DSCN|CIMG))(?P<n>[0-9]+)$"),
mat!(lits_unambiguous2, r"((IMG|CAM|MG|MB2)_|(DSCN|CIMG))(?P<n>[0-9]+)$",
"CIMG2341", Some((0, 8)), Some((0, 4)), None, Some((0, 4)), Some((4, 8)));

// See: /~https://github.com/rust-lang-nursery/regex/issues/271
mat!(end_not_wb, u!(r"$(?-u:\B)"), "\u{5c124}\u{b576c}", Some((8, 8)));
mat!(endl_or_wb, u!(r"(?m:$)|(?-u:\b)"), "\u{6084e}", Some((4, 4)));
mat!(zero_or_end, u!(r"(?i-u:\x00)|$"), "\u{e682f}", Some((4, 4)));
mat!(y_or_endl, u!(r"(?i-u:y)|(?m:$)"), "\u{b4331}", Some((4, 4)));
mat!(wb_start_x, u!(r"(?u:\b)^(?-u:X)"), "X", Some((0, 1)));
mat!(end_not_wb, r"$(?-u:\B)", "\u{5c124}\u{b576c}", Some((8, 8)));
mat!(endl_or_wb, r"(?m:$)|(?-u:\b)", "\u{6084e}", Some((4, 4)));
mat!(zero_or_end, r"(?i-u:\x00)|$", "\u{e682f}", Some((4, 4)));
mat!(y_or_endl, r"(?i-u:y)|(?m:$)", "\u{b4331}", Some((4, 4)));
mat!(wb_start_x, r"(?u:\b)^(?-u:X)", "X", Some((0, 1)));
2 changes: 2 additions & 0 deletions tests/test_backtrack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![cfg_attr(feature = "pattern", feature(pattern))]

extern crate rand;
extern crate regex;

Expand Down
2 changes: 2 additions & 0 deletions tests/test_backtrack_utf8bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![cfg_attr(feature = "pattern", feature(pattern))]

extern crate rand;
extern crate regex;

Expand Down
2 changes: 2 additions & 0 deletions tests/test_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![cfg_attr(feature = "pattern", feature(pattern))]

extern crate rand;
extern crate regex;

Expand Down
2 changes: 2 additions & 0 deletions tests/test_nfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![cfg_attr(feature = "pattern", feature(pattern))]

extern crate rand;
extern crate regex;

Expand Down
1 change: 0 additions & 1 deletion tests/test_nfa_bytes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_nfa_utf8bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![cfg_attr(feature = "pattern", feature(pattern))]

extern crate rand;
extern crate regex;

Expand Down

0 comments on commit 1f7f5c9

Please sign in to comment.