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).
authorPeter Hosey <hg@boredzo.org>
Thu Oct 15 16:16:16 2009 -0700 (2009-10-15)
changeset 4525e49d3c2578db
parent 4524 e21dae320e19
child 4526 990a94a64eb6
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).
Common/Source/GrowlVersionUtilities.c
Unit tests/TestVersionParsing.h
Unit tests/TestVersionParsing.m
     1.1 --- a/Common/Source/GrowlVersionUtilities.c	Wed Oct 14 20:16:19 2009 -0700
     1.2 +++ b/Common/Source/GrowlVersionUtilities.c	Thu Oct 15 16:16:16 2009 -0700
     1.3 @@ -131,6 +131,12 @@
     1.4  							}
     1.5  						}
     1.6  						break;
     1.7 +					case 'h':
     1.8 +						myReleaseType = releaseType_svn;
     1.9 +						if ((i < length) && (buf[i] == 'g')) {
    1.10 +							++i;
    1.11 +						}
    1.12 +						break;
    1.13  				}
    1.14  
    1.15  				while ((i < length) && isspace(buf[i])) {
     2.1 --- a/Unit tests/TestVersionParsing.h	Wed Oct 14 20:16:19 2009 -0700
     2.2 +++ b/Unit tests/TestVersionParsing.h	Thu Oct 15 16:16:16 2009 -0700
     2.3 @@ -13,11 +13,13 @@
     2.4  
     2.5  - (void) testParseNil;
     2.6  - (void) testParseTwoComponentSVNVersion;
     2.7 +- (void) testParseTwoComponentHgVersion;
     2.8  - (void) testParseTwoComponentDevelopmentVersion;
     2.9  - (void) testParseTwoComponentAlphaVersion;
    2.10  - (void) testParseTwoComponentBetaVersion;
    2.11  - (void) testParseTwoComponentReleaseVersion;
    2.12  - (void) testParseThreeComponentSVNVersion;
    2.13 +- (void) testParseThreeComponentHgVersion;
    2.14  - (void) testParseThreeComponentDevelopmentVersion;
    2.15  - (void) testParseThreeComponentAlphaVersion;
    2.16  - (void) testParseThreeComponentBetaVersion;
     3.1 --- a/Unit tests/TestVersionParsing.m	Wed Oct 14 20:16:19 2009 -0700
     3.2 +++ b/Unit tests/TestVersionParsing.m	Thu Oct 15 16:16:16 2009 -0700
     3.3 @@ -39,6 +39,31 @@
     3.4  		@"Development component (SVN revision) was %u, not %u",
     3.5  		version.development, (u_int32_t)1400);
     3.6  }
     3.7 +- (void) testParseTwoComponentHgVersion {
     3.8 +	struct Version version;
     3.9 +	NSString *string = @"1.3hg1400";
    3.10 +	STAssertTrue(parseVersionString(string, &version), @"Parse of %@ failed", string);
    3.11 +	STAssertEquals(
    3.12 +		version.major, (u_int16_t)1,
    3.13 +		@"Major component was %u, not %u",
    3.14 +		version.major, (u_int16_t)1);
    3.15 +	STAssertEquals(
    3.16 +		version.minor, (u_int16_t)3,
    3.17 +		@"Minor component was %u, not %u",
    3.18 +		version.minor, (u_int16_t)3);
    3.19 +	STAssertEquals(
    3.20 +		version.incremental, (u_int8_t)0,
    3.21 +		@"Incremental component was %u, not %u",
    3.22 +		version.incremental, (u_int8_t)0);
    3.23 +	STAssertEquals(
    3.24 +		version.releaseType, (u_int8_t)releaseType_svn,
    3.25 +		@"Release-type component was %u, not %u",
    3.26 +		version.releaseType, (u_int8_t)releaseType_svn);
    3.27 +	STAssertEquals(
    3.28 +		version.development, (u_int32_t)1400,
    3.29 +		@"Development component (Hg revision) was %u, not %u",
    3.30 +		version.development, (u_int32_t)1400);
    3.31 +}
    3.32  - (void) testParseTwoComponentDevelopmentVersion {
    3.33  	struct Version version;
    3.34  	NSString *string = @"1.3d1";
    3.35 @@ -165,6 +190,31 @@
    3.36  		@"Development component (SVN revision) was %u, not %u",
    3.37  		version.development, (u_int32_t)1400);
    3.38  }
    3.39 +- (void) testParseThreeComponentHgVersion {
    3.40 +	struct Version version;
    3.41 +	NSString *string = @"1.3.4hg1400";
    3.42 +	STAssertTrue(parseVersionString(string, &version), @"Parse of %@ failed", string);
    3.43 +	STAssertEquals(
    3.44 +		version.major, (u_int16_t)1,
    3.45 +		@"Major component was %u, not %u",
    3.46 +		version.major, (u_int16_t)1);
    3.47 +	STAssertEquals(
    3.48 +		version.minor, (u_int16_t)3,
    3.49 +		@"Minor component was %u, not %u",
    3.50 +		version.minor, (u_int16_t)3);
    3.51 +	STAssertEquals(
    3.52 +		version.incremental, (u_int8_t)4,
    3.53 +		@"Incremental component was %u, not %u",
    3.54 +		version.incremental, (u_int8_t)4);
    3.55 +	STAssertEquals(
    3.56 +		version.releaseType, (u_int8_t)releaseType_svn,
    3.57 +		@"Release-type component was %u, not %u",
    3.58 +		version.releaseType, (u_int8_t)releaseType_svn);
    3.59 +	STAssertEquals(
    3.60 +		version.development, (u_int32_t)1400,
    3.61 +		@"Development component (Hg revision) was %u, not %u",
    3.62 +		version.development, (u_int32_t)1400);
    3.63 +}
    3.64  - (void) testParseThreeComponentDevelopmentVersion {
    3.65  	struct Version version;
    3.66  	NSString *string = @"1.3.4d1";