aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMSystemVersionTest.m
diff options
context:
space:
mode:
authorGravatar Boris Vidolov <borisv@google.com>2018-05-18 15:14:41 -0700
committerGravatar Thomas Van Lenten <thomasvl@google.com>2018-05-21 15:22:24 -0400
commitb2a7e116b444b18da0be6efd031b82f00aa9c6ea (patch)
treef5e114fa158b4796462b3406feae38e8fe3faf70 /Foundation/GTMSystemVersionTest.m
parent484a1bb5b366119a79863801c92d8a0abc3c6ebb (diff)
Allow for building GTMSystemVersion under deployment target of 10.8 and above.
- Keep Gestalt APIs till 10.8. - On 10.8 and 10.9 use sysctl and infer the OS version from there. - On 10.10+ use NSProcessInfo. - Added unit test to cover it.
Diffstat (limited to 'Foundation/GTMSystemVersionTest.m')
-rw-r--r--Foundation/GTMSystemVersionTest.m26
1 files changed, 26 insertions, 0 deletions
diff --git a/Foundation/GTMSystemVersionTest.m b/Foundation/GTMSystemVersionTest.m
index b881233..42a1b77 100644
--- a/Foundation/GTMSystemVersionTest.m
+++ b/Foundation/GTMSystemVersionTest.m
@@ -90,4 +90,30 @@
XCTAssertTrue([GTMSystemVersion isBuildLessThan:largeVersion]);
}
+
+#ifdef GTM_MACOS_SDK
+- (void)testMacOSVersion {
+ SInt32 major = -1;
+ SInt32 minor = -1;
+ SInt32 bugfix = -1;
+
+ [GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugfix];
+ NSDictionary *versionPlistContents =
+ [NSDictionary dictionaryWithContentsOfFile:
+ @"/System/Library/CoreServices/SystemVersion.plist"];
+ XCTAssertNotNil(versionPlistContents);
+ NSString *version =
+ [versionPlistContents objectForKey:@"ProductVersion"];
+ XCTAssertNotNil(version);
+ NSArray *pieces = [version componentsSeparatedByString:@"."];
+ XCTAssertTrue([pieces count] > 2);
+ XCTAssertEqual(major, (SInt32)[[pieces objectAtIndex:0] integerValue]);
+ XCTAssertEqual(minor, [[pieces objectAtIndex:1] integerValue]);
+ if ([pieces count] > 2) {
+ XCTAssertEqual(bugfix, [[pieces objectAtIndex:2] integerValue]);
+ } else {
+ XCTAssertEqual(bugfix, 0, @"possible beta OS");
+ }
+}
+#endif
@end