PageRenderTime 54ms CodeModel.GetById 1ms app.highlight 49ms RepoModel.GetById 2ms app.codeStats 0ms

/core/externals/update-engine/externals/google-toolbox-for-mac/Foundation/GTMSystemVersionTest.m

http://macfuse.googlecode.com/
Objective C | 93 lines | 63 code | 9 blank | 21 comment | 29 complexity | a1aed1b4cad6889722a9c79324bd672f MD5 | raw file
 1//
 2//  GTMSystemVersionTest.m
 3//
 4//  Copyright 2007-2008 Google Inc.
 5//
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
 9// 
10//  http://www.apache.org/licenses/LICENSE-2.0
11// 
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
17//
18
19#import "GTMSenTestCase.h"
20#import "GTMSystemVersion.h"
21
22@interface GTMSystemVersionTest : GTMTestCase
23@end
24
25@implementation GTMSystemVersionTest
26- (void)testBasics {
27  SInt32 major;
28  SInt32 minor;
29  SInt32 bugFix;
30  
31  [GTMSystemVersion getMajor:NULL minor:NULL bugFix:NULL];
32  [GTMSystemVersion getMajor:&major minor:NULL bugFix:NULL];
33  [GTMSystemVersion getMajor:NULL minor:&minor bugFix:NULL];
34  [GTMSystemVersion getMajor:NULL minor:NULL bugFix:&bugFix];
35  [GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugFix];
36#if GTM_IPHONE_SDK
37  STAssertTrue(major >= 2 && minor >= 0 && bugFix >= 0, nil);
38#else
39  STAssertTrue(major >= 10 && minor >= 3 && bugFix >= 0, nil);
40  BOOL isPanther = (major == 10) && (minor == 3);
41  BOOL isTiger = (major == 10) && (minor == 4);
42  BOOL isLeopard = (major == 10) && (minor == 5);
43  BOOL isSnowLeopard = (major == 10) && (minor == 6);
44  
45  BOOL isLater = (major > 10) || ((major == 10) && (minor > 6));
46  STAssertEquals([GTMSystemVersion isPanther], isPanther, nil);
47  STAssertEquals([GTMSystemVersion isPantherOrGreater],
48                 (BOOL)(isPanther || isTiger 
49                        || isLeopard || isSnowLeopard || isLater), nil);
50  STAssertEquals([GTMSystemVersion isTiger], isTiger, nil);
51  STAssertEquals([GTMSystemVersion isTigerOrGreater],
52                 (BOOL)(isTiger || isLeopard || isSnowLeopard || isLater), nil);
53  STAssertEquals([GTMSystemVersion isLeopard], isLeopard, nil);
54  STAssertEquals([GTMSystemVersion isLeopardOrGreater],
55                 (BOOL)(isLeopard || isSnowLeopard || isLater), nil);
56  STAssertEquals([GTMSystemVersion isSnowLeopard], isSnowLeopard, nil);
57  STAssertEquals([GTMSystemVersion isSnowLeopardOrGreater],
58                 (BOOL)(isSnowLeopard || isLater), nil);
59#endif  
60}
61
62- (void)testRuntimeArchitecture {
63  // Not sure how to test this short of recoding it and verifying.
64  // This at least executes the code for me.
65  STAssertNotNil([GTMSystemVersion runtimeArchitecture], nil);
66}
67
68- (void)testBuild {
69  // Not sure how to test this short of coding up a large fragile table.
70  // This at least executes the code for me.
71  NSString *systemVersion = [GTMSystemVersion build];
72  STAssertNotEquals([systemVersion length], (NSUInteger)0, nil);
73  
74  NSString *smallVersion = @"1A00";
75  NSString *largeVersion = @"100Z100";
76  STAssertTrue([GTMSystemVersion isBuildGreaterThan:smallVersion], nil);
77  STAssertFalse([GTMSystemVersion isBuildGreaterThan:systemVersion], nil);
78  STAssertFalse([GTMSystemVersion isBuildGreaterThan:largeVersion], nil);
79  STAssertTrue([GTMSystemVersion isBuildGreaterThanOrEqualTo:smallVersion], nil);
80  STAssertTrue([GTMSystemVersion isBuildGreaterThanOrEqualTo:systemVersion], nil);
81  STAssertFalse([GTMSystemVersion isBuildGreaterThanOrEqualTo:largeVersion], nil);
82  STAssertFalse([GTMSystemVersion isBuildEqualTo:smallVersion], nil);
83  STAssertTrue([GTMSystemVersion isBuildEqualTo:systemVersion], nil);
84  STAssertFalse([GTMSystemVersion isBuildEqualTo:largeVersion], nil);
85  STAssertFalse([GTMSystemVersion isBuildLessThanOrEqualTo:smallVersion], nil);
86  STAssertTrue([GTMSystemVersion isBuildLessThanOrEqualTo:systemVersion], nil);
87  STAssertTrue([GTMSystemVersion isBuildLessThanOrEqualTo:largeVersion], nil);
88  STAssertFalse([GTMSystemVersion isBuildLessThan:smallVersion], nil);
89  STAssertFalse([GTMSystemVersion isBuildLessThan:systemVersion], nil);
90  STAssertTrue([GTMSystemVersion isBuildLessThan:largeVersion], nil);
91  
92}
93@end