summaryrefslogtreecommitdiff
path: root/android/OldPhoneNumberUtilsTest.cpp
AgeCommit message (Collapse)Author
2019-05-01Unit test of strict match on russian number.Hui Yu
Bug: 129698226 Test: atest external/sqlite/android Change-Id: Ifcea4f77f73b8f669a4f3b11a6c2e11a97580bc4
2017-07-18Fix false positives comparing local and intl numbersFrancisco Pimenta
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