我正在为我的项目编写单元测试。以下是单元测试:
-(void)testRecordMapControl
{
MKPinAnnotationView *tempMap = [[MKPinAnnotationView alloc] init];
NSMutableDictionary *testDict = [mAutomate_MapView recordMapControl:1 :0 :1 :[ @"-1" stringByAppendingFormat:SEPARATOR@"-2"] :tempMap :MAPVIEW];
// STAssertNotNil(testDict, @"not null");
}
以下是正在测试的方法:
+(NSMutableDictionary *) recordMapControl:(int)globalIndex:(int) mapCntlIndex :(int) controlIdIndex :(NSString *) viewIndexInList :(id) control :(NSString *)controlType{
MKPinAnnotationView *mapView = (MKPinAnnotationView*)control;
mAutomate_ViewBean *mapBean = [[mAutomate_ViewBean alloc] init];
NSMutableDictionary *tempDict = [mapBean proxyForJsonCreation];
[tempDict setValue:[NSString stringWithFormat:@"%d",[mapView animatesDrop]] ? [NSString stringWithFormat:@"%d",[mapView animatesDrop]]:@"null" forKey:ANIMATESDROP];
[tempDict setValue:[NSString stringWithFormat:@"%d",[mapView pinColor]] ? [NSString stringWithFormat:@"%d",[mapView pinColor]]:@"null" forKey:PINCOLOR];
return tempDict;
}
我在执行以下行时收到BAD ACCESS错误:
[tempDict setValue:[NSString stringWithFormat:@"%d",[mapView animatesDrop]] ? [NSString stringWithFormat:@"%d",[mapView animatesDrop]]:@"null" forKey:ANIMATESDROP];
请有人能告诉我哪里出错了吗?
答案 0 :(得分:0)
animatedDrop会返回一个双精度数吗?看起来它正在回归布尔......
[tempDict setValue:([mapView animatesDrop] ? @"1" : @"null") forKey:ANIMATESDROP];