Reputation: 7826
I am currently beginning writing some unit test in my project. However, seems that I met some issue:
- (void)testThatItIsValidNumber
{
BOOL result1 = [NSString isValidNumber:@"1234567890987654"];
BOOL result2 = [NSString isValidNumber:@" ^123dadaj"];
BOOL result3 = [NSString isValidNumber:@"123 09 123"];
BOOL result4 = [NSString isValidNumber:@"~#)(^%@*#&Bhadahj1@"];
XCTAssertFalse(result1);
XCTAssert(result2);
XCTAssertFalse(result3);
XCTAssert(result4);
}
This gave me an error:
caught "NSInvalidArgumentException", "+[NSString isValidNumber]: unrecognized selector sent to class 0x1069448e0"
Any one can guide me to the right way?
Edit:
+ (BOOL)isValidNumber:(NSString *)value {
const char *cvalue = [value UTF8String];
unsigned long len = strlen(cvalue);
for (int i = 0; i < len; i++) {
if(!isNumber(cvalue[i])){
return FALSE;
}
}
return TRUE;
}
Upvotes: 3
Views: 924
Reputation: 10144
Make sure that your category is added to your test target otherwise it won't be available in your tests.
To do that, just select your class from the file navigator, and press the document inspector on the right side. In the Target membership section, check your test target.
Upvotes: 1