• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem writing unit tests - "Incompatible types in initialization"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem writing unit tests - "Incompatible types in initialization"


  • Subject: Problem writing unit tests - "Incompatible types in initialization"
  • From: Ian Piper <email@hidden>
  • Date: Sun, 25 Oct 2009 20:08:42 +0000

Hi,

I'm having a problem getting a unit test to run. It's quite a simple one, based on a sample project that I developed and that does actually work. It's loosely based on the Apple Temperature Converter project.

I have a Converter class that has a float property called originalTemperature. It also has a method called convertCToF that takes an originalTemperature and returns the converted temperature, also as a float. So I am calling this using temperatureInF = instanceOfConverter.convertCToF. As I say, this works fine.

I created a test case that creates an instance of Converter, then sets its originalTemp value, then tries to get back the converted value:

testConverter = Converter.new;

[testConverter setValue:[NSNumber numberWithFloat:25.0] forKey:@"originalTemp"]; // Builds OK to here

NSNumber *newTemperatureInF = [testConverter convertCToF]; // This is where I get the error "Incompatible types in initialization"

STAssertEquals(77.0f, [newTemperatureInF floatValue], @"F value should be 25, and test value was %f", [newTemperatureInF floatValue]);

I am importing Converter.h in my TCTests.m file (where this method is located) and I have selected it for linking in the Detail pane for the project.
I'm confused because I am passing in a float, the method takes in and returns a float. NSNumber ought to be able to cope with a returned float. I'm clearly making a very basic error but have bashed my head against it to the point where I have the phrase "Incompatible types" in reverse burned onto my forehead. Google was not my friend on this occasion.


Can anyone guide me out of this black hole?

Thanks,


Ian. -- _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Problem writing unit tests - "Incompatible types in initialization"
      • From: Chris Hanson <email@hidden>
    • Re: Problem writing unit tests - "Incompatible types in initialization"
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: Crash drawing image
  • Next by Date: Re: Problem writing unit tests - "Incompatible types in initialization"
  • Previous by thread: Re: Make a solid line look like 3D
  • Next by thread: Re: Problem writing unit tests - "Incompatible types in initialization"
  • Index(es):
    • Date
    • Thread