Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
[UICommon] Add testing support up to iOS 4.2 for TTOSVersionIsAtLeast.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Oct 14, 2010
1 parent 46e7443 commit 9919e15
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
48 changes: 27 additions & 21 deletions src/Three20UICommon/Sources/TTGlobalUICommon.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,27 +48,33 @@ BOOL TTOSVersionIsAtLeast(float version) {
// Floating-point comparison is pretty bad, so let's cut it some slack with an epsilon. // Floating-point comparison is pretty bad, so let's cut it some slack with an epsilon.
static const CGFloat kEpsilon = 0.0000001; static const CGFloat kEpsilon = 0.0000001;


#ifdef __IPHONE_4_0 #ifdef __IPHONE_4_2
return 4.0 - version >= -kEpsilon; return 4.2 - version >= -kEpsilon;
#endif #endif
#ifdef __IPHONE_3_2 #ifdef __IPHONE_4_1
return 3.2 - version >= -kEpsilon; return 4.1 - version >= -kEpsilon;
#endif #endif
#ifdef __IPHONE_3_1 #ifdef __IPHONE_4_0
return 3.1 - version >= -kEpsilon; return 4.0 - version >= -kEpsilon;
#endif #endif
#ifdef __IPHONE_3_0 #ifdef __IPHONE_3_2
return 3.0 - version >= -kEpsilon; return 3.2 - version >= -kEpsilon;
#endif #endif
#ifdef __IPHONE_2_2 #ifdef __IPHONE_3_1
return 2.2 - version >= -kEpsilon; return 3.1 - version >= -kEpsilon;
#endif #endif
#ifdef __IPHONE_2_1 #ifdef __IPHONE_3_0
return 2.1 - version >= -kEpsilon; return 3.0 - version >= -kEpsilon;
#endif #endif
#ifdef __IPHONE_2_0 #ifdef __IPHONE_2_2
return 2.0 - version >= -kEpsilon; return 2.2 - version >= -kEpsilon;
#endif #endif
#ifdef __IPHONE_2_1
return 2.1 - version >= -kEpsilon;
#endif
#ifdef __IPHONE_2_0
return 2.0 - version >= -kEpsilon;
#endif
return NO; return NO;
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@
isa = PBXProject; isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Three20UICommon" */; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Three20UICommon" */;
compatibilityVersion = "Xcode 3.1"; compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1; hasScannedForEncodings = 1;
knownRegions = ( knownRegions = (
English, English,
Expand Down
18 changes: 18 additions & 0 deletions src/Three20UICommon/UnitTests/UICommonTests.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ - (void)testTTOSVersion {


/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)testTTOSVersionIsAtLeast { - (void)testTTOSVersionIsAtLeast {
#ifdef __IPHONE_4_2
STAssertTrue(TTOSVersionIsAtLeast(4.2), @"Should be at least 4.2.");
#else
STAssertTrue(!TTOSVersionIsAtLeast(4.2), @"Should be lower than 4.2.");
#endif

#ifdef __IPHONE_4_1
STAssertTrue(TTOSVersionIsAtLeast(4.1), @"Should be at least 4.1.");
#else
STAssertTrue(!TTOSVersionIsAtLeast(4.1), @"Should be lower than 4.1.");
#endif

#ifdef __IPHONE_4_0
STAssertTrue(TTOSVersionIsAtLeast(4.0), @"Should be at least 4.0.");
#else
STAssertTrue(!TTOSVersionIsAtLeast(4.0), @"Should be lower than 4.0.");
#endif

#ifdef __IPHONE_3_2 #ifdef __IPHONE_3_2
STAssertTrue(TTOSVersionIsAtLeast(3.2), @"Should be at least 3.2."); STAssertTrue(TTOSVersionIsAtLeast(3.2), @"Should be at least 3.2.");
#else #else
Expand Down

0 comments on commit 9919e15

Please sign in to comment.