-
Notifications
You must be signed in to change notification settings - Fork 495
Add max code length tests, fix behavior for Python, Rust and C++ #300
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
Conversation
775daa2
to
4fc7378
Compare
4fc7378
to
c001f45
Compare
The C++ library seems to be failing the new tests. If you have time, would you mind looking into it? If not, I can take a look next week. |
38f46c7
to
66a4636
Compare
Sure thing, I fixed the C++ issue (was returning the original size in the CodeArea object) by moving the truncation a bit earlier. |
ab80f24
to
b9976bf
Compare
@zongweil I believe this is good to go, all implementations are now passing the tests I added to verify the max code length behavior. |
cpp/openlocationcode.cc
Outdated
@@ -199,7 +199,7 @@ std::string Encode(const LatLng &location) { | |||
|
|||
CodeArea Decode(const std::string &code) { | |||
// Make a copy that doesn't have the separator and stops at the first padding | |||
// character. | |||
// character, and is constrained to the maximum length. | |||
std::string clean_code(code); | |||
clean_code.erase( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code from lines 203-210 seems to be duplicated in CodeLength(). Can you extract and de-dupe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing! Done.
9bd842d
to
1e6891e
Compare
As documented in issue number 190: 1. If you ask the library to encode a lat/long with more than 15 digits, the library will return a plus code with 15 digits. 2. If you ask the library to decode a plus code with more than 15 digits, the library will only take the first 15 digits into account with the returned code area. 3. Plus codes with more than 15 digits will be treated as valid if all the other validity constraints are satisfied. If the plus code has an invalid character after the 15th digit, it will be treated as invalid.
Limit decoding to first 15 significant digits.
Decode was only processing the first 15 significant digits, but was returning the length of the entire code. Refactored a little to move the truncation earlier.
1e6891e
to
76b869c
Compare
@zongweil this should be ready now, PTAL :) |
cpp/openlocationcode.cc
Outdated
@@ -92,6 +92,19 @@ double adjust_latitude(double latitude_degrees, size_t code_length) { | |||
return latitude_degrees - precision / 2; | |||
} | |||
|
|||
// Remove the separateor and padding characters from the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks! One typo, I'll merge it in right after :). |
76b869c
to
af246f0
Compare
Replaces #287, moves tests to data files.
Includes #299 (I will rebase when that is merged).