Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bug in rure_captures_len #365

Merged
merged 1 commit into from
May 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions regex-capi/ctest/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ bool test_captures() {
}
passed = false;
}
size_t expect_captures_len = 3;
size_t captures_len = rure_captures_len(caps);
if (captures_len != expect_captures_len) {
if (DEBUG) {
fprintf(stderr,
"[test_captures] "
"expected capture group lenght to be %zd, but "
"got %zd\n",
expect_captures_len, captures_len);
}
passed = false;
goto done;
}
int32_t expect_capture_index = 2;
int32_t capture_index = rure_capture_name_index(re, "snowman");
if (capture_index != expect_capture_index) {
Expand Down
2 changes: 1 addition & 1 deletion regex-capi/src/rure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ ffi_fn! {

ffi_fn! {
fn rure_captures_len(captures: *const Captures) -> size_t {
unsafe { (*captures).0.len() / 2 }
unsafe { (*captures).0.len() }
}
}

Expand Down