aboutsummaryrefslogtreecommitdiff
path: root/tests/shortest_match.rs
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2020-04-16 10:44:21 -0700
committerChih-Hung Hsieh <chh@google.com>2020-04-16 10:45:53 -0700
commite42c505f54ac2e7b2ca7d0197304cac1b4f605e9 (patch)
tree7ca22ebdbdb7d0c9dc5c66d31f564aeaf51cece4 /tests/shortest_match.rs
parent815d0a2344b5321fd47f0cb7dba96e4cb4e84615 (diff)
downloadregex-e42c505f54ac2e7b2ca7d0197304cac1b4f605e9.tar.gz
Import 'regex' package vesion 1.3.6
* Add OWNERS * No Android.bp yet Bug: 152884384 Test: make Change-Id: I455caf7833b6c437c1c133bc7b2f47b83da9cbce
Diffstat (limited to 'tests/shortest_match.rs')
-rw-r--r--tests/shortest_match.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/shortest_match.rs b/tests/shortest_match.rs
new file mode 100644
index 0000000..f8b4fed
--- /dev/null
+++ b/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));