/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. #import "GTMSenTestCase.h"
  19. #import "GTMSystemVersion.h"
  20. @interface GTMSystemVersionTest : GTMTestCase
  21. @end
  22. @implementation GTMSystemVersionTest
  23. - (void)testBasics {
  24. SInt32 major;
  25. SInt32 minor;
  26. SInt32 bugFix;
  27. [GTMSystemVersion getMajor:NULL minor:NULL bugFix:NULL];
  28. [GTMSystemVersion getMajor:&major minor:NULL bugFix:NULL];
  29. [GTMSystemVersion getMajor:NULL minor:&minor bugFix:NULL];
  30. [GTMSystemVersion getMajor:NULL minor:NULL bugFix:&bugFix];
  31. [GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugFix];
  32. #if GTM_IPHONE_SDK
  33. STAssertTrue(major >= 2 && minor >= 0 && bugFix >= 0, nil);
  34. #else
  35. STAssertTrue(major >= 10 && minor >= 3 && bugFix >= 0, nil);
  36. BOOL isPanther = (major == 10) && (minor == 3);
  37. BOOL isTiger = (major == 10) && (minor == 4);
  38. BOOL isLeopard = (major == 10) && (minor == 5);
  39. BOOL isSnowLeopard = (major == 10) && (minor == 6);
  40. BOOL isLater = (major > 10) || ((major == 10) && (minor > 6));
  41. STAssertEquals([GTMSystemVersion isPanther], isPanther, nil);
  42. STAssertEquals([GTMSystemVersion isPantherOrGreater],
  43. (BOOL)(isPanther || isTiger
  44. || isLeopard || isSnowLeopard || isLater), nil);
  45. STAssertEquals([GTMSystemVersion isTiger], isTiger, nil);
  46. STAssertEquals([GTMSystemVersion isTigerOrGreater],
  47. (BOOL)(isTiger || isLeopard || isSnowLeopard || isLater), nil);
  48. STAssertEquals([GTMSystemVersion isLeopard], isLeopard, nil);
  49. STAssertEquals([GTMSystemVersion isLeopardOrGreater],
  50. (BOOL)(isLeopard || isSnowLeopard || isLater), nil);
  51. STAssertEquals([GTMSystemVersion isSnowLeopard], isSnowLeopard, nil);
  52. STAssertEquals([GTMSystemVersion isSnowLeopardOrGreater],
  53. (BOOL)(isSnowLeopard || isLater), nil);
  54. #endif
  55. }
  56. - (void)testRuntimeArchitecture {
  57. // Not sure how to test this short of recoding it and verifying.
  58. // This at least executes the code for me.
  59. STAssertNotNil([GTMSystemVersion runtimeArchitecture], nil);
  60. }
  61. - (void)testBuild {
  62. // Not sure how to test this short of coding up a large fragile table.
  63. // This at least executes the code for me.
  64. NSString *systemVersion = [GTMSystemVersion build];
  65. STAssertNotEquals([systemVersion length], (NSUInteger)0, nil);
  66. NSString *smallVersion = @"1A00";
  67. NSString *largeVersion = @"100Z100";
  68. STAssertTrue([GTMSystemVersion isBuildGreaterThan:smallVersion], nil);
  69. STAssertFalse([GTMSystemVersion isBuildGreaterThan:systemVersion], nil);
  70. STAssertFalse([GTMSystemVersion isBuildGreaterThan:largeVersion], nil);
  71. STAssertTrue([GTMSystemVersion isBuildGreaterThanOrEqualTo:smallVersion], nil);
  72. STAssertTrue([GTMSystemVersion isBuildGreaterThanOrEqualTo:systemVersion], nil);
  73. STAssertFalse([GTMSystemVersion isBuildGreaterThanOrEqualTo:largeVersion], nil);
  74. STAssertFalse([GTMSystemVersion isBuildEqualTo:smallVersion], nil);
  75. STAssertTrue([GTMSystemVersion isBuildEqualTo:systemVersion], nil);
  76. STAssertFalse([GTMSystemVersion isBuildEqualTo:largeVersion], nil);
  77. STAssertFalse([GTMSystemVersion isBuildLessThanOrEqualTo:smallVersion], nil);
  78. STAssertTrue([GTMSystemVersion isBuildLessThanOrEqualTo:systemVersion], nil);
  79. STAssertTrue([GTMSystemVersion isBuildLessThanOrEqualTo:largeVersion], nil);
  80. STAssertFalse([GTMSystemVersion isBuildLessThan:smallVersion], nil);
  81. STAssertFalse([GTMSystemVersion isBuildLessThan:systemVersion], nil);
  82. STAssertTrue([GTMSystemVersion isBuildLessThan:largeVersion], nil);
  83. }
  84. @end