Browse Source

Write testcases for parseWithOptions

We had to switch up the deprecated test cases of parseAndKeepRawInput and replaced them with parseWithOptions. It includes the phonenumber that has to be parsed and the options such as if the raw input should be kept or what the default regioncode is.
pull/3730/head
karoljk 1 year ago
parent
commit
90270c70dc
3 changed files with 243 additions and 257 deletions
  1. +0
    -16
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  2. +239
    -240
      java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
  3. +4
    -1
      pending_code_changes.txt

+ 0
- 16
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -3136,16 +3136,10 @@ public class PhoneNumberUtil {
* @throws NumberParseException if the string is not considered to be a viable phone number (e.g.
* too few or too many digits) or if no default region was supplied and the number is not in
* international format (does not start with +)
* @deprecated Use {@link #parseWithOptions(CharSequence, ParsingOptions)} instead.
*/
@Deprecated
public PhoneNumber parse(CharSequence numberToParse, String defaultRegion)
throws NumberParseException {
PhoneNumber phoneNumber = new PhoneNumber();
parseWithOptions(
numberToParse,
new ParsingOptions().setDefaultRegion(defaultRegion),
phoneNumber);
parseWithOptions(
numberToParse,
new ParsingOptions().setDefaultRegion(defaultRegion),
@ -3156,19 +3150,13 @@ public class PhoneNumberUtil {
/**
* Same as {@link #parse(CharSequence, String)}, but accepts mutable PhoneNumber as a
* parameter to decrease object creation when invoked many times.
* @deprecated Use {@link #parseWithOptions(CharSequence, ParsingOptions, PhoneNumber)} instead.
*/
@Deprecated
public void parse(CharSequence numberToParse, String defaultRegion, PhoneNumber phoneNumber)
throws NumberParseException {
parseWithOptions(
numberToParse,
new ParsingOptions().setDefaultRegion(defaultRegion),
phoneNumber);
parseWithOptions(
numberToParse,
new ParsingOptions().setDefaultRegion(defaultRegion),
phoneNumber);
}
/**
@ -3190,10 +3178,6 @@ public class PhoneNumberUtil {
public PhoneNumber parseAndKeepRawInput(CharSequence numberToParse, String defaultRegion)
throws NumberParseException {
PhoneNumber phoneNumber = new PhoneNumber();
parseWithOptions(
numberToParse,
new ParsingOptions().setKeepRawInput(true).setDefaultRegion(defaultRegion),
phoneNumber);
parseWithOptions(
numberToParse,
new ParsingOptions().setKeepRawInput(true).setDefaultRegion(defaultRegion),


+ 239
- 240
java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
File diff suppressed because it is too large
View File


+ 4
- 1
pending_code_changes.txt View File

@ -1 +1,4 @@
Code changes:
- Introduced new function parseWithOptions to customize the parser's behaviour
- Deprecated parseAndKeepRawInput in favor of parseWithOptions
-

Loading…
Cancel
Save