Peter Hosey avatar 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).

Comments (0)

Files changed (3)

Common/Source/GrowlVersionUtilities.c

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

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;

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";
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.