Added test cases for comparing Version structures. All pass.
authorPeter Hosey <hg@boredzo.org>
Tue Oct 13 06:24:50 2009 -0700 (2009-10-13)
changeset 4519ae36d1878499
parent 4518 cf3cc57fd5f7
child 4520 ec1cf41d2ca4
Added test cases for comparing Version structures. All pass.
Growl.xcodeproj/project.pbxproj
Unit tests/TestVersionComparison.h
Unit tests/TestVersionComparison.m
     1.1 --- a/Growl.xcodeproj/project.pbxproj	Tue Oct 13 05:26:18 2009 -0700
     1.2 +++ b/Growl.xcodeproj/project.pbxproj	Tue Oct 13 06:24:50 2009 -0700
     1.3 @@ -101,6 +101,7 @@
     1.4  		31E184F51084632C0011C78B /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83282741073A6BD70044A959 /* Cocoa.framework */; };
     1.5  		31E18503108463E60011C78B /* TestVersionParsing.m in Sources */ = {isa = PBXBuildFile; fileRef = 31E18502108463E60011C78B /* TestVersionParsing.m */; };
     1.6  		31E18504108465590011C78B /* GrowlVersionUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = 0790135507D9321B0023B640 /* GrowlVersionUtilities.c */; };
     1.7 +		31E185E51084A9780011C78B /* TestVersionComparison.m in Sources */ = {isa = PBXBuildFile; fileRef = 31E185E41084A9780011C78B /* TestVersionComparison.m */; };
     1.8  		342157C00C2AE377004003BB /* PriorityTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 342157BE0C2AE377004003BB /* PriorityTransformer.m */; };
     1.9  		3433456E0790E39200C84B15 /* Bubbles.growlView in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0AB508AE0767C87B006EA5CB /* Bubbles.growlView */; };
    1.10  		343345880790E3D600C84B15 /* Smoke.growlView in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0AB508AF0767C87B006EA5CB /* Smoke.growlView */; };
    1.11 @@ -697,6 +698,8 @@
    1.12  		31E18501108463E60011C78B /* TestVersionParsing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestVersionParsing.h; sourceTree = "<group>"; };
    1.13  		31E18502108463E60011C78B /* TestVersionParsing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestVersionParsing.m; sourceTree = "<group>"; };
    1.14  		31E1852A108469460011C78B /* UnitTests-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UnitTests-Prefix.pch"; sourceTree = "<group>"; };
    1.15 +		31E185E31084A9780011C78B /* TestVersionComparison.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestVersionComparison.h; sourceTree = "<group>"; };
    1.16 +		31E185E41084A9780011C78B /* TestVersionComparison.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestVersionComparison.m; sourceTree = "<group>"; };
    1.17  		32DBCFA20370C41700C91783 /* Growl_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Growl_Prefix.pch; path = Core/Source/Growl_Prefix.pch; sourceTree = "<group>"; };
    1.18  		342157BD0C2AE377004003BB /* PriorityTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PriorityTransformer.h; path = Core/Source/PriorityTransformer.h; sourceTree = "<group>"; };
    1.19  		342157BE0C2AE377004003BB /* PriorityTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PriorityTransformer.m; path = Core/Source/PriorityTransformer.m; sourceTree = "<group>"; };
    1.20 @@ -1726,6 +1729,8 @@
    1.21  				31E1852A108469460011C78B /* UnitTests-Prefix.pch */,
    1.22  				31E18501108463E60011C78B /* TestVersionParsing.h */,
    1.23  				31E18502108463E60011C78B /* TestVersionParsing.m */,
    1.24 +				31E185E31084A9780011C78B /* TestVersionComparison.h */,
    1.25 +				31E185E41084A9780011C78B /* TestVersionComparison.m */,
    1.26  			);
    1.27  			path = "Unit tests";
    1.28  			sourceTree = "<group>";
    1.29 @@ -2852,6 +2857,7 @@
    1.30  			files = (
    1.31  				31E18503108463E60011C78B /* TestVersionParsing.m in Sources */,
    1.32  				31E18504108465590011C78B /* GrowlVersionUtilities.c in Sources */,
    1.33 +				31E185E51084A9780011C78B /* TestVersionComparison.m in Sources */,
    1.34  			);
    1.35  			runOnlyForDeploymentPostprocessing = 0;
    1.36  		};
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/Unit tests/TestVersionComparison.h	Tue Oct 13 06:24:50 2009 -0700
     2.3 @@ -0,0 +1,45 @@
     2.4 +//
     2.5 +//  TestVersionComparison.h
     2.6 +//  Growl
     2.7 +//
     2.8 +//  Created by Peter Hosey on 2009-10-13.
     2.9 +//  Copyright 2009 Peter Hosey. All rights reserved.
    2.10 +//
    2.11 +
    2.12 +#import <SenTestingKit/SenTestingKit.h>
    2.13 +
    2.14 +@interface TestVersionComparison : SenTestCase
    2.15 +{}
    2.16 +
    2.17 +- (void) testSVNVersionNewerThanSVNVersion;
    2.18 +- (void) testSVNVersionEqualToSVNVersion;
    2.19 +
    2.20 +- (void) testDevelopmentVersionNewerThanDevelopmentVersion;
    2.21 +- (void) testDevelopmentVersionEqualToDevelopmentVersion;
    2.22 +
    2.23 +- (void) testAlphaNewerThanAlpha;
    2.24 +- (void) testAlphaEqualToAlpha;
    2.25 +
    2.26 +- (void) testBetaNewerThanBeta;
    2.27 +- (void) testBetaEqualToBeta;
    2.28 +
    2.29 +- (void) testReleaseNewerThanRelease;
    2.30 +- (void) testReleaseEqualToRelease;
    2.31 +
    2.32 +#pragma mark -
    2.33 +
    2.34 +- (void) testReleaseNewerThanBeta;
    2.35 +- (void) testReleaseNewerThanAlpha;
    2.36 +- (void) testReleaseNewerThanDevelopmentVersion;
    2.37 +- (void) testReleaseNewerThanSVNVersion;
    2.38 +
    2.39 +- (void) testBetaNewerThanAlpha;
    2.40 +- (void) testBetaNewerThanDevelopmentVersion;
    2.41 +- (void) testBetaNewerThanSVNVersion;
    2.42 +
    2.43 +- (void) testAlphaNewerThanDevelopmentVersion;
    2.44 +- (void) testAlphaNewerThanSVNVersion;
    2.45 +
    2.46 +- (void) testDevelopmentVersionNewerThanSVNVersion;
    2.47 +
    2.48 +@end
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/Unit tests/TestVersionComparison.m	Tue Oct 13 06:24:50 2009 -0700
     3.3 @@ -0,0 +1,378 @@
     3.4 +//
     3.5 +//  TestVersionComparison.m
     3.6 +//  Growl
     3.7 +//
     3.8 +//  Created by Peter Hosey on 2009-10-13.
     3.9 +//  Copyright 2009 Peter Hosey. All rights reserved.
    3.10 +//
    3.11 +
    3.12 +#import "TestVersionComparison.h"
    3.13 +
    3.14 +#import "GrowlVersionUtilities.h"
    3.15 +
    3.16 +@implementation TestVersionComparison
    3.17 +
    3.18 +- (void) testSVNVersionNewerThanSVNVersion {
    3.19 +	struct Version older, newer;
    3.20 +	NSString *olderString = @"1.0svn1000", *newerString = @"1.0svn1009";
    3.21 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
    3.22 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
    3.23 +
    3.24 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
    3.25 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
    3.26 +
    3.27 +	olderString = @"1.0svn1000";
    3.28 +	newerString = @"2.5.1svn1009";
    3.29 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
    3.30 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
    3.31 +
    3.32 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
    3.33 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
    3.34 +}
    3.35 +- (void) testSVNVersionEqualToSVNVersion {
    3.36 +	struct Version versionA, versionB;
    3.37 +	NSString *string = @"1.0svn1000";
    3.38 +	STAssertTrue(parseVersionString(string, &versionA), @"Could not parse version string (prerequisite for equality test)");
    3.39 +	STAssertTrue(parseVersionString(string, &versionB), @"Could not parse version string (prerequisite for equality test)");
    3.40 +
    3.41 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version string (%@) must be equal to itself", string);
    3.42 +
    3.43 +	//Version-equal, but not string-equal.
    3.44 +	NSString *stringA = @"01.00svn01000";
    3.45 +	NSString *stringB =   @"1.0svn1000";
    3.46 +	STAssertTrue(parseVersionString(stringA, &versionA), @"Could not parse first version string (prerequisite for comparison test)");
    3.47 +	STAssertTrue(parseVersionString(stringB, &versionB), @"Could not parse second version string (prerequisite for comparison test)");
    3.48 +
    3.49 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version from string %@ must be equal to version from string %@", stringA, stringB);
    3.50 +}
    3.51 +
    3.52 +- (void) testDevelopmentVersionNewerThanDevelopmentVersion {
    3.53 +	struct Version older, newer;
    3.54 +	NSString *olderString = @"1.0d10", *newerString = @"1.0d19";
    3.55 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
    3.56 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
    3.57 +
    3.58 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
    3.59 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
    3.60 +
    3.61 +	//Note that in this case, the development field is *lower*. Earlier development versions of newer releases should always compare newer.
    3.62 +	olderString = @"1.0d10";
    3.63 +	newerString = @"2.5.1d5";
    3.64 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
    3.65 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
    3.66 +
    3.67 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
    3.68 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
    3.69 +}
    3.70 +- (void) testDevelopmentVersionEqualToDevelopmentVersion {
    3.71 +	struct Version versionA, versionB;
    3.72 +	NSString *string = @"1.0d10";
    3.73 +	STAssertTrue(parseVersionString(string, &versionA), @"Could not parse version string (prerequisite for equality test)");
    3.74 +	STAssertTrue(parseVersionString(string, &versionB), @"Could not parse version string (prerequisite for equality test)");
    3.75 +
    3.76 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version string (%@) must be equal to itself", string);
    3.77 +
    3.78 +	//Version-equal, but not string-equal.
    3.79 +	NSString *stringA = @"01.00d010";
    3.80 +	NSString *stringB =   @"1.0d10";
    3.81 +	STAssertTrue(parseVersionString(stringA, &versionA), @"Could not parse first version string (prerequisite for comparison test)");
    3.82 +	STAssertTrue(parseVersionString(stringB, &versionB), @"Could not parse second version string (prerequisite for comparison test)");
    3.83 +
    3.84 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version from string %@ must be equal to version from string %@", stringA, stringB);
    3.85 +}
    3.86 +
    3.87 +- (void) testAlphaNewerThanAlpha {
    3.88 +	struct Version older, newer;
    3.89 +	NSString *olderString = @"1.0a10", *newerString = @"1.0a19";
    3.90 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
    3.91 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
    3.92 +
    3.93 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
    3.94 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
    3.95 +
    3.96 +	//Note that in this case, the development field is *lower*. Earlier development versions of newer releases should always compare newer.
    3.97 +	olderString = @"1.0a10";
    3.98 +	newerString = @"2.5.1a5";
    3.99 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.100 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.101 +
   3.102 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
   3.103 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
   3.104 +}
   3.105 +- (void) testAlphaEqualToAlpha {
   3.106 +	struct Version versionA, versionB;
   3.107 +	NSString *string = @"1.0a10";
   3.108 +	STAssertTrue(parseVersionString(string, &versionA), @"Could not parse version string (prerequisite for equality test)");
   3.109 +	STAssertTrue(parseVersionString(string, &versionB), @"Could not parse version string (prerequisite for equality test)");
   3.110 +
   3.111 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version string (%@) must be equal to itself", string);
   3.112 +
   3.113 +	//Version-equal, but not string-equal.
   3.114 +	NSString *stringA = @"01.00a010";
   3.115 +	NSString *stringB =   @"1.0a10";
   3.116 +	STAssertTrue(parseVersionString(stringA, &versionA), @"Could not parse first version string (prerequisite for comparison test)");
   3.117 +	STAssertTrue(parseVersionString(stringB, &versionB), @"Could not parse second version string (prerequisite for comparison test)");
   3.118 +
   3.119 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version from string %@ must be equal to version from string %@", stringA, stringB);
   3.120 +}
   3.121 +
   3.122 +- (void) testBetaNewerThanBeta {
   3.123 +	struct Version older, newer;
   3.124 +	NSString *olderString = @"1.0b10", *newerString = @"1.0b19";
   3.125 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.126 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.127 +
   3.128 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
   3.129 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
   3.130 +
   3.131 +	//Note that in this case, the development field is *lower*. Earlier development versions of newer releases should always compare newer.
   3.132 +	olderString = @"1.0b10";
   3.133 +	newerString = @"2.5.1b5";
   3.134 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.135 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.136 +
   3.137 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
   3.138 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
   3.139 +}
   3.140 +- (void) testBetaEqualToBeta {
   3.141 +	struct Version versionA, versionB;
   3.142 +	NSString *string = @"1.0b10";
   3.143 +	STAssertTrue(parseVersionString(string, &versionA), @"Could not parse version string (prerequisite for equality test)");
   3.144 +	STAssertTrue(parseVersionString(string, &versionB), @"Could not parse version string (prerequisite for equality test)");
   3.145 +
   3.146 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version string (%@) must be equal to itself", string);
   3.147 +
   3.148 +	//Version-equal, but not string-equal.
   3.149 +	NSString *stringA = @"01.00b010";
   3.150 +	NSString *stringB =   @"1.0b10";
   3.151 +	STAssertTrue(parseVersionString(stringA, &versionA), @"Could not parse first version string (prerequisite for comparison test)");
   3.152 +	STAssertTrue(parseVersionString(stringB, &versionB), @"Could not parse second version string (prerequisite for comparison test)");
   3.153 +
   3.154 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version from string %@ must be equal to version from string %@", stringA, stringB);
   3.155 +}
   3.156 +
   3.157 +- (void) testReleaseNewerThanRelease {
   3.158 +	struct Version older, newer;
   3.159 +	NSString *olderString = @"1.0", *newerString = @"1.0.1";
   3.160 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.161 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.162 +
   3.163 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
   3.164 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
   3.165 +
   3.166 +	olderString = @"1.0";
   3.167 +	newerString = @"2.5.1";
   3.168 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.169 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.170 +
   3.171 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Older (%@) must be less than newer (%@)", olderString, newerString);
   3.172 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Newer (%@) must be greater than older (%@)", newerString, olderString);
   3.173 +}
   3.174 +- (void) testReleaseEqualToRelease {
   3.175 +	struct Version versionA, versionB;
   3.176 +	NSString *string = @"1.0";
   3.177 +	STAssertTrue(parseVersionString(string, &versionA), @"Could not parse version string (prerequisite for equality test)");
   3.178 +	STAssertTrue(parseVersionString(string, &versionB), @"Could not parse version string (prerequisite for equality test)");
   3.179 +
   3.180 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version string (%@) must be equal to itself", string);
   3.181 +
   3.182 +	//Version-equal, but not string-equal.
   3.183 +	NSString *stringA = @"01.00.0";
   3.184 +	NSString *stringB =  @"1.0";
   3.185 +	STAssertTrue(parseVersionString(stringA, &versionA), @"Could not parse first version string (prerequisite for comparison test)");
   3.186 +	STAssertTrue(parseVersionString(stringB, &versionB), @"Could not parse second version string (prerequisite for comparison test)");
   3.187 +
   3.188 +	STAssertEquals(compareVersions(versionA, versionB), (CFComparisonResult)kCFCompareEqualTo, @"Version from string %@ must be equal to version from string %@", stringA, stringB);
   3.189 +}
   3.190 +
   3.191 +#pragma mark -
   3.192 +
   3.193 +- (void) testReleaseNewerThanBeta {
   3.194 +	struct Version older, newer;
   3.195 +	NSString *olderString = @"1.0b5", *newerString = @"1.0";
   3.196 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.197 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.198 +
   3.199 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Beta (%@) must be less than release (%@)", olderString, newerString);
   3.200 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than beta (%@)", newerString, olderString);
   3.201 +
   3.202 +	//Inverse: Make sure an earlier beta of a later release compares as newer.
   3.203 +	olderString = newerString;
   3.204 +	newerString = @"2.0b2";
   3.205 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.206 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.207 +
   3.208 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Beta (%@) must be less than release (%@)", olderString, newerString);
   3.209 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than beta (%@)", newerString, olderString);
   3.210 +}
   3.211 +- (void) testReleaseNewerThanAlpha {
   3.212 +	struct Version older, newer;
   3.213 +	NSString *olderString = @"1.0a5", *newerString = @"1.0";
   3.214 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.215 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.216 +
   3.217 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Alpha (%@) must be less than release (%@)", olderString, newerString);
   3.218 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than alpha (%@)", newerString, olderString);
   3.219 +
   3.220 +	//Inverse: Make sure an earlier alpha of a later release compares as newer.
   3.221 +	olderString = newerString;
   3.222 +	newerString = @"2.0a2";
   3.223 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.224 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.225 +
   3.226 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Beta (%@) must be less than release (%@)", olderString, newerString);
   3.227 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than beta (%@)", newerString, olderString);
   3.228 +}
   3.229 +- (void) testReleaseNewerThanDevelopmentVersion {
   3.230 +	struct Version older, newer;
   3.231 +	NSString *olderString = @"1.0d5", *newerString = @"1.0";
   3.232 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.233 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.234 +
   3.235 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Development version (%@) must be less than release (%@)", olderString, newerString);
   3.236 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than development version (%@)", newerString, olderString);
   3.237 +
   3.238 +	//Inverse: Make sure an earlier development version of a later release compares as newer.
   3.239 +	olderString = newerString;
   3.240 +	newerString = @"2.0d2";
   3.241 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.242 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.243 +
   3.244 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Development version (%@) must be less than release (%@)", olderString, newerString);
   3.245 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than development version (%@)", newerString, olderString);
   3.246 +}
   3.247 +- (void) testReleaseNewerThanSVNVersion {
   3.248 +	struct Version older, newer;
   3.249 +	NSString *olderString = @"1.0svn500", *newerString = @"1.0";
   3.250 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.251 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.252 +
   3.253 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"SVN version (%@) must be less than release (%@)", olderString, newerString);
   3.254 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than SVN version (%@)", newerString, olderString);
   3.255 +
   3.256 +	//Inverse: Make sure an earlier SVN version of a later release compares as newer.
   3.257 +	//(This can happen in the case of reviving a maintenance branch for an emergency fix.)
   3.258 +	olderString = newerString;
   3.259 +	newerString = @"2.0svn200";
   3.260 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.261 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.262 +
   3.263 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"SVN version (%@) must be less than release (%@)", olderString, newerString);
   3.264 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than SVN version (%@)", newerString, olderString);
   3.265 +}
   3.266 +
   3.267 +- (void) testBetaNewerThanAlpha {
   3.268 +	struct Version older, newer;
   3.269 +	NSString *olderString = @"1.0a5", *newerString = @"1.0b4";
   3.270 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.271 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.272 +
   3.273 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Alpha (%@) must be less than beta (%@)", olderString, newerString);
   3.274 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Beta (%@) must be greater than alpha (%@)", newerString, olderString);
   3.275 +
   3.276 +	//Inverse: Make sure an earlier alpha of a later release compares as newer.
   3.277 +	olderString = newerString;
   3.278 +	newerString = @"2.0a2";
   3.279 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.280 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.281 +
   3.282 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Alpha (%@) must be less than beta (%@)", olderString, newerString);
   3.283 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Beta (%@) must be greater than alpha (%@)", newerString, olderString);
   3.284 +}
   3.285 +- (void) testBetaNewerThanDevelopmentVersion {
   3.286 +	struct Version older, newer;
   3.287 +	NSString *olderString = @"1.0d5", *newerString = @"1.0b4";
   3.288 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.289 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.290 +
   3.291 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Development version (%@) must be less than beta (%@)", olderString, newerString);
   3.292 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Beta (%@) must be greater than development version (%@)", newerString, olderString);
   3.293 +
   3.294 +	//Inverse: Make sure an earlier development version of a later release compares as newer.
   3.295 +	olderString = newerString;
   3.296 +	newerString = @"2.0d2";
   3.297 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.298 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.299 +
   3.300 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Development version (%@) must be less than beta (%@)", olderString, newerString);
   3.301 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Beta (%@) must be greater than development version (%@)", newerString, olderString);
   3.302 +}
   3.303 +- (void) testBetaNewerThanSVNVersion {
   3.304 +	struct Version older, newer;
   3.305 +	NSString *olderString = @"1.0svn500", *newerString = @"1.0b4";
   3.306 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.307 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.308 +
   3.309 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"SVN version (%@) must be less than beta (%@)", olderString, newerString);
   3.310 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Beta (%@) must be greater than SVN version (%@)", newerString, olderString);
   3.311 +
   3.312 +	//Inverse: Make sure an earlier SVN version of a later release compares as newer.
   3.313 +	//(This can happen in the case of reviving a maintenance branch for an emergency fix.)
   3.314 +	olderString = newerString;
   3.315 +	newerString = @"2.0svn200";
   3.316 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.317 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.318 +
   3.319 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"SVN version (%@) must be less than beta (%@)", olderString, newerString);
   3.320 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Beta (%@) must be greater than SVN version (%@)", newerString, olderString);
   3.321 +}
   3.322 +
   3.323 +- (void) testAlphaNewerThanDevelopmentVersion {
   3.324 +	struct Version older, newer;
   3.325 +	NSString *olderString = @"1.0d5", *newerString = @"1.0a4";
   3.326 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.327 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.328 +
   3.329 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Development version (%@) must be less than alpha (%@)", olderString, newerString);
   3.330 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Alpha (%@) must be greater than development version (%@)", newerString, olderString);
   3.331 +
   3.332 +	//Inverse: Make sure an earlier development version of a later release compares as newer.
   3.333 +	olderString = newerString;
   3.334 +	newerString = @"2.0d2";
   3.335 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.336 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.337 +
   3.338 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"Development version (%@) must be less than alpha (%@)", olderString, newerString);
   3.339 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Alpha (%@) must be greater than development version (%@)", newerString, olderString);
   3.340 +}
   3.341 +- (void) testAlphaNewerThanSVNVersion {
   3.342 +	struct Version older, newer;
   3.343 +	NSString *olderString = @"1.0svn500", *newerString = @"1.0a4";
   3.344 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.345 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.346 +
   3.347 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"SVN version (%@) must be less than alpha (%@)", olderString, newerString);
   3.348 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Alpha (%@) must be greater than SVN version (%@)", newerString, olderString);
   3.349 +
   3.350 +	//Inverse: Make sure an earlier SVN version of a later release compares as newer.
   3.351 +	//(This can happen in the case of reviving a maintenance branch for an emergency fix.)
   3.352 +	olderString = newerString;
   3.353 +	newerString = @"2.0svn200";
   3.354 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.355 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.356 +
   3.357 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"SVN version (%@) must be less than alpha (%@)", olderString, newerString);
   3.358 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Alpha (%@) must be greater than SVN version (%@)", newerString, olderString);
   3.359 +}
   3.360 +
   3.361 +- (void) testDevelopmentVersionNewerThanSVNVersion {
   3.362 +	struct Version older, newer;
   3.363 +	NSString *olderString = @"1.0svn500", *newerString = @"1.0d4";
   3.364 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.365 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.366 +
   3.367 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"SVN version (%@) must be less than development version (%@)", olderString, newerString);
   3.368 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Development version (%@) must be greater than SVN version (%@)", newerString, olderString);
   3.369 +
   3.370 +	//Inverse: Make sure an earlier SVN version of a later release compares as newer.
   3.371 +	//(This can happen in the case of reviving a maintenance branch for an emergency fix.)
   3.372 +	olderString = newerString;
   3.373 +	newerString = @"2.0svn200";
   3.374 +	STAssertTrue(parseVersionString(olderString, &older), @"Could not parse older version string (prerequisite for comparison test)");
   3.375 +	STAssertTrue(parseVersionString(newerString, &newer), @"Could not parse newer version string (prerequisite for comparison test)");
   3.376 +
   3.377 +	STAssertEquals(compareVersions(older, newer), (CFComparisonResult)kCFCompareLessThan, @"SVN version (%@) must be less than Development version (%@)", olderString, newerString);
   3.378 +	STAssertEquals(compareVersions(newer, older), (CFComparisonResult)kCFCompareGreaterThan, @"Release (%@) must be greater than SVN version (%@)", newerString, olderString);
   3.379 +}
   3.380 +
   3.381 +@end