Skip to content

Commit

Permalink
remove obsolete constructor from SemVersion (issue #70)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalkerCodeRanger committed Jan 22, 2023
1 parent fff2a80 commit 94be5f4
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 394 deletions.
142 changes: 62 additions & 80 deletions Semver.Test/Comparers/ComparerTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,86 +20,68 @@ public static class ComparerTestData
{
public static readonly IReadOnlyList<SemVersion> VersionsInSortOrder = new List<SemVersion>()
{
#pragma warning disable CS0618 // Type or member is obsolete
new SemVersion(-2),
new SemVersion(-1, -1),
new SemVersion(-1),
new SemVersion(0, -1),
new SemVersion(0, 0, -1),
new SemVersion(0),
new SemVersion(0, 0, 1, "13"),
new SemVersion(0, 0, 1, "."),
new SemVersion(0, 0, 1, ".."),
new SemVersion(0, 0, 1, ".a"),
new SemVersion(0, 0, 1, "b"),
new SemVersion(0, 0, 1, "gamma.12.87"),
new SemVersion(0, 0, 1, "gamma.12.87.1"),
new SemVersion(0, 0, 1, "gamma.12.87.99"),
new SemVersion(0, 0, 1, "gamma.12.87.-"),
new SemVersion(0, 0, 1, "gamma.12.87.X"),
new SemVersion(0, 0, 1, "gamma.12.88"),
new SemVersion(0, 0, 1),
new SemVersion(0, 0, 1, "", "."),
new SemVersion(0, 0, 1, "", ".."),
new SemVersion(0, 0, 1, "", ".a"),
new SemVersion(0, 0, 1, "", "12"),
new SemVersion(0, 0, 1, "", "b"),
new SemVersion(0, 0, 1, "", "bu"),
new SemVersion(0, 0, 1, "", "build.-"),
new SemVersion(0, 0, 1, "", "build.12"),
new SemVersion(0, 0, 1, "", "build.12.2"),
new SemVersion(0, 0, 1, "", "build.13"),
new SemVersion(0, 0, 1, "", "uiui"),
new SemVersion(0, 1, 1),
new SemVersion(0, 2, 1),
new SemVersion(1, 0, 0, "alpha"),
new SemVersion(1, 0, 0, "alpha", "dev.123"),
new SemVersion(1, 0, 0, "alpha", "😞"),
new SemVersion(1, 0, 0, "alpha.1"),
new SemVersion(1, 0, 0, "alpha.-"),
new SemVersion(1, 0, 0, "alpha.beta"),
new SemVersion(1, 0, 0, "beta"),
new SemVersion(1, 0, 0, "beta", "dev.123"),
new SemVersion(1, 0, 0, "beta.2"),
new SemVersion(1, 0, 0, "beta.11"),
new SemVersion(1, 0, 0, "rc.1"),
new SemVersion(1, 0, 0, "😞"),
new SemVersion(1),
new SemVersion(1, 0, 0, "", "CA6B10F"),
new SemVersion(1, 0, 10, "alpha"),
new SemVersion(1, 2, 0, "alpha", "dev"),
new SemVersion(1, 2, 0, "nightly"),
new SemVersion(1, 2, 0, "nightly", "dev"),
new SemVersion(1, 2, 0, "nightly2"),
new SemVersion(1, 2),
new SemVersion(1, 2, 0, "", "nightly"),
new SemVersion(1, 2, 1, "0"),
new SemVersion(1, 2, 1, "1"),
new SemVersion(1, 2, 1, "2"),
new SemVersion(1, 2, 1, "10"), // Sorts numeric after 2
new SemVersion(1, 2, 1, "99"),
new SemVersion(1, 2, 1, "-"),
new SemVersion(1, 2, 1, "-1"), // Sorts alphanumeric instead of numeric
new SemVersion(1, 2, 1, "-a"),
new SemVersion(1, 2, 1, "0A"),
new SemVersion(1, 2, 1, "A"),
new SemVersion(1, 2, 1, "a"),
new SemVersion(1, 2, 1),
new SemVersion(1, 2, 3, "01"),
new SemVersion(1, 2, 3, "1"),
new SemVersion(1, 2, 3, "a.000001"),
new SemVersion(1, 2, 3, "a.01"),
new SemVersion(1, 2, 3, "a.1"),
new SemVersion(1, 2, 3, "", "01"),
new SemVersion(1, 2, 3, "", "1"),
new SemVersion(1, 2, 3, "", "a.000001"),
new SemVersion(1, 2, 3, "", "a.01"),
new SemVersion(1, 2, 3, "", "a.1"),
new SemVersion(1, 4),
new SemVersion(2),
new SemVersion(2, 1),
new SemVersion(2, 1, 1),
#pragma warning restore CS0618 // Type or member is obsolete
SemVersion.ParsedFrom(0),
SemVersion.ParsedFrom(0, 0, 1, "13"),
SemVersion.ParsedFrom(0, 0, 1, "b"),
SemVersion.ParsedFrom(0, 0, 1, "gamma.12.87"),
SemVersion.ParsedFrom(0, 0, 1, "gamma.12.87.1"),
SemVersion.ParsedFrom(0, 0, 1, "gamma.12.87.99"),
SemVersion.ParsedFrom(0, 0, 1, "gamma.12.87.-"),
SemVersion.ParsedFrom(0, 0, 1, "gamma.12.87.X"),
SemVersion.ParsedFrom(0, 0, 1, "gamma.12.88"),
SemVersion.ParsedFrom(0, 0, 1),
SemVersion.ParsedFrom(0, 0, 1, "", "12"),
SemVersion.ParsedFrom(0, 0, 1, "", "b"),
SemVersion.ParsedFrom(0, 0, 1, "", "bu"),
SemVersion.ParsedFrom(0, 0, 1, "", "build.-"),
SemVersion.ParsedFrom(0, 0, 1, "", "build.12"),
SemVersion.ParsedFrom(0, 0, 1, "", "build.12.2"),
SemVersion.ParsedFrom(0, 0, 1, "", "build.13"),
SemVersion.ParsedFrom(0, 0, 1, "", "uiui"),
SemVersion.ParsedFrom(0, 1, 1),
SemVersion.ParsedFrom(0, 2, 1),
SemVersion.ParsedFrom(1, 0, 0, "alpha"),
SemVersion.ParsedFrom(1, 0, 0, "alpha", "dev.123"),
SemVersion.ParsedFrom(1, 0, 0, "alpha.1"),
SemVersion.ParsedFrom(1, 0, 0, "alpha.-"),
SemVersion.ParsedFrom(1, 0, 0, "alpha.beta"),
SemVersion.ParsedFrom(1, 0, 0, "beta"),
SemVersion.ParsedFrom(1, 0, 0, "beta", "dev.123"),
SemVersion.ParsedFrom(1, 0, 0, "beta.2"),
SemVersion.ParsedFrom(1, 0, 0, "beta.11"),
SemVersion.ParsedFrom(1, 0, 0, "rc.1"),
SemVersion.ParsedFrom(1),
SemVersion.ParsedFrom(1, 0, 0, "", "CA6B10F"),
SemVersion.ParsedFrom(1, 0, 10, "alpha"),
SemVersion.ParsedFrom(1, 2, 0, "alpha", "dev"),
SemVersion.ParsedFrom(1, 2, 0, "nightly"),
SemVersion.ParsedFrom(1, 2, 0, "nightly", "dev"),
SemVersion.ParsedFrom(1, 2, 0, "nightly2"),
SemVersion.ParsedFrom(1, 2),
SemVersion.ParsedFrom(1, 2, 0, "", "nightly"),
SemVersion.ParsedFrom(1, 2, 1, "0"),
SemVersion.ParsedFrom(1, 2, 1, "1"),
SemVersion.ParsedFrom(1, 2, 1, "2"),
SemVersion.ParsedFrom(1, 2, 1, "10"), // Sorts numeric after 2
SemVersion.ParsedFrom(1, 2, 1, "99"),
SemVersion.ParsedFrom(1, 2, 1, "-"),
SemVersion.ParsedFrom(1, 2, 1, "-1"), // Sorts alphanumeric instead of numeric
SemVersion.ParsedFrom(1, 2, 1, "-a"),
SemVersion.ParsedFrom(1, 2, 1, "0A"),
SemVersion.ParsedFrom(1, 2, 1, "A"),
SemVersion.ParsedFrom(1, 2, 1, "a"),
SemVersion.ParsedFrom(1, 2, 1),
SemVersion.ParsedFrom(1, 2, 3, "1"),
SemVersion.ParsedFrom(1, 2, 3, "a.1"),
SemVersion.ParsedFrom(1, 2, 3, "", "01"),
SemVersion.ParsedFrom(1, 2, 3, "", "1"),
SemVersion.ParsedFrom(1, 2, 3, "", "a.000001"),
SemVersion.ParsedFrom(1, 2, 3, "", "a.01"),
SemVersion.ParsedFrom(1, 2, 3, "", "a.1"),
SemVersion.ParsedFrom(1, 4),
SemVersion.ParsedFrom(2),
SemVersion.ParsedFrom(2, 1),
SemVersion.ParsedFrom(2, 1, 1),
}.AsReadOnly();

public static readonly IReadOnlyList<(SemVersion, SemVersion)> VersionPairs
Expand Down
15 changes: 6 additions & 9 deletions Semver.Test/Comparers/PrecedenceComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ public void EqualsIdenticalTest()
foreach (var v in ComparerTestData.VersionsInSortOrder)
{
// Construct an identical version, but different instance
#pragma warning disable CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch, v.Prerelease, v.Metadata);
#pragma warning restore CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch,
v.PrereleaseIdentifiers, v.MetadataIdentifiers);
Assert.True(Comparer.Equals(v, identical), v.ToString());
}
}
Expand Down Expand Up @@ -63,9 +62,8 @@ public void GetHashCodeIdenticalTest()
foreach (var v in ComparerTestData.VersionsInSortOrder)
{
// Construct an identical version, but different instance
#pragma warning disable CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch, v.Prerelease, v.Metadata);
#pragma warning restore CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch,
v.PrereleaseIdentifiers, v.MetadataIdentifiers);
Assert.True(Comparer.GetHashCode(v) == Comparer.GetHashCode(identical), v.ToString());
}
}
Expand All @@ -92,9 +90,8 @@ public void CompareIdenticalTest()
foreach (var v in ComparerTestData.VersionsInSortOrder)
{
// Construct an identical version, but different instance
#pragma warning disable CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch, v.Prerelease, v.Metadata);
#pragma warning restore CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch,
v.PrereleaseIdentifiers, v.MetadataIdentifiers);
Assert.True(Comparer.Compare(v, identical) == 0, v.ToString());
}
}
Expand Down
15 changes: 6 additions & 9 deletions Semver.Test/Comparers/SortOrderComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ public void EqualsIdenticalTest()
foreach (var v in ComparerTestData.VersionsInSortOrder)
{
// Construct an identical version, but different instance
#pragma warning disable CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch, v.Prerelease, v.Metadata);
#pragma warning restore CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch,
v.PrereleaseIdentifiers, v.MetadataIdentifiers);
Assert.True(Comparer.Equals(v, identical), v.ToString());
}
}
Expand Down Expand Up @@ -55,9 +54,8 @@ public void GetHashCodeIdenticalTest()
foreach (var v in ComparerTestData.VersionsInSortOrder)
{
// Construct an identical version, but different instance
#pragma warning disable CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch, v.Prerelease, v.Metadata);
#pragma warning restore CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch,
v.PrereleaseIdentifiers, v.MetadataIdentifiers);
Assert.True(Comparer.GetHashCode(v) == Comparer.GetHashCode(identical), v.ToString());
}
}
Expand All @@ -78,9 +76,8 @@ public void CompareIdenticalTest()
foreach (var v in ComparerTestData.VersionsInSortOrder)
{
// Construct an identical version, but different instance
#pragma warning disable CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch, v.Prerelease, v.Metadata);
#pragma warning restore CS0618 // Type or member is obsolete
var identical = new SemVersion(v.Major, v.Minor, v.Patch,
v.PrereleaseIdentifiers, v.MetadataIdentifiers);
Assert.True(Comparer.Compare(v, identical) == 0, v.ToString());
}
}
Expand Down
Loading

0 comments on commit 94be5f4

Please sign in to comment.