]>
git.proxmox.com Git - rustc.git/blob - vendor/regex-1.4.3/tests/api_str.rs
1 // These tests don't really make sense with the bytes API, so we only test them
5 fn empty_match_unicode_find_iter() {
6 // Tests that we still yield byte ranges at valid UTF-8 sequence boundaries
7 // even when we're susceptible to empty width matches.
8 let re
= regex
!(r
".*?");
10 vec
![(0, 0), (3, 3), (4, 4), (7, 7), (8, 8)],
16 fn empty_match_unicode_captures_iter() {
17 // Same as empty_match_unicode_find_iter, but tests capture iteration.
18 let re
= regex
!(r
".*?");
20 .captures_iter(text
!("Ⅰ1Ⅱ2"))
21 .map(|c
| c
.get(0).unwrap())
22 .map(|m
| (m
.start(), m
.end()))
24 assert_eq
!(vec
![(0, 0), (3, 3), (4, 4), (7, 7), (8, 8)], ms
);
29 let re
= regex
!(r
"fo+");
30 let caps
= re
.captures("barfoobar").unwrap();
31 assert_eq
!(caps
.get(0).map(|m
| m
.as_str()), Some("foo"));
32 assert_eq
!(caps
.get(0).map(From
::from
), Some("foo"));
33 assert_eq
!(caps
.get(0).map(Into
::into
), Some("foo"));