Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare CGFloat in XCTestCase?

Tags:

xctest

I can't understand this at all. What is the problem here?

I've tried typing 1.0, 1.0f, (CGFloat) 1.0 and (CGFloat)(2.0 - 1.0). Every time the same error.

Screenshot from xcode

like image 210
hfossli Avatar asked Oct 07 '13 18:10

hfossli


1 Answers

I would recommend using FLT_EPSILON for this:

XCTAssertEqualWithAccuracy(mov.lastDelta, 0.0f, FLT_EPSILON, @"");

Unless you have some reason to require a larger epsilon.

like image 64
Rob Jones Avatar answered Nov 14 '22 23:11

Rob Jones