summaryrefslogtreecommitdiffstats
path: root/vendor/regex/tests/shortest_match.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/regex/tests/shortest_match.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/vendor/regex/tests/shortest_match.rs b/vendor/regex/tests/shortest_match.rs
new file mode 100644
index 000000000..f8b4fed15
--- /dev/null
+++ b/vendor/regex/tests/shortest_match.rs
@@ -0,0 +1,14 @@
+macro_rules! shortmat {
+ ($name:ident, $re:expr, $text:expr, $shortest_match:expr) => {
+ #[test]
+ fn $name() {
+ let text = text!($text);
+ let re = regex!($re);
+ assert_eq!($shortest_match, re.shortest_match(text));
+ }
+ };
+}
+
+shortmat!(t01, r"a+", r"aa", Some(1));
+// Test that the reverse suffix optimization gets it right.
+shortmat!(t02, r".*(?:abcd)+", r"abcdabcd", Some(4));