Test cases for issue 29 on Github
#include <cassert>
#include <iostream>
void test_match(
jp::Regex &re, std::string
const &subject) {
bool out_of_range_occured = false;
size_t num = rm
.setRegexObject(&re)
.setNumberedSubstringVector(&matches)
.setSubject(subject)
.match();
assert(num > 0);
assert(matches[0][1] != "dummy");
assert(matches[0][2] != "dummy");
assert(matches[0][3] != "dummy");
try{
assert(matches[0].at(4) != "dummy");
} catch(std::out_of_range const & e){
out_of_range_occured = true;
}
if(!out_of_range_occured){
std::cout<<"E: std::out_of_range exception was not thrown. vecnum has more capture groups than expected.\n";
exit(1);
}
}
int main(){
test_match(re, "42bZ");
test_match(re, "23Z");
test_match(re, "54b");
test_match(re, "13");
return 0;
}
- Author
- Md Jahidul Hamid
-
Moritz Bunkus