MCPcopy Create free account
hub / github.com/davidblewett/rure-python / capture_misc

Function capture_misc

regex/tests/api.rs:125–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123
124#[test]
125fn capture_misc() {
126 let re = regex!(r"(.)(?P<a>a)?(.)(?P<b>.)");
127 let cap = re.captures(t!("abc")).unwrap();
128
129 assert_eq!(5, cap.len());
130
131 assert_eq!((0, 3), { let m = cap.get(0).unwrap(); (m.start(), m.end()) });
132 assert_eq!(None, cap.get(2));
133 assert_eq!((2, 3), { let m = cap.get(4).unwrap(); (m.start(), m.end()) });
134
135 assert_eq!(t!("abc"), match_text!(cap.get(0).unwrap()));
136 assert_eq!(None, cap.get(2));
137 assert_eq!(t!("c"), match_text!(cap.get(4).unwrap()));
138
139 assert_eq!(None, cap.name("a"));
140 assert_eq!(t!("c"), match_text!(cap.name("b").unwrap()));
141}
142
143#[test]
144fn sub_capture_matches() {

Callers

nothing calls this directly

Calls 2

unwrapMethod · 0.80
capturesMethod · 0.45

Tested by

no test coverage detected