Permalink
Browse files

Fixes #222: Long version ids (12 digits based on reverse date) cause …

…update to work no longer
  • Loading branch information...
1 parent b86770c commit 7b3928db9b61d4eb97b26437d9ea1c9024539d49 @andymatuschak andymatuschak committed Nov 16, 2012
Showing with 11 additions and 6 deletions.
  1. +6 −6 SUStandardVersionComparator.m
  2. +5 −0 Tests/SUVersionComparisonTest.m
View
12 SUStandardVersionComparator.m
@@ -84,8 +84,8 @@ - (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)
NSArray *partsB = [self splitVersionString:versionB];
NSString *partA, *partB;
- NSUInteger i, n;
- int intA, intB;
+ int i, n;
+ long long valueA, valueB;
SUCharacterType typeA, typeB;
n = MIN([partsA count], [partsB count]);
@@ -100,11 +100,11 @@ - (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)
if (typeA == typeB) {
// Same type; we can compare
if (typeA == kNumberType) {
- intA = [partA intValue];
- intB = [partB intValue];
- if (intA > intB) {
+ valueA = [partA longLongValue];
+ valueB = [partB longLongValue];
+ if (valueA > valueB) {
return NSOrderedDescending;
- } else if (intA < intB) {
+ } else if (valueA < valueB) {
return NSOrderedAscending;
}
} else if (typeA == kStringType) {
View
5 Tests/SUVersionComparisonTest.m
@@ -59,4 +59,9 @@ - (void)testWordsWithSpaceInFront
// SUAssertEqual(@"1.0 - beta", @"1.0 beta");
}
+- (void)testVersionsWithReverseDateBasedNumbers
+{
+ SUAssertAscending(@"201210251627", @"201211051041");
+}
+
@end

0 comments on commit 7b3928d

Please sign in to comment.