Commits

Peter Hosey committed 987556e

Test the parser's assignment of default development version numbers for various release types. GVU test coverage now 90.1%.

I don't think this is right, though. Present Me says that the parser should reject these inputs, not accept them and make up the missing values.

Comments (0)

Files changed (2)

Unit tests/TestVersionParsing.h

 - (void) testParseTwoComponentSVNVersionWithSmallLetterRBeforeRevisionNumber;
 - (void) testParseTwoComponentSVNVersionWithSpacesAroundReleaseTypeAndSmallLetterRBeforeRevisionNumber;
 
+- (void) testParseSVNVersionWithNoRevisionNumber;
+- (void) testParseDevelopmentVersionWithNoDevelopmentVersionNumber;
+- (void) testParseAlphaVersionWithNoDevelopmentVersionNumber;
+- (void) testParseBetaVersionWithNoDevelopmentVersionNumber;
+
 @end

Unit tests/TestVersionParsing.m

 		version.development, (u_int32_t)1400);
 }
 
+- (void) testParseSVNVersionWithNoRevisionNumber {
+	struct Version version;
+	NSString *string = @"1.3svn";
+	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)0,
+		@"Development component (SVN revision) was %u, not %u",
+		version.development, (u_int32_t)0);
+}
+- (void) testParseDevelopmentVersionWithNoDevelopmentVersionNumber {
+	struct Version version;
+	NSString *string = @"1.3d";
+	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_development,
+		@"Release-type component was %u, not %u",
+		version.releaseType, (u_int8_t)releaseType_development);
+	STAssertEquals(
+		version.development, (u_int32_t)1,
+		@"Development component (SVN revision) was %u, not %u",
+		version.development, (u_int32_t)1);
+}
+- (void) testParseAlphaVersionWithNoDevelopmentVersionNumber {
+	struct Version version;
+	NSString *string = @"1.3a";
+	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_alpha,
+		@"Release-type component was %u, not %u",
+		version.releaseType, (u_int8_t)releaseType_alpha);
+	STAssertEquals(
+		version.development, (u_int32_t)1,
+		@"Development component (SVN revision) was %u, not %u",
+		version.development, (u_int32_t)1);
+}
+- (void) testParseBetaVersionWithNoDevelopmentVersionNumber {
+	struct Version version;
+	NSString *string = @"1.3b";
+	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_beta,
+		@"Release-type component was %u, not %u",
+		version.releaseType, (u_int8_t)releaseType_beta);
+	STAssertEquals(
+		version.development, (u_int32_t)1,
+		@"Development component (SVN revision) was %u, not %u",
+		version.development, (u_int32_t)1);
+}
+
 @end
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.