我想比较两个数组的等效对象,其中一个属性在我的类中,另一个在我的测试方法中。比较两个阵列的等效对象与Kiwi(Sentesting)套件
我无法直接比较,因为对象将被分开分配,因此具有不同的内存位置。
为了解决这个问题,我实现我的目标字符串中,列出其属性的描述:(VEL是一个CGPoint)
- (NSString *)description {
return [NSString stringWithFormat:@"vel:%.5f%.5f",vel.x,vel.y];
}
我测试:
NSLog(@"moveArray description: %@",[moveArray description]);
NSLog(@"currentMoves description: %@", [p.currentMoves description]);
[[theValue([moveArray description]) should] equal:theValue([p.currentMoves description])];
我的NSLog的产量:
Project[13083:207] moveArray description: (
"vel:0.38723-0.92198"
)
Project[13083:207] currentMoves description: (
"vel:0.38723-0.92198"
)
但我的测试失败:
/ProjectPath/ObjectTest.m:37: error: -[ObjectTest example] : 'Object should pass test' [FAILED], expected subject to equal <9086b104>, got <7099e004>
theValue初始化与字节KWValue和物镜-C型,并将其值与
- (id)initWithBytes:(const void *)bytes objCType:(const char *)anObjCType {
if ((self = [super init])) {
objCType = anObjCType;
value = [[NSValue alloc] initWithBytes:bytes objCType:anObjCType];
}
return self;
}
如何可以比较这两个阵列具有等价的值的对象?
完美,谢谢。欢迎来到SO! – quantumpotato
谢谢,很高兴我能帮上忙。 – Sticktron