38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using Xunit;
|
|
|
|
namespace StellaOps.VersionComparison.Tests;
|
|
|
|
public partial class RpmVersionComparerTests
|
|
{
|
|
public static TheoryData<string, string, int> RpmComparisonCases => new()
|
|
{
|
|
// Epoch precedence
|
|
{ "0:1.0-1", "1:0.1-1", -1 },
|
|
{ "1:1.0-1", "0:9.9-9", 1 },
|
|
{ "1.0-1", "0:1.0-1", 0 }, // Missing epoch = 0
|
|
{ "2:1.0-1", "1:9.9-9", 1 },
|
|
|
|
// Numeric version ordering
|
|
{ "1.9-1", "1.10-1", -1 },
|
|
{ "1.02-1", "1.2-1", 0 }, // Leading zeros ignored
|
|
{ "1.0-1", "1.0.1-1", -1 },
|
|
{ "2.0-1", "1.999-1", 1 },
|
|
|
|
// Tilde pre-releases
|
|
{ "1.0~rc1-1", "1.0-1", -1 }, // Tilde sorts before release
|
|
{ "1.0~alpha-1", "1.0~beta-1", -1 },
|
|
{ "1.0~-1", "1.0-1", -1 },
|
|
{ "1.0~~-1", "1.0~-1", -1 }, // Double tilde < single
|
|
|
|
// Release qualifiers (RHEL backports)
|
|
{ "1.0-1.el8", "1.0-1.el8_5", -1 }, // Base < security update
|
|
{ "1.0-1.el8_5", "1.0-1.el8_5.1", -1 },
|
|
{ "1.0-1.el8", "1.0-1.el9", -1 }, // el8 < el9
|
|
{ "1.0-1.el9_2", "1.0-1.el9_3", -1 },
|
|
|
|
// Alpha suffix ordering (1.0a > 1.0 because "a" is additional segment)
|
|
{ "1.0a-1", "1.0-1", 1 }, // 1.0a > 1.0 (alpha suffix adds to version)
|
|
{ "1.0-1", "1.0a-1", -1 },
|
|
};
|
|
}
|