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

Error handling of bad polyline still broken #39

Closed
urschrei opened this issue Apr 27, 2024 · 3 comments · Fixed by #45 · May be fixed by #40
Closed

Error handling of bad polyline still broken #39

urschrei opened this issue Apr 27, 2024 · 3 comments · Fixed by #45 · May be fixed by #40

Comments

@urschrei
Copy link
Member

urschrei commented Apr 27, 2024

Our fix in #37 has not worked: trying to decode the polyline 'ugh_ugh' gives an out of bounds error on line 142:

index out of bounds: the len is 7 but the index is 7.

@urschrei
Copy link
Member Author

cc @mattiZed

@urschrei
Copy link
Member Author

Repro (note ommission of should_panic directive on the test: we want to ensure that error values and panics are surfaced, and we want to distinguish between them, since we can handle errors, but not panics). We expect this test to return an Err value, but we have a logic error in our loop beginning on line 141:

#[test]
fn invalid_string() {
    let s = "ugh_ugh";
    let expected: Result<_, _> = Err("Cannot decode character at index 12".to_string());
    assert_eq!(decode_polyline(s, 5), expected);
}

@mattiZed
Copy link
Contributor

mattiZed commented Apr 27, 2024

Well then, I guess it's time to fix the algorithm instead of suppressing the symptoms - I might have a bit of free time for this next week as my org also relies on this crate in some sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants