Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCMock expect and return gives signature error

I have a method of the followng signature;

- (NSInteger) getFirstVisitTimeStamp;

When I use OCMock to mock and return a value, the test fails with the below error.

[[[[YSNYI13NMockingTest mockedYI13N] expect] andReturnValue:@(12345)] getFirstVisitTimeStamp];

Error:

file:///%3Cunknown%3E: test failure:
failed: Return value does not match method signature; signature declares 'q' but value is 'i'.

Can anyone help ?

like image 355
mohkhan Avatar asked Jun 03 '14 21:06

mohkhan


1 Answers

On 64-bit devices, NSInteger is declared as long, but the value you are returning is being typed as int. Try forcing your value to a long by adding l after the number:

[[[[YSNYI13NMockingTest mockedYI13N] expect] andReturnValue:@(12345l)] getFirstVisitTimeStamp];
like image 52
michaels Avatar answered Oct 11 '22 01:10

michaels