views:

54

answers:

1

Hi,

I have the following test in my unit test suite:

STAssertEquals(0, [[newUnit itemsWithinBasketFrom:[NSDate dateYesterday] through:[NSDate dateTomorrow]] count],
               @"A unit with no items should return 0 when asked for items in place within a date range. (count=%i)",
               [[newUnit itemsWithinBasketFrom:[NSDate dateYesterday] through:[NSDate dateTomorrow]] count]);

And the output from the build console is: Type mismatch -- A unit with no items should return nil when asked for items in basket within a date range. (count=0).

If count is 0, and I'm testing its equality against 0, then why do I get a type mismatch?

Thanks!

A: 

IMO, the problem is not the count is 0 or not. What is the returned type of [[newUnit itemsInPlaceWithinDateRangeFrom:[NSDate dateYesterday] through:[NSDate dateTomorrow]] count]. Maybe your type is not correct (like double), then when you try to print it out, it appears to be 0. And because it can not compare int and double, it generates type mismatch. It is just my guess

vodkhang
The `itemsWithinBasketFrom:through` function returns an `NSSet*`. `count` should be an available method on an NSSet.
Greg Smalls
Can you try with STAssertTrue, I will look up again the STAssertEquals
vodkhang