Remove useless test methods from NBAsYouTypeFormatter

This commit is contained in:
Dave MacLachlan 2017-11-03 10:10:37 -07:00
parent 42ed67045b
commit 3c594aebac
3 changed files with 32 additions and 55 deletions

View File

@ -14,9 +14,7 @@
@interface NBAsYouTypeFormatter : NSObject
- (id)initWithRegionCode:(NSString *)regionCode;
- (id)initWithRegionCodeForTest:(NSString *)regionCode;
- (id)initWithRegionCode:(NSString *)regionCode bundle:(NSBundle *)bundle;
- (id)initWithRegionCodeForTest:(NSString *)regionCode bundle:(NSBundle *)bundle;
- (NSString *)inputString:(NSString *)string;
- (NSString *)inputStringAndRememberPosition:(NSString *)string;

View File

@ -265,11 +265,6 @@
return [self initWithRegionCode:regionCode bundle:[NSBundle mainBundle]];
}
- (id)initWithRegionCodeForTest:(NSString*)regionCode
{
return [self initWithRegionCodeForTest:regionCode bundle:[NSBundle mainBundle]];
}
- (id)initWithRegionCode:(NSString*)regionCode bundle:(NSBundle *)bundle
{
self = [self init];
@ -299,22 +294,6 @@
}
- (id)initWithRegionCodeForTest:(NSString*)regionCode bundle:(NSBundle *)bundle
{
self = [self init];
if (self) {
self.phoneUtil_ = [NBPhoneNumberUtil sharedInstance];
self.defaultCountry_ = regionCode;
self.currentMetaData_ = [self getMetadataForRegion_:self.defaultCountry_];
self.defaultMetaData_ = self.currentMetaData_;
self.EMPTY_METADATA_ = [[NBPhoneMetaData alloc] init];
}
return self;
}
/**
* The metadata needed by this class is the same for all regions sharing the
* same country calling code. Therefore, we return the metadata for "main"

View File

@ -17,7 +17,7 @@
@implementation NBAsYouTypeFormatterTest
- (void)testInvalidRegion {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:NB_UNKNOWN_REGION];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:NB_UNKNOWN_REGION];
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
XCTAssertEqualObjects(@"+4", [f inputDigit:@"4"]);
XCTAssertEqualObjects(@"+48 ", [f inputDigit:@"8"]);
@ -39,7 +39,7 @@
}
- (void)testInvalidPlusSign {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:NB_UNKNOWN_REGION];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:NB_UNKNOWN_REGION];
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
XCTAssertEqualObjects(@"+4", [f inputDigit:@"4"]);
XCTAssertEqualObjects(@"+48 ", [f inputDigit:@"8"]);
@ -71,7 +71,7 @@
// See http://code.google.com/p/libphonenumber/issues/detail?id=36
// The bug occurred last time for countries which have two formatting rules
// with exactly the same leading digits pattern but differ in length.
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:NB_UNKNOWN_REGION];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:NB_UNKNOWN_REGION];
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
XCTAssertEqualObjects(@"+8", [f inputDigit:@"8"]);
XCTAssertEqualObjects(@"+81 ", [f inputDigit:@"1"]);
@ -91,7 +91,7 @@
}
- (void)testCountryWithSpaceInNationalPrefixFormattingRule {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"BY"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"BY"];
XCTAssertEqualObjects(@"8", [f inputDigit:@"8"]);
XCTAssertEqualObjects(@"88", [f inputDigit:@"8"]);
XCTAssertEqualObjects(@"881", [f inputDigit:@"1"]);
@ -106,7 +106,7 @@
}
- (void)testCountryWithSpaceInNationalPrefixFormattingRuleAndLongNdd {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"BY"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"BY"];
XCTAssertEqualObjects(@"9", [f inputDigit:@"9"]);
XCTAssertEqualObjects(@"99", [f inputDigit:@"9"]);
XCTAssertEqualObjects(@"999", [f inputDigit:@"9"]);
@ -120,7 +120,7 @@
}
- (void)testAYTFUS {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
XCTAssertEqualObjects(@"6", [f inputDigit:@"6"]);
XCTAssertEqualObjects(@"65", [f inputDigit:@"5"]);
XCTAssertEqualObjects(@"650", [f inputDigit:@"0"]);
@ -214,7 +214,7 @@
}
- (void)testAYTFUSFullWidthCharacters {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
XCTAssertEqualObjects(@"\uFF16", [f inputDigit:@"\uFF16"]);
XCTAssertEqualObjects(@"\uFF16\uFF15", [f inputDigit:@"\uFF15"]);
XCTAssertEqualObjects(@"650", [f inputDigit:@"\uFF10"]);
@ -228,7 +228,7 @@
}
- (void)testAYTFUSMobileShortCode {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
XCTAssertEqualObjects(@"*", [f inputDigit:@"*"]);
XCTAssertEqualObjects(@"*1", [f inputDigit:@"1"]);
XCTAssertEqualObjects(@"*12", [f inputDigit:@"2"]);
@ -237,7 +237,7 @@
}
- (void)testAYTFUSVanityNumber {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
XCTAssertEqualObjects(@"8", [f inputDigit:@"8"]);
XCTAssertEqualObjects(@"80", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"800", [f inputDigit:@"0"]);
@ -253,7 +253,7 @@
}
- (void)testAYTFAndRememberPositionUS {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
XCTAssertEqualObjects(@"1", [f inputDigitAndRememberPosition:@"1"]);
XCTAssertEqual(1, [f getRememberedPosition]);
XCTAssertEqualObjects(@"16", [f inputDigit:@"6"]);
@ -389,7 +389,7 @@
}
- (void)testAYTFGBFixedLine {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"GB"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"GB"];
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"02", [f inputDigit:@"2"]);
XCTAssertEqualObjects(@"020", [f inputDigit:@"0"]);
@ -406,7 +406,7 @@
}
- (void)testAYTFGBTollFree {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"GB"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"GB"];
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"08", [f inputDigit:@"8"]);
XCTAssertEqualObjects(@"080", [f inputDigit:@"0"]);
@ -421,7 +421,7 @@
}
- (void)testAYTFGBPremiumRate {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"GB"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"GB"];
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"09", [f inputDigit:@"9"]);
XCTAssertEqualObjects(@"090", [f inputDigit:@"0"]);
@ -436,7 +436,7 @@
}
- (void)testAYTFNZMobile {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"NZ"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"NZ"];
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"02", [f inputDigit:@"2"]);
XCTAssertEqualObjects(@"021", [f inputDigit:@"1"]);
@ -451,7 +451,7 @@
}
- (void)testAYTFDE {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"DE"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"DE"];
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"03", [f inputDigit:@"3"]);
XCTAssertEqualObjects(@"030", [f inputDigit:@"0"]);
@ -502,7 +502,7 @@
}
- (void)testAYTFAR {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"AR"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"AR"];
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"01", [f inputDigit:@"1"]);
XCTAssertEqualObjects(@"011", [f inputDigit:@"1"]);
@ -517,7 +517,7 @@
}
-(void)testAYTFARMobile {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"AR"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"AR"];
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
XCTAssertEqualObjects(@"+5", [f inputDigit:@"5"]);
XCTAssertEqualObjects(@"+54 ", [f inputDigit:@"4"]);
@ -536,7 +536,7 @@
-(void)testAYTFKR {
// +82 51 234 5678
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"KR"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"KR"];
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
XCTAssertEqualObjects(@"+8", [f inputDigit:@"8"]);
XCTAssertEqualObjects(@"+82 ", [f inputDigit:@"2"]);
@ -625,7 +625,7 @@
}
-(void)testAYTF_MX {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"MX"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"MX"];
// +52 800 123 4567
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
@ -710,7 +710,7 @@
}
-(void)testAYTF_International_Toll_Free {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
// +800 1234 5678
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
XCTAssertEqualObjects(@"+8", [f inputDigit:@"8"]);
@ -729,7 +729,7 @@
-(void)testAYTFMultipleLeadingDigitPatterns {
// +81 50 2345 6789
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"JP"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"JP"];
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
XCTAssertEqualObjects(@"+8", [f inputDigit:@"8"]);
XCTAssertEqualObjects(@"+81 ", [f inputDigit:@"1"]);
@ -785,7 +785,7 @@
}
-(void)testAYTFLongIDD_AU {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"AU"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"AU"];
// 0011 1 650 253 2250
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"00", [f inputDigit:@"0"]);
@ -842,7 +842,7 @@
}
-(void)testAYTFLongIDD_KR {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"KR"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"KR"];
// 00300 1 650 253 2222
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"00", [f inputDigit:@"0"]);
@ -863,7 +863,7 @@
}
-(void)testAYTFLongNDD_KR {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"KR"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"KR"];
// 08811-9876-7890
XCTAssertEqualObjects(@"0", [f inputDigit:@"0"]);
XCTAssertEqualObjects(@"08", [f inputDigit:@"8"]);
@ -899,7 +899,7 @@
}
-(void)testAYTFLongNDD_SG {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"SG"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"SG"];
// 777777 9876 7890
XCTAssertEqualObjects(@"7", [f inputDigit:@"7"]);
XCTAssertEqualObjects(@"77", [f inputDigit:@"7"]);
@ -919,7 +919,7 @@
-(void)testAYTFShortNumberFormattingFix_AU {
// For Australia, the national prefix is not optional when formatting.
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"AU"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"AU"];
// 1234567890 - For leading digit 1, the national prefix formatting rule has
// first group only.
@ -995,7 +995,7 @@
-(void)testAYTFShortNumberFormattingFix_KR {
// For Korea, the national prefix is not optional when formatting, and the
// national prefix formatting rule doesn't consist of only the first group.
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"KR"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"KR"];
// 111
XCTAssertEqualObjects(@"1", [f inputDigit:@"1"]);
@ -1037,7 +1037,7 @@
-(void)testAYTFShortNumberFormattingFix_MX {
// For Mexico, the national prefix is optional when formatting.
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"MX"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"MX"];
// 911
XCTAssertEqualObjects(@"9", [f inputDigit:@"9"]);
@ -1076,7 +1076,7 @@
}
-(void)testAYTFNoNationalPrefix {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"IT"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"IT"];
XCTAssertEqualObjects(@"3", [f inputDigit:@"3"]);
XCTAssertEqualObjects(@"33", [f inputDigit:@"3"]);
XCTAssertEqualObjects(@"333", [f inputDigit:@"3"]);
@ -1087,7 +1087,7 @@
-(void)testAYTFShortNumberFormattingFix_US {
// For the US, an initial 1 is treated specially.
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
// 101 - Test that the initial 1 is not treated as a national prefix.
XCTAssertEqualObjects(@"1", [f inputDigit:@"1"]);
@ -1108,7 +1108,7 @@
}
-(void)testAYTFDescription {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
[f inputDigit:@"1"];
[f inputDigit:@"6"];
@ -1161,7 +1161,7 @@
}
-(void)testAYTFNumberPatternsBecomingInvalidShouldNotResultInDigitLoss {
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"CN"];
NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"CN"];
XCTAssertEqualObjects(@"+", [f inputDigit:@"+"]);
XCTAssertEqualObjects(@"+8", [f inputDigit:@"8"]);