Test the parser's assignment of default development version numbers for various release types. GVU test coverage now 90.1%.
authorPeter Hosey <hg@boredzo.org>
Wed Oct 14 18:05:03 2009 -0700 (2009-10-14)
changeset 4523987556ed56e3
parent 4522 5fa478e3475a
child 4524 e21dae320e19
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.
Unit tests/TestVersionParsing.h
Unit tests/TestVersionParsing.m
     1.1 --- a/Unit tests/TestVersionParsing.h	Wed Oct 14 17:55:37 2009 -0700
     1.2 +++ b/Unit tests/TestVersionParsing.h	Wed Oct 14 18:05:03 2009 -0700
     1.3 @@ -35,4 +35,9 @@
     1.4  - (void) testParseTwoComponentSVNVersionWithSmallLetterRBeforeRevisionNumber;
     1.5  - (void) testParseTwoComponentSVNVersionWithSpacesAroundReleaseTypeAndSmallLetterRBeforeRevisionNumber;
     1.6  
     1.7 +- (void) testParseSVNVersionWithNoRevisionNumber;
     1.8 +- (void) testParseDevelopmentVersionWithNoDevelopmentVersionNumber;
     1.9 +- (void) testParseAlphaVersionWithNoDevelopmentVersionNumber;
    1.10 +- (void) testParseBetaVersionWithNoDevelopmentVersionNumber;
    1.11 +
    1.12  @end
     2.1 --- a/Unit tests/TestVersionParsing.m	Wed Oct 14 17:55:37 2009 -0700
     2.2 +++ b/Unit tests/TestVersionParsing.m	Wed Oct 14 18:05:03 2009 -0700
     2.3 @@ -386,4 +386,105 @@
     2.4  		version.development, (u_int32_t)1400);
     2.5  }
     2.6  
     2.7 +- (void) testParseSVNVersionWithNoRevisionNumber {
     2.8 +	struct Version version;
     2.9 +	NSString *string = @"1.3svn";
    2.10 +	STAssertTrue(parseVersionString(string, &version), @"Parse of %@ failed", string);
    2.11 +	STAssertEquals(
    2.12 +		version.major, (u_int16_t)1,
    2.13 +		@"Major component was %u, not %u",
    2.14 +		version.major, (u_int16_t)1);
    2.15 +	STAssertEquals(
    2.16 +		version.minor, (u_int16_t)3,
    2.17 +		@"Minor component was %u, not %u",
    2.18 +		version.minor, (u_int16_t)3);
    2.19 +	STAssertEquals(
    2.20 +		version.incremental, (u_int8_t)0,
    2.21 +		@"Incremental component was %u, not %u",
    2.22 +		version.incremental, (u_int8_t)0);
    2.23 +	STAssertEquals(
    2.24 +		version.releaseType, (u_int8_t)releaseType_svn,
    2.25 +		@"Release-type component was %u, not %u",
    2.26 +		version.releaseType, (u_int8_t)releaseType_svn);
    2.27 +	STAssertEquals(
    2.28 +		version.development, (u_int32_t)0,
    2.29 +		@"Development component (SVN revision) was %u, not %u",
    2.30 +		version.development, (u_int32_t)0);
    2.31 +}
    2.32 +- (void) testParseDevelopmentVersionWithNoDevelopmentVersionNumber {
    2.33 +	struct Version version;
    2.34 +	NSString *string = @"1.3d";
    2.35 +	STAssertTrue(parseVersionString(string, &version), @"Parse of %@ failed", string);
    2.36 +	STAssertEquals(
    2.37 +		version.major, (u_int16_t)1,
    2.38 +		@"Major component was %u, not %u",
    2.39 +		version.major, (u_int16_t)1);
    2.40 +	STAssertEquals(
    2.41 +		version.minor, (u_int16_t)3,
    2.42 +		@"Minor component was %u, not %u",
    2.43 +		version.minor, (u_int16_t)3);
    2.44 +	STAssertEquals(
    2.45 +		version.incremental, (u_int8_t)0,
    2.46 +		@"Incremental component was %u, not %u",
    2.47 +		version.incremental, (u_int8_t)0);
    2.48 +	STAssertEquals(
    2.49 +		version.releaseType, (u_int8_t)releaseType_development,
    2.50 +		@"Release-type component was %u, not %u",
    2.51 +		version.releaseType, (u_int8_t)releaseType_development);
    2.52 +	STAssertEquals(
    2.53 +		version.development, (u_int32_t)1,
    2.54 +		@"Development component (SVN revision) was %u, not %u",
    2.55 +		version.development, (u_int32_t)1);
    2.56 +}
    2.57 +- (void) testParseAlphaVersionWithNoDevelopmentVersionNumber {
    2.58 +	struct Version version;
    2.59 +	NSString *string = @"1.3a";
    2.60 +	STAssertTrue(parseVersionString(string, &version), @"Parse of %@ failed", string);
    2.61 +	STAssertEquals(
    2.62 +		version.major, (u_int16_t)1,
    2.63 +		@"Major component was %u, not %u",
    2.64 +		version.major, (u_int16_t)1);
    2.65 +	STAssertEquals(
    2.66 +		version.minor, (u_int16_t)3,
    2.67 +		@"Minor component was %u, not %u",
    2.68 +		version.minor, (u_int16_t)3);
    2.69 +	STAssertEquals(
    2.70 +		version.incremental, (u_int8_t)0,
    2.71 +		@"Incremental component was %u, not %u",
    2.72 +		version.incremental, (u_int8_t)0);
    2.73 +	STAssertEquals(
    2.74 +		version.releaseType, (u_int8_t)releaseType_alpha,
    2.75 +		@"Release-type component was %u, not %u",
    2.76 +		version.releaseType, (u_int8_t)releaseType_alpha);
    2.77 +	STAssertEquals(
    2.78 +		version.development, (u_int32_t)1,
    2.79 +		@"Development component (SVN revision) was %u, not %u",
    2.80 +		version.development, (u_int32_t)1);
    2.81 +}
    2.82 +- (void) testParseBetaVersionWithNoDevelopmentVersionNumber {
    2.83 +	struct Version version;
    2.84 +	NSString *string = @"1.3b";
    2.85 +	STAssertTrue(parseVersionString(string, &version), @"Parse of %@ failed", string);
    2.86 +	STAssertEquals(
    2.87 +		version.major, (u_int16_t)1,
    2.88 +		@"Major component was %u, not %u",
    2.89 +		version.major, (u_int16_t)1);
    2.90 +	STAssertEquals(
    2.91 +		version.minor, (u_int16_t)3,
    2.92 +		@"Minor component was %u, not %u",
    2.93 +		version.minor, (u_int16_t)3);
    2.94 +	STAssertEquals(
    2.95 +		version.incremental, (u_int8_t)0,
    2.96 +		@"Incremental component was %u, not %u",
    2.97 +		version.incremental, (u_int8_t)0);
    2.98 +	STAssertEquals(
    2.99 +		version.releaseType, (u_int8_t)releaseType_beta,
   2.100 +		@"Release-type component was %u, not %u",
   2.101 +		version.releaseType, (u_int8_t)releaseType_beta);
   2.102 +	STAssertEquals(
   2.103 +		version.development, (u_int32_t)1,
   2.104 +		@"Development component (SVN revision) was %u, not %u",
   2.105 +		version.development, (u_int32_t)1);
   2.106 +}
   2.107 +
   2.108  @end