Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-05-2009, 08:28 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 16
Cliff76 is on a distinguished road
Question Use a struct with OCMock?

First off, sorry for the x-post! I posted on StackOverflow before I discovered this site so head over there for more of the same. I am having trouble using passing structs to mocks using OCMock. I'm still relatively new to ObjC, Cocoa, XCode and the whole nine yards but I'm no stranger to TDD and mock objects. I have a case where I need to mock a "thing" that takes struct params and returns a struct and I'm having soo much trouble. Has anybody here done TDD w/ OCMock? If not, what's your excuse? If you have seen similar issues could you please weigh in? Thanx in advance!

Your friendly neighborhoood ObjC Developer,
Cliff
Cliff76 is offline   Reply With Quote
Old 02-06-2009, 08:24 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 16
Cliff76 is on a distinguished road
Question return struct from OCMock - Detailed code

In my example I try to wrap the struct in an NSValue and pass that as the return value for the mock. Then when the object I'm testing calls into the mock the return value gets munged. So either I'm incorrectly wrapping the value or I'm incorrectly creating it.
Here's my define for wrapping the struct:
Code:
#define OCMOCK_STRUCT(atype, variable) [NSValue value:&variable withObjCType:@encode(atype)]
Here's the code that sets the expectation:
Code:
	CLLocationCoordinate2D ulLL = (CLLocationCoordinate2D){1.0f,1.0f};
	CLLocationCoordinate2D lrLL = (CLLocationCoordinate2D){2.0f,2.0f};
	[[[(id)aMap expect] andReturn:OCMOCK_STRUCT(CLLocationCoordinate2D, ulLL)] pixelToLatLong:(CGPoint){0,0}];
	[[[(id)aMap expect] andReturn:OCMOCK_STRUCT(CLLocationCoordinate2D, lrLL)] pixelToLatLong:(CGPoint){320,460}];//lower right point
When I call into my mock I get garbage in the mock return values. Help?
Cliff76 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 323
6 members and 317 guests
Anwerbl, guusleijsten, HowEver, LEARN2MAKE, mottdog, Objective Zero
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,879
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:37 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0