I am working on kiwi framework for testing by following
myStack.m
- (id) init {
if (self = [super init]) {
_data = [[NSMutableArray alloc] initWithCapacity:4];
}
return self;
}
- (void) push:(int)numberToPush {
[self.data addObject:numberToPush];
}
- (int)top {
return [[self.data lastObject] integerValue];
}
-(int)numberOfItem {
return [self.data count];
}
and testing is
SPEC_BEGIN(MyStack)
describe(@"The stack", ^{
__block MyStack *stack;
context(@"when created", ^{
beforeAll(^{
stack = [[MyStack alloc] init];
});
it(@"is not nil.", ^{
[stack shouldNotBeNil];
});
it(@"allows me to count the item of stack", ^{
[stack push:5];
[[stack should] haveCountOf:1];
});
});
});
SPEC_END
However, I am getting BAD_EXCESS with Expectations
testing.I dont know why getting this error. All helps are welcomed here.
It looks like you are trying to add an
int
to yourNSMutableArray
. You can only add objects to anNSArray
, not primitive types. Try boxing in anNSNumber
in your implementation ofpush:
: