Commits

Peter Hosey  committed e49d3c2

Add a couple of basic test cases for hg versions as well as svn versions. Same release type, but different name in the version string. GVU test coverage now 97% (I'm not sure how it went up, but I'll take it).

  • Participants
  • Parent commits e21dae3
  • Branches default

Comments (0)

Files changed (3)

File Common/Source/GrowlVersionUtilities.c

 							}
 						}
 						break;
+					case 'h':
+						myReleaseType = releaseType_svn;
+						if ((i < length) && (buf[i] == 'g')) {
+							++i;
+						}
+						break;
 				}
 
 				while ((i < length) && isspace(buf[i])) {

File Unit tests/TestVersionParsing.h

 
 - (void) testParseNil;
 - (void) testParseTwoComponentSVNVersion;
+- (void) testParseTwoComponentHgVersion;
 - (void) testParseTwoComponentDevelopmentVersion;
 - (void) testParseTwoComponentAlphaVersion;
 - (void) testParseTwoComponentBetaVersion;
 - (void) testParseTwoComponentReleaseVersion;
 - (void) testParseThreeComponentSVNVersion;
+- (void) testParseThreeComponentHgVersion;
 - (void) testParseThreeComponentDevelopmentVersion;
 - (void) testParseThreeComponentAlphaVersion;
 - (void) testParseThreeComponentBetaVersion;

File Unit tests/TestVersionParsing.m

 		@"Development component (SVN revision) was %u, not %u",
 		version.development, (u_int32_t)1400);
 }
+- (void) testParseTwoComponentHgVersion {
+	struct Version version;
+	NSString *string = @"1.3hg1400";
+	STAssertTrue(parseVersionString(string, &version), @"Parse of %@ failed", string);
+	STAssertEquals(
+		version.major, (u_int16_t)1,
+		@"Major component was %u, not %u",
+		version.major, (u_int16_t)1);
+	STAssertEquals(
+		version.minor, (u_int16_t)3,
+		@"Minor component was %u, not %u",
+		version.minor, (u_int16_t)3);
+	STAssertEquals(
+		version.incremental, (u_int8_t)0,
+		@"Incremental component was %u, not %u",
+		version.incremental, (u_int8_t)0);
+	STAssertEquals(
+		version.releaseType, (u_int8_t)releaseType_svn,
+		@"Release-type component was %u, not %u",
+		version.releaseType, (u_int8_t)releaseType_svn);
+	STAssertEquals(
+		version.development, (u_int32_t)1400,
+		@"Development component (Hg revision) was %u, not %u",
+		version.development, (u_int32_t)1400);
+}
 - (void) testParseTwoComponentDevelopmentVersion {
 	struct Version version;
 	NSString *string = @"1.3d1";
 		@"Development component (SVN revision) was %u, not %u",
 		version.development, (u_int32_t)1400);
 }
+- (void) testParseThreeComponentHgVersion {
+	struct Version version;
+	NSString *string = @"1.3.4hg1400";
+	STAssertTrue(parseVersionString(string, &version), @"Parse of %@ failed", string);
+	STAssertEquals(
+		version.major, (u_int16_t)1,
+		@"Major component was %u, not %u",
+		version.major, (u_int16_t)1);
+	STAssertEquals(
+		version.minor, (u_int16_t)3,
+		@"Minor component was %u, not %u",
+		version.minor, (u_int16_t)3);
+	STAssertEquals(
+		version.incremental, (u_int8_t)4,
+		@"Incremental component was %u, not %u",
+		version.incremental, (u_int8_t)4);
+	STAssertEquals(
+		version.releaseType, (u_int8_t)releaseType_svn,
+		@"Release-type component was %u, not %u",
+		version.releaseType, (u_int8_t)releaseType_svn);
+	STAssertEquals(
+		version.development, (u_int32_t)1400,
+		@"Development component (Hg revision) was %u, not %u",
+		version.development, (u_int32_t)1400);
+}
 - (void) testParseThreeComponentDevelopmentVersion {
 	struct Version version;
 	NSString *string = @"1.3.4d1";