iphone - STAssertEqualObjects compare class -
i trying cover test case
a method homecoming class object.
-(classname *)returnclass{ homecoming _class; } -(void)test_returnclass{ id returnobj; returnobj = [aclassnameobj returnclass]; stassertnotnil(returnobj, @"return not null value"); stassertequalobjects(returnobj, [iskindofclass: classname],@""); }
i want compare show stassertequalobjects
iskindofclass:classname
possible if yes please allow me know.
@all in advance
it's unclear you're asking.
if want check if returned object's class classname
or subclass, can utilize this:
stasserttrue([returnobj iskindofclass:[classname class]], nil);
if want check it's classname
and not subclass (this seems permissible in unit test, not in normal code), instead utilize this:
stasserttrue([returnobj ismemberofclass:[classname class]], nil);
if really want utilize stassertequalobjects, might utilize (this checks classes equal; not allow instance subclass):
stassertequalobjects([returnobj class], [classname class], nil);
personally, i'd stick alternative 1. alternative 2 i've never needed utilize in production code, , alternative 3 worse (there few legitimate uses of [foo class]
, comparing class -equals:
isn't 1 of them).
iphone ocunit
No comments:
Post a Comment