summaryrefslogtreecommitdiff
path: root/android/PhoneNumberUtilsTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix false positives comparing local and intl numbersFrancisco Pimenta2017-07-181-18/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously when comparing local phone numbers with international it was possible to match the wrong number because the first digit of the area code was being treated as a skippable trunk digit, e.g: "550-123-4567" would be considered equal to "+14501234567". Since there are two different algorithms (loose/old and strict) there are two solutions with the same basic goal: Only ignore mismatches if there's an actual extra digit which could possibly be the trunk digit, i.e: "0550-123-4567" is acceptable as equal to "+15501234567". NB: The US not having a trunk digit to begin with is a different issue entirely - the code is agnostic on which country has which trunk digits! For "loose" matching we achieve this by checking the length of the mismatch. For "strict" matching we keep track of the supposed trunk digit and compare it against the current position in match. So for the above example 5 != 4. Several new unit tests were added (including replicating tests for OldPhoneNumberUtils). I broke down the c++ tests into smaller methods for additional readability. NB: By adding more tests I uncovered that two digit trunk prefixes were never handled correctly for the "strict" matching case. "Loose" matching is much more robust. I commented out the "strict" test cases. Test: All unit tests pass for PhoneNumberUtilsTest, OldPhoneNumberUtilsTest and DatabaseGeneralTest. Bug: 63179537 Bug: 63178542 Bug: 62916088 Change-Id: Idc2a1c2c2f64ed29995208503de4755c521e1c82
* external/sqlite/android cleanup.Elliott Hughes2016-09-131-112/+72
| | | | | | | | | Removes dead use of deprecated ucol_getShortDefinitionString. Converts PhoneNumberUtils tests to gtest. Bug: http://b/31459453 Change-Id: I4662e25d711868e21afb0661602c64852f0cef65
* Adding a custom function to support legacy API compatibilityDmitri Plotnikov2011-01-061-2/+36
| | | | | Bug: 3210604 Change-Id: I6e9a20ec7887375b67c42a28cff54e2e9d399ea6
* fix failing test.Wei Huang2009-09-211-1/+1
| | | | Change-Id: I11fc145464e29364dbf302c1e607a07031e1821d
* Revert the default phone number comparation algorithm.Daisuke Miyakawa2009-09-201-2/+2
| | | | | | | | | Now developers have to explicitly set the third argument of PHONE_NUMBERS_COMPARE() into 1, when they want to use "strict" phone number comparation algorithm, which was used in Donut. In default, PHONE_NUMBER_COMPARE() now uses "loose" phone number comparation algorithm, which had been used in Cupcake. Internal issue id: 1892808
* Fix the implementation of phone_number_compare in accordance with the tests ↵Daisuke Miyakawa2009-09-021-0/+5
| | | | | | in PhoneNumberUtils.java. Due to the Thailand's special case, the code became a little nastier than before, but I believe it is inevitable...
* fix bug 2015059: where the native sqlite comparison method ↵Wei Huang2009-08-311-0/+17
| | | | | | | | phone_number_compare() treated all alpha addresses as the same phone number. - changed phone_number_compare() to handle alpha chars. Before this change the algorithm skipped over all non-dialable chars for comparison, and thus treating "foo" and "bar" as the same addresses. now we don't skip any char that's alpha. This would treat "foo" and "bar" as separate addresses, as well as treating "1-800-flowers" and "800-flowers" as the same number.
* One more test, which is succesful (and should be successful), but ↵Daisuke Miyakawa2009-07-201-0/+1
| | | | unexpectedly...
* Fix a bug in which "16\d+6" matches 166 and the number is handled as ↵Daisuke Miyakawa2009-07-201-0/+1
| | | | Thailand one...
* "Rewrite" PhoneNumberUtil so that it compares two phone strings using as ↵Daisuke Miyakawa2009-07-071-0/+137
| | | | | | | | | | | many characters as possible, unlike the previous implementation. Unlike the change 5480, this considers the NDD-problem mentioned in the internal issue 1949010. This time, 1-650-555-1234 and 650-555-1234 match each other. Added tests for the cases. related internal issue: 1868702, 1949010
* Revert ""Rewrite" PhoneNumberUtil so that it compares two phone strings ↵Daisuke Miyakawa2009-07-071-129/+0
| | | | | | | | using as many characters as possible, unlike the previous implementation." This reverts commit de43094477419f8a190a6f97b47d346827310a02. related internal issue: 1949010
* "Rewrite" PhoneNumberUtil so that it compares two phone strings using as ↵Daisuke Miyakawa2009-06-261-0/+129
many characters as possible, unlike the previous implementation. The new implementation considers country code seriously. To confirm this change does not do something wrong, I also created another change (https://android-git.corp.google.com/g/Gerrit#change,4036). All tests related to PhoneNumberUtils pass, including Thailand's ugly buggy behavior around country code handling :-P Also Add tests for PhoneNumberUtils, which can be executed in the usual workstation like this: > g++ -Wall external/sqlite/android/PhoneNumberUtils.cpp external/sqlite/android/PhoneNumberUtilsTest.cpp > ./a.out This change fixes the internal bug 1868702.