summaryrefslogtreecommitdiffstats
path: root/vendor/regex/tests/shortest_match.rs
blob: f8b4fed15691d24943fb0e542f29ee80cf3aa4c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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));