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

Tests for invalid input strings, and bounds checks for coordinates #4

Merged
merged 5 commits into from Jul 13, 2016

Conversation

urschrei
Copy link
Member

@urschrei urschrei commented Jul 7, 2016

This PR removes the last of the unwrap() calls (forgot to push that commit last time – sorry) and adds:

  • A test for invalid string input
  • Latitude and longitude bounds checking for the coordinate encoder, and a test.

There's no point in attempting to encode invalid latitude or longitude
coordinates. The function's error value is the input, which we're
converting to an informative error message.

One drawback is the fact that encoding will now fail on the first error;
A more flexible approach would be to first check the values, and if the
vector contains errors, to extract them and their positions into the Err. 🤔

const MIN_LONGITUDE: f64 = -180.;
const MAX_LONGITUDE: f64 = 180.;
const MIN_LATITUDE: f64 = -90.0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these all end with . or should they all have .0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave off the trailing 0, but I like to be consistent. Will push a fix shortly.

@tmcw
Copy link
Collaborator

tmcw commented Jul 13, 2016

👍 awesome, thanks!

@tmcw tmcw merged commit 7eb824b into georust:master Jul 13, 2016
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 this pull request may close these issues.

None yet

2 participants